コード例 #1
0
        void IComponentInstaller.Install(IIoCContainer container, Assembly[] assemblies)
        {
            foreach (var type in _typedServices)
                container.For(type).RegisterAsSingleton();

            container.For<IQueryProcessorFactory>().AsPlugin().RegisterAsTransient();
        }
コード例 #2
0
 public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType, RegisteredParameters parameters)
     : this()
 {
     _iocContainerParent = iocContainerParent;
     _componentType = componentType;
     _constructorParameters = parameters;
 }
コード例 #3
0
 public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType, object componentInstance)
     : this()
 {
     _iocContainerParent = iocContainerParent;
     _componentType = componentType;
     _componentInstance = componentInstance;
 }
コード例 #4
0
 private void ValidateContainer(IIoCContainer container)
 {
     if (_settings.Debug) {
         lock (_featureSetContainer) {
             // Only validate the request container once.
             // But throw every time if it fails.
             if (_requestContainerIsChecked) {
                 if (!_requestContainerIsValid) {
                     throw new InvalidOperationException(
                         "The container configuration for requests for this feature set is invalid. "
                         + "Please refer to previous errors."
                     );
                 }
             }
             else {
                 try {
                     container.Validate();
                     _requestContainerIsValid = true;
                 }
                 finally {
                     _requestContainerIsChecked = true;
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: IoCConfig.cs プロジェクト: jerryshi2007/AK47Source
 public void Configure(IIoCContainer container)
 {
     if (_configureAction != null)
     {
         _configureAction(container);
     }
 }
コード例 #6
0
ファイル: BgTask.cs プロジェクト: hoffmannj/hrsystem
 public BgTask(IIoCContainer container)
 {
     _container = container;
     _dataLayer = _container.Resolve<IDataLayer>();
     _parameters = _container.Resolve<IApplicationParameters>();
     _tokenSource = new CancellationTokenSource();
     _token = _tokenSource.Token;
 }
コード例 #7
0
        public void CreateRouteTable()
        {
            var mock = new Mock<IIoCContainer>();
            mock.Setup(x => x.Get(It.IsAny<Type>())).Returns(new RootController());
            mock.Setup(x => x.GetChildContainer()).Returns<IIoCContainer>(x => x);
            _mockContainer = mock.Object;

            var mockSettings = new Mock<ISettings>();
            mockSettings.Setup(x => x.Debug).Returns(false);
            _mockSettings = mockSettings.Object;

            _mockNegotiator = new Mock<IArbitrator>(MockBehavior.Loose).Object;
        }
コード例 #8
0
 public RequestContext(IRequest request, IResponse response,
     ISessionStore sessionStore, IAuthenticator authenticator,
     IIoCContainer container, IFeatureSet features,
     Interceptors interceptors = null)
 {
     Request = request;
     Response = response;
     _sessionStore = sessionStore;
     _authenticator = authenticator;
     _container = new ContainerWrapper(container);
     Features = features;
     _interceptors = interceptors ?? new Interceptors();
 }
コード例 #9
0
    public override void Configure(IIoCContainer container)
    {
        // non  singleton
        container.Register<IColorItem, ColorItem>();

        // singletons

        // multiple  implementations
        container.RegisterSingleton<IColorFactory, RedColorFactory>("red");
        container.RegisterSingleton<IColorFactory, GreenColorFactory>("green");
        container.RegisterSingleton<IColorFactory, BlueColorFactory>("blue");

        // monobehaviour
        container.RegisterSingleton<IColorHistory, ColorHistory>();
    }
コード例 #10
0
 public RequestProcessor(
     IEnumerable<IInterceptor> interceptors,
     ISessionStore sessionStore,
     IAuthenticator authenticator,
     FeatureSet features,
     IIoCContainer featureSetContainer,
     ISettings settings,
     IArbitrator negotiator
 )
 {
     _interceptors = new Interceptors(interceptors);
     _sessionStore = sessionStore;
     _authenticator = authenticator;
     _features = features;
     _featureSetContainer = featureSetContainer;
     _settings = settings;
     _negotiator = negotiator;
 }
コード例 #11
0
 public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType)
     : this()
 {
     _iocContainerParent = iocContainerParent;
     _componentType = componentType;
 }
コード例 #12
0
ファイル: EmailSender.cs プロジェクト: hoffmannj/hrsystem
 public EmailSender(IIoCContainer container)
 {
     _container = container;
     _parameters = _container.Resolve<IApplicationParameters>();
 }
コード例 #13
0
 public OutgoingLinesViewModelFactory(IIoCContainer container, IResistorViewModelFactory resistorViewModelFactory)
 {
     _container = container;
     _resistorViewModelFactory = resistorViewModelFactory;
 }
コード例 #14
0
 public RawBytesToDeviceStateParserFactory(IIoCContainer container)
 {
     _container = container;
 }
コード例 #15
0
 public void Install(IIoCContainer container, Assembly[] assemblies)
 {
     foreach (Type service in _serviceTypes)
         container.For(service).RegisterAsTransient();
 }
コード例 #16
0
 private static void Register <TBase, TImplementation>(this IIoCContainer container,
                                                       IoCLifecycle lifecycle)
     where TBase : class
     where TImplementation : class, TBase
 => container.Register(lifecycle, typeof(TBase), typeof(TImplementation));
コード例 #17
0
 private void BuildRequestContext(IIoCContainer childContainer, IRequestContext context)
 {
     foreach (var feature in _features.Features) {
         feature.ContainerBuilder.SetupRequest(childContainer);
     }
 }
コード例 #18
0
 public ConsoleLogger(IIoCContainer container)
 {
     container.RegisterInstance <ILogger>(this);
 }
コード例 #19
0
 private static void Register <TBase>(this IIoCContainer container,
                                      IoCLifecycle lifecycle,
                                      Func <TBase> factory)
     where TBase : class
 => container.Register(lifecycle, typeof(TBase), factory);
コード例 #20
0
 public static void RegisterTransient <TBase, TImplementation>(this IIoCContainer container)
     where TBase : class
     where TImplementation : class, TBase
 => container.Register(IoCLifecycle.Transient, typeof(TBase), typeof(TImplementation));
コード例 #21
0
 public abstract void Configure(IIoCContainer container);
コード例 #22
0
 public static void RegisterTransient <TBase>(this IIoCContainer container,
                                              Func <TBase> factory)
     where TBase : class
 => container.Register(IoCLifecycle.Transient, typeof(TBase), factory);
コード例 #23
0
 public abstract void Configure(IIoCContainer container);
コード例 #24
0
 public static void SetIocAndActivator(IIoCContainer ioC, ILaboActivator laboActivator)
 {
     ioc       = ioC;
     activator = laboActivator;
 }
コード例 #25
0
        // TODO: this is only used in one of the tests. Need to either refactor the test
        // or else use [InternalsVisibleTo]. We shouldn't be exposing RequestContext
        // in the public API, only IRequestContext.

        public RequestContext CreateContext(IRequest request, IResponse response, IIoCContainer requestContainer)
        {
            return new RequestContext(request, response, _sessionStore, _authenticator,
                requestContainer, _features, _interceptors);
        }
コード例 #26
0
 /// <summary>
 /// Initializes the specified container.
 /// </summary>
 /// <param name="container">The container.</param>
 public static void Initialize(IIoCContainer container)
 {
     Current = container;
 }