inversion-of-control

Child containers in MvvmCross IoC

℡╲_俬逩灬. 提交于 2019-12-08 03:16:55
问题 I have a WPF MVVM application that I'd like to refactor to use MvvmCross to support a WPF and Mono for Android implementations. Currently we are using Unity 3.0 for dependency injection and rely on its support for container hierarchies (one main container w/ the main view and view model and services; and for each session with a server a child container with views, view models and services that have a limited lifetime). Can the IoC in MvvmCross support child containers? If not, how would you

Is it possible to use Dependency Injection/IoC on an ASP.NET MVC FilterAttribute?

别等时光非礼了梦想. 提交于 2019-12-08 02:43:35
问题 I've got a simple custom FilterAttribute which I use decorate various ActionMethods . eg. [AcceptVerbs(HttpVerbs.Get)] [MyCustomFilter] public ActionResult Bar(...) { ... } Now, I wish to add some logging to this CustomFilter Action .. so being a good boy, I'm using DI/IoC ... and as such wish to use this pattern for my custom FilterAttribute . So if i have the following... ILoggingService and wish to add this my custom FilterAttribute .. i'm not sure how. Like, it's easy for me to do the

Castle windsor and IHttpHandler and IHttpHandlerFactory

我的未来我决定 提交于 2019-12-08 02:03:52
问题 I'm developing a RIA application where there is javascript on the client (i'm using Ext) and .NET on the server, for json-rpc I'm using Jayrock which is a nice library (at least for me) as it is simple and works well, Ive used it in the past. Jayrock uses Web Handlers to serve the json-rpc request, you code a class that implements IHttpHandler and derives from a Jayrock class with some attributes, and it does the rest to provide a javascript class to the browser to do its magic. Now, normally

Change spring bean alias with System property

半城伤御伤魂 提交于 2019-12-08 00:21:27
问题 I try to figure out whether it's possible to change a spring alias configuration through a system property. That's the configuration: <beans> <bean id="beanOne" ... /> <bean id="beanTwo" ... /> <bean id="beanThree" ... /> <alias name="beanOne" alias="beanToUse" /> <bean id="consumer" ...> <constructor-arg ref="beanToUse" /> </bean> </beans> I'd like to be able to use a JVM property e.g. with -Duse=beanThree to select another bean for the alias. Unfortunately using the straight forward

NInject Extension Factory

我是研究僧i 提交于 2019-12-07 22:42:55
问题 After reading the new documentation on NInject v3 and how to use the Factory Extension , apparently I still don't get it fully since my code throws exceptions all over the place... I get this Exception, i could paste the whole thing if people would like that but i'll try and keep it short for now. Error activating IDeployEntityContainer No matching bindings are available, and the type is not self-bindable. Here is my code... The Ninject Bind Module class class MyNinjectModule : NinjectModule

Dependency Injection - What If Dependency Lifetimes Are Shorter Than The Dependent Object?

孤者浪人 提交于 2019-12-07 19:07:52
问题 I realise that DI is a very flexible design pattern, although I'm struggling to accept it as my 'silver bullet' for creating decoupled code. Here's why: What happens when the dependent object has a longer lifetime than the dependencies it has been injected with? Example application: I have a BusinessLogic class which is instantiated for the lifetime of my application. This class requires a DataContext object to perform database operations. I have thefore created an abstract DataContextFactory

Alternative to passing IOC container around

亡梦爱人 提交于 2019-12-07 17:33:55
问题 I had the following base class with several dependencies: public abstract class ViewModel { private readonly ILoggingService loggingService; public ViewModel( ILoggingService loggingService, ...) { this.loggingService = loggingService; ... } } In my derived class, I don't want to have to repeat all of the parameters in this base class constructor, so I did this: public abstract class ViewModel { private readonly IUnityContainer container; private ILoggingService loggingService; ... public

Configuring AutoMapper to fulfil ITypeConverter<,> constructor dependecies with Autofac

巧了我就是萌 提交于 2019-12-07 16:10:44
问题 My first time working with Autofac to inject AutoMapper's IMapper interface into classes that have an object mapping requirement. I have made some progress, with a little help, getting the various dependencies added to AutoMapper's register using Assembly Scanning: builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()) .AsClosedTypesOf(typeof(ITypeConverter<,>)) .AsImplementedInterfaces(); builder.RegisterAssemblyTypes(typeof(AutoMapperExtensions).Assembly) .AssignableTo

Prefetching data in with Linq-to-SQL, IOC and Repository pattern

大兔子大兔子 提交于 2019-12-07 15:28:31
问题 using Linq-to-SQL I'd like to prefetch some data. 1) the common solution is to deal with DataLoadOptions , but in my architecture it won't work because : the options have to be set before the first query I'm using IOC, so I don't directly instanciate the DataContext (I cannot execute code at instanciation) my DataContext is persistent for the duration of a web request 2) I have seen another possibility based on loading the data and its childs in a method, then returning only the data (so the

Injecting a specific instance of an interface using Autofac

為{幸葍}努か 提交于 2019-12-07 12:48:18
问题 I have a controller and it receives a specific instance of an interface. The interface looks something like this: public interface IMyInterface { ... implementation goes here } And then I have some classes that implement this interface like this: public class MyClassA : IMyInterface { ... implementation goes here } public class MyClassB : IMyInterface { ... implementation goes here } In my ControllerA I have the following constructor: private ICustomerService customerService; private