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


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

本文整理匯總了TypeScript中aurelia-dependency-injection.Container的典型用法代碼示例。如果您正苦於以下問題:TypeScript Container類的具體用法?TypeScript Container怎麽用?TypeScript Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Container類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('ToDo', () => {
  const container = new Container();
  const httpClient = container.get(Rest);
  const githubClient = container.get(Rest);
  const dataServices = new DataServices(httpClient, githubClient);
  let sut = new ToDo(dataServices);

  describe('constructor()', () => {
    it('dataServices should be defined', () => {
      expect(sut.dataServices).toBeDefined();
    });
  });

  describe('activate()', () => {
    let todoItems = [
      { id: 1, description: 'I need to read PinpointTownes' }
    ];
    it('todoItems exist', done => {
      spyOn(dataServices, 'getToDoItems').and.callFake(() => {
        return Promise.resolve(todoItems);
      });
      sut.activate()
        .then(() => {
          expect(sut.todoItems).toBe(todoItems);
          done();
        });
    });
  });
});
開發者ID:SoftwareMasons,項目名稱:aurelia-openiddict,代碼行數:29,代碼來源:todo.spec.ts

示例2: beforeEach

    beforeEach(() => {
        container = new Container();
        container.registerInstance(Element, DOM.createElement("div"));
        templatingEngine = container.get(TemplatingEngine);

        sut = templatingEngine.createViewModelForUnitTest(ScrollSpyElement);
    });
開發者ID:eriklieben,項目名稱:old-aurelia-materialize-css-before-rc1,代碼行數:7,代碼來源:scrollspyElement.spec.ts

示例3: beforeEach

  beforeEach(() => {
    history = new MockHistory();
    container = new Container();
    container.registerSingleton(RouteLoader, MockLoader);
    // tslint:disable-next-line
    ea = { publish() { } } as any;
    viewPort = {
      process(viewPortInstruction: ViewPortInstruction) {
        return Promise.resolve();
      },
      // tslint:disable-next-line
      swap() { }
    } as any;

    // tslint:disable-next-line
    instruction = { resolve() { } } as any;
    provider = {
      createPipeline() {
        let p = new Pipeline();
        p.addStep({ run(inst, next) { return pipelineStep(inst, next); } });
        return p;
      }
    } as any;

    router = new AppRouter(container, history, provider, ea);
  });
開發者ID:aurelia,項目名稱:router,代碼行數:26,代碼來源:app-router.spec.ts

示例4: beforeEach

    beforeEach(() => {
        container = new Container();
        container.registerInstance(Element, DOM.createElement("div"));
        templatingEngine = container.get(TemplatingEngine);
        sut = templatingEngine.createViewModelForUnitTest(DropdownDividerAttribute);

    });
開發者ID:eriklieben,項目名稱:old-aurelia-materialize-css-before-rc1,代碼行數:7,代碼來源:dropdownDividerAttribute.spec.ts

示例5: beforeEach

    beforeEach(() => {
        container = new Container();
        templatingEngine = container.get(TemplatingEngine);

        sut = templatingEngine.createViewModelForUnitTest(ButtonElement);
        sut.element = DOM.createElement("a");
    });
開發者ID:eriklieben,項目名稱:old-aurelia-materialize-css-before-rc1,代碼行數:7,代碼來源:buttonElement.spec.ts

示例6: it

        it('should return null when the parent container is not present', () => {
            var sut = new Parent("test"),
                childContainer = new Container(),
                instance = {};

            childContainer.registerInstance("test", instance);
            expect(sut.get(childContainer)).toBe(null);
        });
開發者ID:behzad888,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:metadata.spec.ts

示例7: get

 public get(container: Container): any {
     let dynamicDependencies = this.dynamicDependencies.length > 0 ?
         this.dynamicDependencies.map(dependency => dependency["protocol:aurelia:resolver"] ?
         dependency.get(container) : container.invoke(dependency)) : undefined;
     const instance = container.invoke(this.key, dynamicDependencies);
     container.registerInstance(this.asKey, instance);
     return instance;
 }
開發者ID:devaur,項目名稱:aurelia-property-injection,代碼行數:8,代碼來源:resolvers.ts

示例8: beforeAll

 beforeAll(() => {
   const container = new Container();
   container.registerInstance(BindingLanguage, container.get(TemplatingBindingLanguage));
   const messageParser = container.get(ValidationMessageParser);
   const propertyParser = container.get(PropertyAccessorParser);
   ValidationRules.initialize(messageParser, propertyParser);
   validator = container.get(StandardValidator);
 });
開發者ID:doktordirk,項目名稱:validation,代碼行數:8,代碼來源:validator.ts

示例9: beforeAll

 beforeAll(() => {
   let container = new Container();
   bindingEngine = container.get(BindingEngine);
   let bindingBehaviors = {
     updateTrigger: container.get(UpdateTriggerBindingBehavior)
   };
   lookupFunctions = { bindingBehaviors: name => bindingBehaviors[name] };
 });
開發者ID:aurelia,項目名稱:templating-resources,代碼行數:8,代碼來源:update-trigger-binding-behavior.spec.ts

示例10: create

 /**
  * Creates a new controller instance.
  */
 public create(validator?: Validator) {
   if (!validator) {
     validator = this.container.get(Validator) as Validator;
   }
   const propertyParser = this.container.get(PropertyAccessorParser) as PropertyAccessorParser;
   return new ValidationController(validator, propertyParser);
 }
開發者ID:StrahilKazlachev,項目名稱:validation,代碼行數:10,代碼來源:validation-controller-factory.ts


注:本文中的aurelia-dependency-injection.Container類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。