当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Container.get方法代码示例

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


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

示例1: beforeEach

  beforeEach(done => {
    let container = new Container();
    viewSlot = new ViewSlotMock();
    viewFactory = new BoundViewFactoryMock();
    observerLocator = container.get(ObserverLocator);
    repeatStrategyLocator = container.get(RepeatStrategyLocator);
    repeatStrategyMock = new RepeatStrategyMock();
    container.registerInstance(TargetInstruction, instructionMock);
    container.registerInstance(ViewResources, viewResourcesMock);
    container.registerInstance(ViewSlot, viewSlot);
    container.registerInstance(BoundViewFactory, viewFactory);

    component = StageComponent.withResources().inView('<div repeat.for="item of items"></div>').boundTo({ items: [] });

    component.create(bootstrap).then(() => {
      repeat = component.viewModel;
      repeat.viewSlot = viewSlot;
      repeat.instruction = instructionMock;
      repeat.viewFactory = viewFactory;
      repeat.observerLocator = observerLocator;
      repeat.strategyLocator = repeatStrategyLocator;
      done();
    });

  });
开发者ID:aurelia,项目名称:templating-resources,代码行数:25,代码来源:repeat.spec.ts

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: it

 it('should not modify the default settings', async done => {
   const overrideSettings = { model: 'model data' };
   const expectedSettings = Object.assign({}, container.get(DefaultDialogSettings));
   await _success(() => dialogService.open(overrideSettings), done);
   // clone again the default settings, jasmine doesn't like them being a class
   const actualSettings = Object.assign({}, container.get(DefaultDialogSettings));
   expect(actualSettings).toEqual(expectedSettings);
   done();
 });
开发者ID:HIRANO-Satoshi,项目名称:dialog,代码行数:9,代码来源:dialog-service.spec.ts

示例7: describe

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

  describe('constructor()', () => {
    it('should have a resourceClient defined', () => {
      expect(sut.resourcesClient).toBeDefined();
    });

    it('should have logger defined with Data Services as id', () => {
      expect(sut.logger).toBeDefined();
      expect(sut.logger.id).toBe('Data Services');
    });

    it('should have a githubClient defined', () => {
      expect(sut.githubClient).toBeDefined();
    });
  });

  describe('getToDoItems()', () => {
    it('returns items for only authenticated user', done => {
      let todoItems = [
        { id: 1, description: 'I need to read PinpointTownes' }
      ];
      spyOn(httpClient, 'find').and.callFake((endPoint) => {
        if (endPoint === 'todoItems') {
          return Promise.resolve(todoItems);
        }
      });
      sut.getToDoItems().then(response => {
        expect(response).toBe(todoItems);
        done();
      });
    });
  });

  describe('getUsers', () => {
    it('returns users', done => {
      let users = [
        { userId: 1, userName: 'John Doe' }
      ];
      spyOn(githubClient, 'find').and.callFake((endPoint) => {
        if (endPoint === 'users') {
          return Promise.resolve(users);
        }
      });
      sut.getUsers().then(response => {
        expect(response).toBe(users);
        done();
      });
    });
  });
});
开发者ID:SoftwareMasons,项目名称:aurelia-openiddict,代码行数:55,代码来源:dataServices.spec.ts

示例8: beforeAll

 beforeAll(() => {
   const container = new Container();
   bindingEngine = container.get(BindingEngine);
   const bindingBehaviors = {
     attr: container.get(AttrBindingBehavior)
   };
   const valueConverters = {};
   lookupFunctions = {
     bindingBehaviors: name => bindingBehaviors[name],
     valueConverters: name => valueConverters[name]
   };
 });
开发者ID:aurelia,项目名称:templating-resources,代码行数:12,代码来源:attr-binding-behavior.spec.ts

示例9: configure

export function configure(frameworkConfiguration: FrameworkConfiguration, pluginConfiguration: Function) {
    let container: Container = frameworkConfiguration.container;
    let storage: LocalStorage = container.get(LocalStorage);
    let securityContext: SecurityContext = container.get(SecurityContext);
    if (pluginConfiguration) {
        pluginConfiguration(securityContext);
    }
    return securityContext.authenticate(new ImplicitCredential()).then(null, failure => {
        return storage.get<string>(securityContext.configuration.authorizationTokenStorageKey).then(token => {
            return securityContext.authenticate(new TokenCredential(token));
        }).then(null, tokenNotValid => securityContext.deleteAndRevokeToken());
    }).then(null, failure => console.debug(failure));
}
开发者ID:heruan,项目名称:aurelia-security,代码行数:13,代码来源:index.ts

示例10: 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


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