ioc-container

Whats the status of Prism integration in Autofac?

北战南征 提交于 2019-12-10 18:47:22
问题 Integration into Prism was talked about in the 2.1.x time frame, we are @ 2.4.x, Prism 4 is out now and the RIStockTrader Example in /contrib is just a default XAML project. Should it work? If so, anyone have a simple example of a Silverlight Shell + Bootstrapper + 1 Module they could point me to? 回答1: An updated Prism integration is currently in progress. I'm not sure what the status is exactly, but you can get the code and potentially contact the author here. You can also pass on feedback

Microsoft Unity - code to xml

白昼怎懂夜的黑 提交于 2019-12-10 18:44:42
问题 Can someone provide the XML configuration I should use with Microsoft Unity application block in the Enterprise Library 4.1 to achieve the same result as the following? using System; using Microsoft.Practices.Unity; using Microsoft.Practices.Unity.InterceptionExtension; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { IUnityContainer container = new UnityContainer(); container.AddNewExtension<Interception>(); container.RegisterType<ILogger, Logger>();

Castle windsor lifestyle issue

纵饮孤独 提交于 2019-12-10 18:21:17
问题 I am implementing hangFire which is a job scheduling library in my project. I am facing the same issue as faced in this link However after replacing LifestylePerWebRequest() with HybridPerWebRequestTransient() I am still getting the same error message: HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net Here's a couple of the lines of my dependency installer: container.Register(Component.For<IApiHra>() .ImplementedBy(typeof(ApiHra)) .LifeStyle

Define filter for DecorateAllWith() method in structure-map 3

纵然是瞬间 提交于 2019-12-10 17:36:12
问题 I used following statement to decorate all my ICommandHandlers<> with Decorator1<> : ObjectFactory.Configure(x => { x.For(typeof(ICommandHandler<>)).DecorateAllWith(typeof(Decorator1<>)); }); But because Decorator1<> implements ICommandHandlers<> , the Decorator1<> class decorates itself too. So, the problem is that the Decorator1 registers inadvertently, when I register all the ICommandHandler<> 's. How can I filter DecorateWithAll() to decorate all ICommandHandler<> , except Decorator1<> ?

Multiple constructor with Structuremap changing the scope?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 16:53:01
问题 To illustrate the problem, here is a simplified version of my setup. I have a factory like this one : public interface IFactory{ } public class Factory : IFactory { public Factory() { Console.WriteLine("parameterless"); } //public Factory(int i) //{ // Console.WriteLine("with parameter : {0}", i); //} } the program to test this is a consoleApp. Enough to prove my point. static void Main(string[] args) { Init(); var factory1 = ObjectFactory.GetInstance<IFactory>(); var factory2 = ObjectFactory

MEF Property Export with PartCreationPolicy

百般思念 提交于 2019-12-10 16:18:00
问题 When I try to do this: [Export(typeof(IMyService))] [PartCreationPolicy(CreationPolicy.Shared)] private MyService Service { get { var service = new MyService(); service.Configure(); return service; } } I get a compile error: Attribute 'PartCreationPolicy' is not valid on this declaration type. It is only valid on 'class' declarations. Is this a bug? I don't see why MEF would allow property exports but not allow one to specify the part lifetime. Using VS2010 RC. 回答1: The PartCreationPolicy

Method-level attributed interception with Autofac

二次信任 提交于 2019-12-10 15:33:56
问题 (this is a related question to this one which is for SimpleInjector. I was recommended to create separate questions for each IoC container.) With Unity, I'm able to quickly add an attribute based interception like this public sealed class MyCacheAttribute : HandlerAttribute, ICallHandler { public override ICallHandler CreateHandler(IUnityContainer container) { return this; } public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { // grab from cache if I have it,

Abstract Factory and Inversion of Control resolve at runtime

早过忘川 提交于 2019-12-10 15:32:54
问题 I have the following class and interface structure and I'm having a hard time trying to get the code to do what I need. public interface IUserManager { int Add(User user); } public class UserManagerA : IUserManager{} public class UserManagerB : IUserManager{} In this example I'm using Ninject as the IoC container but I'm open to changing it if some other container resolves the issue: This is inside my NinjectWebCommon.cs : void RegisterServices(IKernel kernel) { string userRole = CurrentUser

What is the equivalent of Container.GetAllInstances<T> in NInject?

拜拜、爱过 提交于 2019-12-10 14:53:54
问题 I'm building a message broker with NInject, and I need to find all instances in the container that implement Consumes, an interface that marks the class as being able to consume a particular message type. Is this scenario supported? 回答1: Answer from Nate: Multi-resolution (via GetAll ) is currently not polymorphic. That means that it will only consider bindings from the exact interface you specify. If you do this: kernel.Bind<IWorker>().To<WorkerA>(); kernel.Bind<IWorker>().To<WorkerB>();

How to keep IoC container in one place, while inner classes need to create dependencies after beeing constructed

耗尽温柔 提交于 2019-12-10 14:44:06
问题 I started to use Ninject , on this relatively small project and i have run into a problem: i have this class class SomeService : ISomeService that depends on class BizLogicModule : IBizLogicModule that in turn depends on class DataRepository : IDataRepository the DataRepository has a ctor that looks like: DataRepository(BizEntityModel context) Now, i need to be able to use a single instance of BizEntityModel across more than one IDataRepository instance. I also need to create IDataRepository