ioc-container

Can IoC and the Managed AddIn Framework (System.AddIn) work together with isolated AppDomains?

守給你的承諾、 提交于 2019-12-04 12:13:09
If I use Managed AddIn Framework (System.AddIn) and set it up to use separate AppDomains, can I use a centralized IoC container that is in the primary/default AppDomain? Can the IoC container resolve across the AppDomains? I'm going to approach this answer by ignoring the MAF part of the equation, and concentrating on the AppDomain issue. An IoC container could theoretically do what you describe, assuming that the IoC entry point inherits from MarshalByRefObject or is wrapped by a class that in turn inherits from MarshalByRefObject. With a 29K+ rep score, I am sure you know this but: 1)

Injecting Dependencies into Domain Model classes with Nhibernate (ASP.NET MVC + IOC)

时光总嘲笑我的痴心妄想 提交于 2019-12-04 11:42:58
问题 I'm building an ASP.NET MVC application that uses a DDD (Domain Driven Design) approach with database access handled by NHibernate. I have domain model class (Administrator) that I want to inject a dependency into via an IOC Container such as Castle Windsor, something like this: public class Administrator { public virtual int Id { get; set; } //.. snip ..// public virtual string HashedPassword { get; protected set; } public void SetPassword(string plainTextPassword) { IHashingService hasher =

Delphi Spring DI: Is it possible to delegate interface instantiation without an implementing type?

岁酱吖の 提交于 2019-12-04 11:27:03
问题 I'm just getting started with the Delphi Spring Framework and was wondering whether the current version of the DI container somehow allows delegating the construction to a factory method without specifying an implementing type? E.g. something similar to this: GlobalContainer .RegisterFactory<ISomeObject>( function: ISomeObject begin Result := CreateComObject(CLASS_SomeObject) as ISomeObject; end) .Implements<ISomeObject> // could probably be implied from the above .AsSingletonPerThread; As

DI: Handling Life of IDisposable Objects

风流意气都作罢 提交于 2019-12-04 11:18:58
问题 So I'm working on my DI/IoC Container OpenNETCF.IoC and I've got a (reasonable) feature request to add some form of lifecycle management for IDisposable items in the container collections. My current thinking is that, since I can't query an object to see if it's been disposed, and I can't get an event for when it's been disposed, that I have to create some form of wrapper for objects that a developer wants the framework to manage. Right now objects can be added with AddNew (for simplicity

How to reset all instances in IOC Container

时光毁灭记忆、已成空白 提交于 2019-12-04 09:52:51
I have made an C# WPF Application using the MVVM Light framework . My Application uses the ViewModelLocator class to locate the viewmodels during runtime. The ViewModelLocator makes usage of the SimpleIoc class which also comes with the MVVM Light framework . Here is my scenario: The user logs in an can use my application. On logout, i want to dispose/reset/recreate all viewmodel instances to provide a clean environment to the next user. I tried to implement the Cleanup() method in the ViewModelLocator class but it is not working. Not working means that the (second) user sees the data from the

Castle Windsor: UsingFactoryMethod can't instantiate with a weird error

久未见 提交于 2019-12-04 09:48:18
When I use this registration: container.Register( Component .For<IFooFactory>() .ImplementedBy<FooFactory>(), Component .For<IFoo>() .UsingFactoryMethod(kernel => kernel.Resolve<IFooFactory>().CreateFoo()) ); I get this exception: Castle.MicroKernel.ComponentRegistrationException: Type MyNamespace.IFoo is abstract. As such, it is not possible to instansiate it as implementation of MyNamespace.IFoo service I'm not really sure what the problem is. But the stack trace shows that in 'DefaultComponentActivator.CreateInstance()', the following condition succeeds and then the error is thrown: if

Using Prism with Ninject

江枫思渺然 提交于 2019-12-04 09:28:11
问题 Is anyone out there using the Prism framework with Ninject instead of Unity? I need some functionality Unity isn't supporting yet, and I've decided to switch the IoC container to Ninject. I'm struggling a bit with the replace though.. What I need to use from Prism is the EventAggregator and the RegionManager. I have seen this sample that actually does the replace, but this is written for an older version of Prism, and several of the classes seems to have changed etc. So I ended up all

Is it ok to register components in Windsor without specifying an interface?

会有一股神秘感。 提交于 2019-12-04 09:06:51
问题 Is it considered bad form to register components in Windsor without specifying an interface? i.e. container.Register(Component.For<MyClass>().LifeStyle.Transient); as opposed to... container.Register(Component.For<IMyClass>().ImplementedBy<MyClass>().LifeStyle.Transient); I understand the benefits of coding to an interface rather than a concrete implementation however we are finding that we now have lots of interfaces many of them are on classes that realistically will only ever have one

Property Injection in Base Controller using Ninject 2

假装没事ソ 提交于 2019-12-04 08:52:38
I have the following code in my Global.aspx protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); } protected override IKernel CreateKernel() { return new StandardKernel(new ServiceModule()); } I also have the following Ninject Module: internal class ServiceModule : NinjectModule { public override void Load() { Bind<IProductService>().To<ProductService>().InRequestScope(); } } I also have a base controller: public class BaseController : Controller { [Inject] public

IoC Containers and Domain Driven Design

大憨熊 提交于 2019-12-04 08:24:19
问题 I've been searching for guidance for using IoC containers in domain driven design. Evan's book unfortunately doesn't touch on the subject. The only substantial guidelines I could find on the internet is here. Many of Malovic's points are common sense but I'm concerned about a few of them. He suggests that IoC container's should be reserved for resolving services only and that using an IoC container to resolve domain dependencies is a bad idea. However, he doesn't back up this assertion with