• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript aurelia-metadata.metadata类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中aurelia-metadata.metadata的典型用法代码示例。如果您正苦于以下问题:TypeScript metadata类的具体用法?TypeScript metadata怎么用?TypeScript metadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了metadata类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

 const deco = function (target, key, descriptor?) {
     if (!key) {
         target.inject = metadata.getOwn(metadata.paramTypes, target, key) || emptyParameters;
     } else if (!descriptor) {
         if (!target.constructor.injectProperties) {
             target.constructor.injectProperties = Object.create(null);
         }
         target.constructor.injectProperties[key] = metadata.getOwn(metadataType, target, key);
     }
 };
开发者ID:matjaz,项目名称:aurelia-property-injection-1,代码行数:10,代码来源:decorators.ts


示例2: function

 let deco = function (target, key, descriptor?) {
     if (key === undefined) {
         target.inject = metadata.getOwn(metadata.paramTypes, target, key) || Object.freeze([]);
     } else if (descriptor === undefined) {
         if (target.constructor.injectProperties === undefined) {
             target.constructor.injectProperties = Object.create(null);
         }
         target.constructor.injectProperties[key] = metadata.getOwn("design:type", target, key);
     }
 };
开发者ID:doktordirk,项目名称:aurelia-property-injection,代码行数:10,代码来源:decorators.ts


示例3: bindingFunction

export function bindingFunction(nameOrTarget){
  if(nameOrTarget === undefined || typeof nameOrTarget === 'string'){
    return function(target) {
      metadata.define(metadata.resource, new BindingFunctionResource(nameOrTarget), target);
    }
  }

  metadata.define(metadata.resource, new BindingFunctionResource(), nameOrTarget);
}
开发者ID:niieani,项目名称:aurelia-binding-functions,代码行数:9,代码来源:binding-function-resource.ts


示例4: createViewResources

// create the root view resources.
function createViewResources(container) {
  let resources = new ViewResources();

  // repeat
  let resource = metadata.get(metadata.resource, Repeat) as HtmlBehaviorResource;
  resource.target = Repeat;
  resource.initialize(container, Repeat);
  resources.registerAttribute('repeat', resource, 'repeat');
  // if
  resource = metadata.get(metadata.resource, If) as HtmlBehaviorResource;
  resource.target = If;
  resource.initialize(container, If);
  resources.registerAttribute('if', resource, 'if');
  // compose
  resource = metadata.get(metadata.resource, Compose) as HtmlBehaviorResource;
  resource.target = Compose;
  resource.initialize(container, Compose);
  resources.registerElement('compose', resource);

  container.registerInstance(ViewResources, resources);

  // slice value converter
  resources.registerValueConverter('slice', { toView: array => array ? array.slice(0) : array });

  // no-op value converter
  resources.registerValueConverter('noopValueConverter', { toView: value => value });

  // toLength value converter
  resources.registerValueConverter('toLength', { toView: collection => collection ? (collection.length || collection.size || 0) : 0 });

  // no-op binding behavior
  resources.registerBindingBehavior('noopBehavior', { bind: () => {/**/}, unbind: () => {/**/} });

  // oneTime binding behavior
  resources.registerBindingBehavior('oneTime', new OneTimeBindingBehavior());
}
开发者ID:aurelia,项目名称:templating-resources,代码行数:37,代码来源:repeat-integration.spec.ts


示例5: analyze

  ModuleAnalyzer.prototype.analyze = function analyze(moduleId: string, moduleInstance: any, mainResourceKey?: string): ResourceModule {
    let mainResource;
    let fallbackValue;
    let fallbackKey;
    let resourceTypeMeta;
    let key;
    let exportedValue;
    let resources = [];
    let conventional;
    let vs;
    let resourceModule;

    resourceModule = this.cache[moduleId];
    if (resourceModule) {
      return resourceModule;
    }

    resourceModule = new ResourceModule(moduleId);
    this.cache[moduleId] = resourceModule;

    if (typeof moduleInstance === 'function') {
      moduleInstance = {'default': moduleInstance};
    }

    if (mainResourceKey) {
      mainResource = new ResourceDescription(mainResourceKey, moduleInstance[mainResourceKey]);
    }

    for (key in moduleInstance) {
      exportedValue = moduleInstance[key];

      if (key === mainResourceKey || 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));
        }
      } else if (viewStrategy.decorates(exportedValue)) {
        vs = exportedValue;
      } else if (exportedValue instanceof TemplateRegistryEntry) {
        vs = new TemplateRegistryViewStrategy(moduleId, exportedValue);
      } else {
        if (conventional = HtmlBehaviorResource.convention(key)) {
          if (conventional.elementName !== null && !mainResource) {
            mainResource = new ResourceDescription(key, exportedValue, conventional);
          } else {
            resources.push(new ResourceDescription(key, exportedValue, conventional));
          }

          metadata.define(metadata.resource, conventional, exportedValue);
        } else if (conventional = ValueConverterResource.convention(key)) {
          resources.push(new ResourceDescription(key, exportedValue, conventional));
          metadata.define(metadata.resource, conventional, exportedValue);
        } else if (conventional = BindingBehaviorResource.convention(key)) {
          resources.push(new ResourceDescription(key, exportedValue, conventional));
          metadata.define(metadata.resource, conventional, exportedValue);
        } else if (conventional = BindingFunctionResource.convention(key)) {
          resources.push(new ResourceDescription(key, exportedValue, conventional));
          metadata.define(metadata.resource, conventional, exportedValue);
        } else if (!fallbackValue) {
          fallbackValue = exportedValue;
          fallbackKey = key;
        }
      }
    }

    if (!mainResource && fallbackValue) {
      mainResource = new ResourceDescription(fallbackKey, fallbackValue);
    }

    resourceModule.moduleInstance = moduleInstance;
    resourceModule.mainResource = mainResource;
    resourceModule.resources = resources;
    resourceModule.viewStrategy = vs;

    return resourceModule;
  }
开发者ID:niieani,项目名称:aurelia-binding-functions,代码行数:93,代码来源:module-analyzer.ts


示例6: function

 return function(target) {
   metadata.define(metadata.resource, new BindingFunctionResource(nameOrTarget), target);
 }
开发者ID:niieani,项目名称:aurelia-binding-functions,代码行数:3,代码来源:binding-function-resource.ts


示例7: return

 return (target: any) => {
     metadata.define(symbols.alias, alias, target);
 };
开发者ID:OmniSharp,项目名称:atom-languageclient,代码行数:3,代码来源:decorators.ts



注:本文中的aurelia-metadata.metadata类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript aurelia-orm.Repository类代码示例发布时间:2022-05-25
下一篇:
TypeScript aurelia-metadata.Metadata类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap