How to use the aurelia-metadata.Metadata.get function in aurelia-metadata

To help you get started, we’ve selected a few aurelia-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / dependency-injection / dist / es6 / aurelia-dependency-injection.js View on Github external
autoRegister(fn: any, key?: any): void {
    let registration;

    if (fn === null || fn === undefined) {
      throw new Error(badKeyError);
    }

    if (typeof fn === 'function') {
      registration = Metadata.get(Metadata.registration, fn);

      if (registration !== undefined) {
        registration.register(this, key || fn, fn);
      } else {
        this.registerSingleton(key || fn, fn);
      }
    } else {
      this.registerInstance(fn, fn);
    }
  }
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / module-analyzer.ts View on Github external
constructor(key, exportedValue, resourceTypeMeta?){
    if(!resourceTypeMeta){
      resourceTypeMeta = Metadata.get(Metadata.resource, exportedValue);

      if(!resourceTypeMeta){
        resourceTypeMeta = new HtmlBehaviorResource();
        resourceTypeMeta.elementName = hyphenate(key);
        Reflect.defineMetadata(Metadata.resource, resourceTypeMeta, exportedValue);
      }
    }

    if(resourceTypeMeta instanceof HtmlBehaviorResource){
      if(resourceTypeMeta.elementName === undefined){
        //customeElement()
        resourceTypeMeta.elementName = hyphenate(key);
      } else if(resourceTypeMeta.attributeName === undefined){
        //customAttribute()
        resourceTypeMeta.attributeName = hyphenate(key);
      } else if(resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null){
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / module-analyzer.js View on Github external
return resourceModule;
        }
        resourceModule = new ResourceModule(moduleId);
        this.cache[moduleId] = resourceModule;
        if (typeof moduleInstance === 'function') {
            moduleInstance = { 'default': moduleInstance };
        }
        if (viewModelMember) {
            mainResource = new ResourceDescription(viewModelMember, moduleInstance[viewModelMember]);
        }
        for (key in moduleInstance) {
            exportedValue = moduleInstance[key];
            if (key === viewModelMember || typeof exportedValue !== 'function') {
                continue;
            }
            resourceTypeMeta = Metadata.get(Metadata.resource, exportedValue);
            if (resourceTypeMeta) {
                if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) {
                    //no customeElement or customAttribute but behavior added by other metadata
                    HtmlBehaviorResource.convention(key, resourceTypeMeta);
                }
                if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) {
                    //no convention and no customeElement or customAttribute but behavior added by other metadata
                    resourceTypeMeta.elementName = hyphenate(key);
                }
                if (!mainResource && resourceTypeMeta instanceof HtmlBehaviorResource && resourceTypeMeta.elementName !== null) {
                    mainResource = new ResourceDescription(key, exportedValue, resourceTypeMeta);
                }
                else {
                    resources.push(new ResourceDescription(key, exportedValue, resourceTypeMeta));
                }
            }
github cmichaelgraham / aurelia-ts-port / aurelia-ts / dependency-injection / container.js View on Github external
autoRegister(fn, key) {
        var registration;
        if (fn === null || fn === undefined) {
            throw new Error('fn cannot be null or undefined.');
        }
        registration = Metadata.get(Metadata.registration, fn);
        if (registration !== undefined) {
            registration.register(this, key || fn, fn);
        }
        else {
            this.registerSingleton(key || fn, fn);
        }
    }
    /**
github aurelia / dependency-injection / dist / aurelia-dependency-injection.js View on Github external
autoRegister(fn : any, key? : any) : void {
    var registration;

    if (fn === null || fn === undefined){
      throw new Error(badKeyError)
    }

    if(typeof fn === 'function'){
      registration = Metadata.get(Metadata.registration, fn);

      if(registration !== undefined){
        registration.register(this, key || fn, fn);
      }else{
        this.registerSingleton(key || fn, fn);
      }
    }else{
      this.registerInstance(fn, fn);
    }
  }
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / view-strategy.ts View on Github external
static getDefault(target){
    var strategy, annotation;

    if(typeof target !== 'function'){
      target = target.constructor;
    }

    annotation = Origin.get(target);
    strategy = Metadata.get(ViewStrategy.metadataKey, target);

    if(!strategy){
      if(!annotation){
        throw AggregateError('Cannot determinte default view strategy for object.', target);
      }

      strategy = new ConventionalViewStrategy(annotation.moduleId);
    }else if(annotation){
      strategy.moduleId = annotation.moduleId;
    }

    return strategy;
  }
}