當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript aurelia-dependency-injection.Optional類代碼示例

本文整理匯總了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;未經允許,請勿轉載。