public void OnApplicationStart(IIocContainer container, object context) { if (container is IOC.IIocContainerForApi) { GlobalConfiguration.Configuration.DependencyResolver = ((IOC.IIocContainerForApi)container).GetDependencyResolver(); } }
public object ResolveDependency(Type type, IIocContainer context) { ConstructorInfo injectionConstructor = this.GetInjectionConstructor(type); object[] dependentObjects = this.ResolveParameters(injectionConstructor, context); //Invoke the constructor with the resolved objects and return the result object obj = injectionConstructor.Invoke(dependentObjects); PropertyInfo[] propertyList = type.GetProperties(); foreach (PropertyInfo prop in propertyList) { Attribute[] attributes = (Attribute[]) prop.GetCustomAttributes(typeof(IocDependencyAttribute), true); if (attributes.Length > 0) { IocDependencyAttribute dependencyAttribute = (IocDependencyAttribute)attributes[0]; object propValue = context.Resolve(prop.PropertyType, dependencyAttribute.Identifier); prop.SetValue(obj, propValue, null); } } MethodInfo[] methodList = type.GetMethods(); foreach (MethodInfo method in methodList) { Attribute[] attributes = (Attribute[]) method.GetCustomAttributes(typeof(IocDependencyAttribute), true); if (attributes.Length > 0) { object[] methodParameters = this.ResolveParameters(method, context); method.Invoke(obj, methodParameters); } } return obj; }
public static void Build() { if (builder != null) { container = builder.Build(); } }
public DynamoDependencyResolver(IIocContainer container) { if (container == null) throw new ArgumentNullException("container"); _container = container; }
public WorkspaceViewModel(IIocContainer iocContainer) : base(iocContainer) { DisplayName = "Workspace"; IsCloseable = true; closeCommand = new RelayCommand(p => Publish(new CloseWorkspaceMessage(this))); }
private void ConfigurePorts(IIocContainer container) { lock (this) RegisterTestFields(container); RegisterPerServerPorts(container); }
private object[] ResolveParameters(MethodBase methodBase, IIocContainer context) { //Gets a list of parameters to attempt to resolve those parameters //before calling the constructor with the resolved objects ParameterInfo[] methodParams = methodBase.GetParameters(); object[] dependentObjects = new object[methodParams.Length]; int paramIndexer = 0; for (paramIndexer = 0; paramIndexer <= methodParams.Length - 1; paramIndexer++) { ParameterInfo param = (ParameterInfo) methodParams.GetValue(paramIndexer); try { string identString = string.Empty; Attribute[] attrs = (Attribute[])param.GetCustomAttributes(typeof(IocDependencyAttribute), false); //Parameters can be specified with an IocDependencyAttribute if a specific string must be used if (attrs.Length > 0) { IocDependencyAttribute dependentAttr = (IocDependencyAttribute) attrs.GetValue(0); identString = dependentAttr.Identifier; } object paramValue = context.Resolve(param.ParameterType, identString); dependentObjects.SetValue(paramValue, paramIndexer); } catch (IocException) { throw new IocException("Could not resolve parameter type: " + param.ParameterType.UnderlyingSystemType.ToString()); } } return dependentObjects; }
public static void Configure(IIocContainer container) { Contract.Requires(container != null); container.RegisterInstance<IMessageTransporter, MessageTransporter>(); container.RegisterInstance<ITransportBuilder, HttpServerTransportBuilder>(); }
void IViewModel.InitializeViewModel(IDataContext context) { if (InitializeViewModel != null) InitializeViewModel(context); IocContainer = context.GetData(InitializationConstants.IocContainer); if (InitializeViewModelStatic != null) InitializeViewModelStatic(context); }
public static void Register(IIocContainer container) { container.RegisterInstance<RequestSender, RequestSender>(); container.RegisterInstance<RequestSenderBuilder, RequestSenderBuilder>(); container.RegisterInstance<RequestReceiverBuilder, RequestReceiverBuilder>(); container.RegisterInstance<ReplySenderBuilder, ReplySenderBuilder>(); container.RegisterInstance<ReplyReceiverBuilder, ReplyReceiverBuilder>(); }
public HomeViewModel(IIocContainer iocContainer) : base(iocContainer) { DisplayName = "Home"; IsCloseable = false; openSearchCustomersCommand = new RelayCommand(p => Publish(new OpenSearchCustomersWorkspaceMessage())); openAddCustomerCommand = new RelayCommand(p => Publish(new OpenAddCustomerWorkspaceMessage())); }
public static void Configure(IIocContainer container) { Contract.Requires(container != null); container.RegisterInstance<IMessageTransporter, MessageTransporter>(); container.RegisterInstance<LongPoller, LongPoller>(); container.RegisterInstance<ITransportBuilder, HttpRemoteClientTransportBuilder>(); }
/// <summary> /// 初始化 <see cref="Context"/> 类的新实例。 /// </summary> /// <param name="container">服务容器。</param> /// <param name="command">命令模型。</param> public Context(IIocContainer container, ICommand command) : base(container) { if(command == null) throw new ArgumentNullException(nameof(command)); this.Command = command; this._Data = new Lazy<HybridDictionary>(() => new HybridDictionary(true)); this._LazyEngine = new Lazy<IDbEngine>(() => this.GetDbEngine()); }
private static void LoadJsonFormatters(IIocContainer resolver, HttpConfiguration config) { var converters = resolver.GetAll<JsonConverter>(); foreach (var converter in converters) { config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(converter); } }
public static void Register(IIocContainer container) { container.RegisterInstance<ITaskStarter, TaskStarter>(); container.RegisterInstance<ITaskScheduler, TaskScheduler>(); container.RegisterInstance<ITaskRepeater, TaskRepeater>(); container.RegisterInstance<MainThreadDispatcher, MainThreadDispatcher>(); container.RegisterInstance<IMainThreadMarshaller, MainThreadMarshaller>(); }
/// <summary> /// 提供父级服务容器,初始化一个 <see cref="IocContainer"/> 类的新实例。 /// </summary> /// <param name="parentLocator">父级服务容器,</param> public IocContainer(IIocContainer parentLocator) : this() { if(parentLocator == null) return; this._parentLocator = parentLocator; this._hasParent = true; }
private static void LoadMediaFormatters(IIocContainer resolver, HttpConfiguration config) { var formatters = resolver.GetAll<MediaTypeFormatter>(); foreach (var mediaTypeFormatter in formatters) { config.Formatters.Add(mediaTypeFormatter); } }
private void LoadMessageHandlers(IIocContainer resolver, HttpConfiguration config) { var delegatingHandlers = resolver.GetAll<DelegatingHandler>(); foreach (var delegatingHandler in delegatingHandlers) { config.MessageHandlers.Add(delegatingHandler); } }
public static void RegisterDependencies(IIocContainer container) { // Register your dependencies here. //container.RegisterLambda(_ => _.Resolve<HomeController>()); container.Register<HomeController, HomeController>().WithRequestLifetime(); container.Register<IAuthorizationManager, AuthorizationManager>().WithRequestLifetime(); container.Register<IProfileConfiguration, ProfileConfiguration>().WithSessionLifetime(); container.Register<IUserManager, UserManager<IAuthorizationManager, IProfileConfiguration>>().WithRequestLifetime(); }
public static void Register(IIocContainer iocContainer) { iocContainer.RegisterInstance<IPublisherRegistry, PublisherRegistry>(); iocContainer.RegisterInstance<ISubscriberSendChannelBuilder, SubscriberSendChannelBuilder>(); iocContainer.RegisterInstance<SubscriptionRequestReceiveChannelBuilder, SubscriptionRequestReceiveChannelBuilder>(); iocContainer.RegisterInstance<PublisherChannelBuilder, PublisherChannelBuilder>(); iocContainer.RegisterInstance<SubscriberRecieveChannelBuilder, SubscriberRecieveChannelBuilder>(); iocContainer.RegisterInstance<SubscriptionRequestSendChannelBuilder, SubscriptionRequestSendChannelBuilder>(); }
public ModuleContext(PlatformInfo platform, LoadMode mode, IIocContainer iocContainer, IDataContext context, IList<Assembly> assemblies) { _platform = platform ?? PlatformInfo.Unknown; _mode = mode; _iocContainer = iocContainer; _context = context.ToNonReadOnly(); _assemblies = assemblies ?? Empty.Array<Assembly>(); }
private void ConfigureTestDependencies(IIocContainer container) { container.UseXunitLogging(output, !options.VerboseLogging); if (options.UseMockOutput) container.For<IMockLogger>().UseSingleton<MockLogger>(); else container.For<IMockLogger>().Use<NoMockLogging>(); }
public virtual void OnApplicationStart(IIocContainer container, object context) { MetadataProviderBase.CreateProvider = () => { MetadataProviderList list = new MetadataProviderList(); var metadataProvider = new DAF.Core.Data.BLToolkit.DataAnnotationMetadataProvider(); list.InsertProvider(0, metadataProvider); return list; }; }
public static void Register(IIocContainer container) { container.RegisterInstance<AuthenticationSessionCache, AuthenticationSessionCache>(); container.RegisterInstance<AuthenticationSenderBuilder, AuthenticationSenderBuilder>(); container.RegisterInstance<AuthenticationReceiverBuilder, AuthenticationReceiverBuilder>(); container.RegisterInstance<AuthenticatedServerRegistry, AuthenticatedServerRegistry>(); container.RegisterInstance<AuthenticationSessionExpirer, AuthenticationSessionExpirer>(); container.RegisterInstance<AuthenticationSessionFactory, AuthenticationSessionFactory>(); container.RegisterInstance<SenderAuthenticationSessionAttacherFactory, SenderAuthenticationSessionAttacherFactory>(); }
public InProcessTransportBuilder(MessageReceiver messageReceiver, IIocContainer container, IInProcessMessageServerFactory messageServerFactory) { Contract.Requires(messageReceiver != null); Contract.Requires(container != null); Contract.Requires(messageServerFactory != null); this.messageReceiver = messageReceiver; this.container = container; this.messageServerFactory = messageServerFactory; }
/// <summary> /// 初始化一个 <see cref="Context"/> 类的新实例。 /// </summary> /// <param name="container">服务容器。</param> /// <param name="command">命令模型。</param> /// <param name="lazyData">延迟模式的命令模型的其他参数。</param> /// <param name="lazyEngine">延迟模式的上下文中的 <see cref="IDbEngine"/> 实例。</param> public Context(IIocContainer container, ICommand command, Lazy<HybridDictionary> lazyData, Lazy<IDbEngine> lazyEngine) : base(container) { if(command == null) throw new ArgumentNullException(nameof(command)); if(lazyData == null) throw new ArgumentNullException(nameof(lazyData)); if(lazyEngine == null) throw new ArgumentNullException(nameof(lazyEngine)); this.Command = command; this._LazyData = lazyData; this._LazyEngine = lazyEngine; }
private HttpConfiguration ConfigureWebApi(IIocContainer resolver) { var config = new HttpConfiguration(); MapRoutes(config); ReplaceControllerActivatorWithIocControllerActivator(resolver, config); LoadMediaFormatters(resolver, config); LoadMessageHandlers(resolver, config); LoadJsonFormatters(resolver, config); return config; }
public static void Register(IIocContainer container) { container.RegisterInstance<RequestRecieveChannelDistributor, RequestRecieveChannelDistributor>(); container.RegisterInstance<RequestReceiveDistributionChannelBuilder, RequestReceiveDistributionChannelBuilder>(); container.RegisterInstance<ReplyReceiveChannelBuilder, ReplyReceiveChannelBuilder>(); container.RegisterInstance<RequestRecieveChannelBuilder, RequestRecieveChannelBuilder>(); container.RegisterInstance<ReplyAddressLookup, ReplyAddressLookup>(); container.RegisterInstance<ReplySendChannelDistributor, ReplySendChannelDistributor>(); container.RegisterInstance<ReplySendDistributionChannelBuilder, ReplySendDistributionChannelBuilder>(); container.RegisterInstance<RequestSendChannelBuilder, RequestSendChannelBuilder>(); container.RegisterInstance<ReplySendChannelBuilder, ReplySendChannelBuilder>(); container.RegisterInstance<ReplyAuthenticationSessionAttacherFactory, ReplyAuthenticationSessionAttacherFactory>(); }
/// <summary> /// Disposes of all managed and unmanaged resources that have been allocated. /// </summary> /// <param name="disposing"> /// Determines whether only unmanaged, or managed and unmanaged resources should be disposed of. This is needed when the method is called from the destructor, because when the destructor is called all managed resources have already been disposed of. /// </param> protected override void Dispose(bool disposing) { // Calls the base implementation base.Dispose(disposing); // Checks if managed resources should be disposed of if (disposing) { // Disposes of the IOC container if (this.iocContainer != null) this.iocContainer.Dispose(); this.iocContainer = null; } }
public static void RegisterDependencies(IIocContainer container) { // Register your dependencies here. container.Register<IBrowserConfigService, BrowserConfigService>().WithRequestLifetime(); container.Register<ICacheService, CacheService>().WithRequestLifetime(); container.Register<IFeedService, FeedService>().WithRequestLifetime(); container.Register<ILoggingService, LoggingService>().WithRequestLifetime(); container.Register<IManifestService, ManifestService>().WithRequestLifetime(); container.Register<IOpenSearchService, OpenSearchService>().WithRequestLifetime(); container.Register<IRobotsService, RobotsService>().WithRequestLifetime(); container.Register<ISitemapService, SitemapService>().WithRequestLifetime(); container.Register<ISitemapPingerService, SitemapPingerService>().WithRequestLifetime(); }
protected virtual void BindNavigationProvider(IModuleContext context, IIocContainer container) { }
protected virtual void BindSerializer(IModuleContext context, IIocContainer container) { var assemblies = context.Assemblies; container.BindToMethod <ISerializer>((iocContainer, list) => new Serializer(assemblies), DependencyLifecycle.SingleInstance); }
protected virtual void BindNavigationDispatcher(IModuleContext context, IIocContainer container) { container.Bind <INavigationDispatcher, NavigationDispatcher>(DependencyLifecycle.SingleInstance); }
protected virtual void BindOperationCallbackStateManager(IModuleContext context, IIocContainer container) { }
protected virtual void BindDisplayNameProvider(IModuleContext context, IIocContainer container) { container.Bind <IDisplayNameProvider, DisplayNameProvider>(DependencyLifecycle.SingleInstance); }
public void Build(IIocContainer ctx) { }
/// <summary> /// 初始化一个 <see cref="ContextFactory"/> 类的新实例。 /// </summary> /// <param name="container">服务容器。</param> public ContextFactory(IIocContainer container) : base(container) { }
public GetGoodsList(IGoodsRepository goodsRepository, IIocContainer iocContainer) : base(iocContainer) { this.goodsRepository = goodsRepository; }
public void Build(IIocContainer ctx) { Type = ctx.Resolve <Type>(); }
public static void EntryPoint(IIocContainer container) { TFDIncident.IncidentMain.Main(container); }
/// <summary> /// Initializes a new instance of the <see cref="Bootstrapper{TRootViewModel}" /> class. /// </summary> public Bootstrapper([NotNull] Application application, [NotNull] IIocContainer iocContainer, IEnumerable <Assembly> assemblies = null, IViewModelSettings viewModelSettings = null, params IModule[] modules) : base(application, true)
public override void Build(IIocContainer ctx) { base.Build(ctx); Recordset = ctx.Resolve <ADORecordSetHelper>(); Text = ""; }
/// <summary> /// Initializes a new instance of the <see cref="Bootstrapper{TRootViewModel}" /> class. /// </summary> public Bootstrapper([NotNull] Frame rootFrame, [NotNull] IIocContainer iocContainer, IEnumerable <Assembly> assemblies = null, IViewModelSettings viewModelSettings = null, params IModule[] modules) : base(rootFrame, assemblies != null)
protected internal InstrumentedPluginContext(IServiceProvider serviceProvider, IIocContainer container, IPluginExecutionContext executionContext, IComponentTelemetryClient telemetryClient) : base(executionContext, container, telemetryClient) { this.ServiceProvider = serviceProvider; }
/// <summary> /// Creates an instance of an object. /// </summary> /// <returns>Instance of a object.</returns> public virtual object Create(IIocContainer container) { var instance = CallConstructor(container); return(instance); }
/// <summary> /// 初始化一个 <see cref="RedisProvider"/> 类的新实例 /// </summary> /// <param name="container">服务容器。</param> public RedisProvider(IIocContainer container) : base(container) { }
protected virtual void BindViewModelPresenter(IModuleContext context, IIocContainer container) { container.Bind <IViewModelPresenter, ViewModelPresenter>(DependencyLifecycle.SingleInstance); }
public void Build(IIocContainer ctx) { Cells = ctx.Resolve <IList <DataGridViewCellViewModel> >(); }
protected virtual void BindAttachedValueProvider(IModuleContext context, IIocContainer container) { }
public void Build(IIocContainer ctx) { Items = Container.Resolve <IList <UltraGridColumn> >(); }
protected virtual void BindItemsSourceDecorator(IModuleContext context, IIocContainer container) { }
/// <summary> /// Builds the specified CTX. /// </summary> /// <param name="ctx">The CTX.</param> public override void Build(IIocContainer ctx) { base.Build(ctx); this.Visible = true; this.Enabled = true; }
protected virtual void BindOperationCallbackManager(IModuleContext context, IIocContainer container) { container.Bind <IOperationCallbackManager, OperationCallbackManager>(DependencyLifecycle.SingleInstance); }
public virtual void TestBindToMethodNamed() { const string named = "named"; var parameters = new IIocParameter[] { new IocParameter("test", "Test", IocParameterType.Property) }; using (IIocContainer iocContainer = GetIocContainer()) { iocContainer.BindToMethod <ISimple>((adapter, list) => { list.SequenceEqual(parameters).ShouldBeTrue(); return(new Simple()); }, DependencyLifecycle.SingleInstance, named); var simple = (ISimple)iocContainer.Get(typeof(ISimple), named, parameters); simple.ShouldNotBeNull(); iocContainer.Get <ISimple>(named, parameters).ShouldEqual(simple); iocContainer.Get(typeof(ISimple), named, parameters).ShouldEqual(simple); Action action = () => iocContainer.Get <ISimple>(); action.ShouldThrow(); } using (IIocContainer iocContainer = GetIocContainer()) { iocContainer.BindToMethod(typeof(ISimple), (adapter, list) => { list.SequenceEqual(parameters).ShouldBeTrue(); return(new Simple()); }, DependencyLifecycle.SingleInstance, named); var simple = (ISimple)iocContainer.Get(typeof(ISimple), named, parameters); simple.ShouldNotBeNull(); iocContainer.Get <ISimple>(named, parameters).ShouldEqual(simple); iocContainer.Get(typeof(ISimple), named, parameters).ShouldEqual(simple); Action action = () => iocContainer.Get <ISimple>(); action.ShouldThrow(); } using (IIocContainer iocContainer = GetIocContainer()) { iocContainer.BindToMethod <ISimple>((adapter, list) => { list.SequenceEqual(parameters).ShouldBeTrue(); return(new Simple()); }, DependencyLifecycle.TransientInstance, named); var simple = (ISimple)iocContainer.Get(typeof(ISimple), named, parameters); simple.ShouldNotBeNull(); iocContainer.Get <ISimple>(named, parameters).ShouldNotEqual(simple); iocContainer.Get(typeof(ISimple), named, parameters).ShouldNotEqual(simple); Action action = () => iocContainer.Get <ISimple>(); action.ShouldThrow(); } using (IIocContainer iocContainer = GetIocContainer()) { iocContainer.BindToMethod(typeof(ISimple), (adapter, list) => { list.SequenceEqual(parameters).ShouldBeTrue(); return(new Simple()); }, DependencyLifecycle.TransientInstance, named); var simple = (ISimple)iocContainer.Get(typeof(ISimple), named, parameters); simple.ShouldNotBeNull(); iocContainer.Get <ISimple>(named, parameters).ShouldNotEqual(simple); iocContainer.Get(typeof(ISimple), named, parameters).ShouldNotEqual(simple); Action action = () => iocContainer.Get <ISimple>(); action.ShouldThrow(); } }
/// <summary>Set the object container. /// </summary> /// <param name="container"></param> public static void SetContainer(IIocContainer container) { Current = container; }
public override void Build(IIocContainer ctx) { base.Build(ctx); this.DataMember = string.Empty; this.DataMember = null; }
protected virtual void BindTracer(IModuleContext context, IIocContainer container) { container.BindToConstant <ITracer>(Tracer.Instance); }
public object GetUser(IIocContainer container) { return(this.Get()); }
/// <summary> /// 初始化一个 <see cref="Aoite.CommandModel.CounterProvider"/> 类的新实例。 /// </summary> /// <param name="container">服务容器。</param> public CounterProvider(IIocContainer container) : base(container) { }
/// <summary> /// Initializes a new instance of the <see cref="Bootstrapper{TRootViewModel}" /> class. /// </summary> public Bootstrapper([NotNull] UIWindow window, [NotNull] IIocContainer iocContainer, IEnumerable <Assembly> assemblies = null, IViewModelSettings viewModelSettings = null, params IModule[] modules) : base(window)