How to use Property Injection with AutoFac?

In my opinion the solution Ninject created is much nicer than the propertyinjection in Autofac. Therefore I created a a custom attribute which is a postsharp aspect which automatically injects my classes: [AutofacResolve] public IStorageManager StorageManager { get; set; } My aspect: [Serializable] [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class AutofacResolveAttribute : LocationInterceptionAspect { public override … Read more

Asp.Net MVC3: Set custom IServiceProvider in ValidationContext so validators can resolve services

On MVC 5.2, you can leveragesteal @Andras’s answer and the MVC source and: 1. Derive a DataAnnotationsModelValidatorEx from DataAnnotationsModelValidator namespace System.Web.Mvc { // From https://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Mvc/DataAnnotationsModelValidator.cs // commit 5fa60ca38b58, Apr 02, 2015 // Only diff is adding of secton guarded by THERE_IS_A_BETTER_EXTENSION_POINT public class DataAnnotationsModelValidatorEx : DataAnnotationsModelValidator { readonly bool _shouldHotwireValidationContextServiceProviderToDependencyResolver; public DataAnnotationsModelValidatorEx( ModelMetadata metadata, ControllerContext … Read more

Why is IoC / DI not common in Python?

I don’t actually think that DI/IoC are that uncommon in Python. What is uncommon, however, are DI/IoC frameworks/containers. Think about it: what does a DI container do? It allows you to wire together independent components into a complete application … … at runtime. We have names for “wiring together” and “at runtime”: scripting dynamic So, … Read more

Using Simple Injector with Unit Of Work & Repository Pattern in Windows Form

The problem you have is the difference in lifestyles between your service, repository, unitofwork and dbcontext. Because the MemberRepository has a Singleton lifestyle, Simple Injector will create one instance which will be reused for the duration of the application, which could be days, even weeks or months with a WinForms application. The direct consequence from … Read more

Which Dependency Injection Tool Should I Use? [closed]

Having recently spiked the use of 6 of these (Windsor, Unity, Spring.Net, Autofac, Ninject, StructureMap) I can offer a quick summary of each, our selection criteria and our final choice. Note: we did not look at PicoContainer.Net as one of our team considered the .Net port to be quite poor from the Java version. We … Read more