void IComponentInstaller.Install(IIoCContainer container, Assembly[] assemblies) { foreach (var type in _typedServices) container.For(type).RegisterAsSingleton(); container.For<IQueryProcessorFactory>().AsPlugin().RegisterAsTransient(); }
public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType, RegisteredParameters parameters) : this() { _iocContainerParent = iocContainerParent; _componentType = componentType; _constructorParameters = parameters; }
public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType, object componentInstance) : this() { _iocContainerParent = iocContainerParent; _componentType = componentType; _componentInstance = componentInstance; }
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; } } } } }
public void Configure(IIoCContainer container) { if (_configureAction != null) { _configureAction(container); } }
public BgTask(IIoCContainer container) { _container = container; _dataLayer = _container.Resolve<IDataLayer>(); _parameters = _container.Resolve<IApplicationParameters>(); _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; }
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; }
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(); }
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>(); }
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; }
public RegisteredComponent(IIoCContainer iocContainerParent, Type componentType) : this() { _iocContainerParent = iocContainerParent; _componentType = componentType; }
public EmailSender(IIoCContainer container) { _container = container; _parameters = _container.Resolve<IApplicationParameters>(); }
public OutgoingLinesViewModelFactory(IIoCContainer container, IResistorViewModelFactory resistorViewModelFactory) { _container = container; _resistorViewModelFactory = resistorViewModelFactory; }
public RawBytesToDeviceStateParserFactory(IIoCContainer container) { _container = container; }
public void Install(IIoCContainer container, Assembly[] assemblies) { foreach (Type service in _serviceTypes) container.For(service).RegisterAsTransient(); }
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));
private void BuildRequestContext(IIoCContainer childContainer, IRequestContext context) { foreach (var feature in _features.Features) { feature.ContainerBuilder.SetupRequest(childContainer); } }
public ConsoleLogger(IIoCContainer container) { container.RegisterInstance <ILogger>(this); }
private static void Register <TBase>(this IIoCContainer container, IoCLifecycle lifecycle, Func <TBase> factory) where TBase : class => container.Register(lifecycle, typeof(TBase), factory);
public static void RegisterTransient <TBase, TImplementation>(this IIoCContainer container) where TBase : class where TImplementation : class, TBase => container.Register(IoCLifecycle.Transient, typeof(TBase), typeof(TImplementation));
public abstract void Configure(IIoCContainer container);
public static void RegisterTransient <TBase>(this IIoCContainer container, Func <TBase> factory) where TBase : class => container.Register(IoCLifecycle.Transient, typeof(TBase), factory);
public static void SetIocAndActivator(IIoCContainer ioC, ILaboActivator laboActivator) { ioc = ioC; activator = laboActivator; }
// 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); }
/// <summary> /// Initializes the specified container. /// </summary> /// <param name="container">The container.</param> public static void Initialize(IIoCContainer container) { Current = container; }