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

TypeScript aurelia-dependency-injection.Optional类代码示例

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

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



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

示例1: it

 it('createForCurrentScope', () => {
   const container = new Container();
   const standardValidator = {};
   container.registerInstance(Validator, standardValidator);
   const childContainer = container.createChild();
   const factory = childContainer.get(ValidationControllerFactory);
   const controller = factory.createForCurrentScope();
   expect(controller.validator).toBe(standardValidator);
   expect(container.get(Optional.of(ValidationController))).toBe(null);
   expect(childContainer.get(Optional.of(ValidationController))).toBe(controller);
   const customValidator = {};
   expect(factory.createForCurrentScope(customValidator).validator).toBe(customValidator);
 });
开发者ID:doktordirk,项目名称:validation,代码行数:13,代码来源:validation-controller-factory.ts


示例2: function

 return function(target, key, desc?) {
     if (!type) {
         // typescript
         type = metadata.get(metadataType, target, key);
     }
     injectFn(target, key, desc, Optional.of(type));
 };
开发者ID:matjaz,项目名称:aurelia-property-injection-1,代码行数:7,代码来源:decorators.ts


示例3: function

 return function(target, key, desc?) {
     if (type === undefined) {
         // typescript
         type = metadata.get('design:type', target, key);
     }
     inject(Optional.of(type))(target, key, desc ? desc : {});
 };
开发者ID:doktordirk,项目名称:aurelia-property-injection,代码行数:7,代码来源:decorators.ts


示例4: bind

  public bind(binding: any, source: any, rulesOrController?: ValidationController | any, rules?: any) {
    // identify the target element.
    const target = getTargetDOMElement(binding, source);

    // locate the controller.
    let controller: ValidationController;
    if (rulesOrController instanceof ValidationController) {
      controller = rulesOrController;
    } else {
      controller = source.container.get(Optional.of(ValidationController));
      rules = rulesOrController;
    }
    if (controller === null) {
      throw new Error(`A ValidationController has not been registered.`);
    }

    controller.registerBinding(binding, target, rules);
    binding.validationController = controller;
    const trigger = this.getValidateTrigger(controller);
    // tslint:disable-next-line:no-bitwise
    if (trigger & validateTrigger.change) {
      binding.standardUpdateSource = binding.updateSource;
      // tslint:disable-next-line:only-arrow-functions
      // tslint:disable-next-line:space-before-function-paren
      binding.updateSource = function (value: any) {
        this.standardUpdateSource(value);
        this.validationController.validateBinding(this);
      };
    }

    // tslint:disable-next-line:no-bitwise
    if (trigger & validateTrigger.blur) {
      binding.validateBlurHandler = () => {
        this.taskQueue.queueMicroTask(() => controller.validateBinding(binding));
      };
      binding.validateTarget = target;
      target.addEventListener('blur', binding.validateBlurHandler);
    }

    if (trigger !== validateTrigger.manual) {
      binding.standardUpdateTarget = binding.updateTarget;
      // tslint:disable-next-line:only-arrow-functions
      // tslint:disable-next-line:space-before-function-paren
      binding.updateTarget = function (value: any) {
        this.standardUpdateTarget(value);
        this.validationController.resetBinding(this);
      };
    }
  }
开发者ID:StrahilKazlachev,项目名称:validation,代码行数:49,代码来源:validate-binding-behavior-base.ts


示例5: inject

 /**@internal */
 static inject() {
   return [DOM.Element, Animator, Optional.of(DOM.boundary, true)];
 }
开发者ID:aurelia,项目名称:templating-resources,代码行数:4,代码来源:show.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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