inversion-of-control

Castle Windsor IoC property injection. Using property from BaseClass inside ChildClass constructor

妖精的绣舞 提交于 2019-12-13 04:39:40
问题 I have a base class as following public class BaseClass { public ISomeObject Property { get; set; } } and ChildClass inherited from BaseClass.I need to use Property from BaseClass inside ChildClass constructor, but it's not initialized by IoC as I want and has value null. And if I use it inside ChildClass's methods, Property is initialized. What am I doing wrong? Here is how I register ISomeObject in IoC container container.Register( Component.For<ISomeObject>() .ImplementedBy<WebSomeObject>(

Ioc/DI - Why do I have to reference all layers/assemblies in application's entry point?

折月煮酒 提交于 2019-12-13 04:17:23
问题 (Related to this question, EF4: Why does proxy creation have to be enabled when lazy loading is enabled?). I'm new to DI, so bear with me. I understand that the container is in charge of instantiating all of my registered types but in order to do so it requires a reference to all of the DLLs in my solution and their references. If I weren't using a DI container, I wouldn't have to reference the EntityFramework library in my MVC3 app, only my business layer, which would reference my DAL/Repo

Autofac pick nested implementation based on parent dependency

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:13:45
问题 Given the example dependency tree below I would like to select the bottom level Config instance based on the top level dependency being resolved from the container e.g. TopLevelMessageConsumer would resolve the same IMessageService & IMessageQueue implementations as TopLevelMessageDispatcher but each would have their own Config instance. - TopLevelMessageConsumer - IMessageService - IMessageQueue - Config - TopLevelMessageDispatcher - IMessageService - IMessageQueue - Config I know this is

Connecting gwt-dispatch with guice and mvp4g

与世无争的帅哥 提交于 2019-12-13 04:09:23
问题 I have some questions regarding gwt-dispatch and guice. I'm using Guice 2.0, gwt-dispatch 1.1.0 snapshot, mvp4g 1.1.0 and GIN 1.0 First of all, I have defined simple action, result and handler: ListContactsAction.java public class ListContactsAction implements Action<ListContactsResult>{ public ListContactsAction() { } } ListContactsResult.java public class ListContactsResult implements Result { private List<Contact> contactList; public ListContactsResult() { } public ListContactsResult(List

How can I configure a Factory with the possible providers?

断了今生、忘了曾经 提交于 2019-12-13 03:23:54
问题 I have three assemblies: "Framework.DataAccess", "Framework.DataAccess.NHibernateProvider" and "Company.DataAccess". Inside the assembly "Framework.DataAccess", I have my factory (with the wrong implementation of discovery): public class DaoFactory { private static readonly object locker = new object(); private static IWindsorContainer _daoContainer; protected static IWindsorContainer DaoContainer { get { if (_daoContainer == null) { lock (locker) { if (_daoContainer != null) return

The best way to implement lives and score count in Sprite Kit (static, IoC, other?)

可紊 提交于 2019-12-13 03:16:37
问题 I have background in Java but havn't been coding in years. Lately I've taken interest to warm my coding skills again and have chosen to create learning apps for my kids in Swift. I've created basic Swift game utilizing the Sprite Kit with gameviewcontroller and multiple scenes. However I run into a basic question which is related to passing basic data such as points and lives counts from scenes to gameviewcontroller. Back in the day, I would have done it by creating a static member that would

In Laravel, how can I add items to array in controller and then process after response via App::finish()

与世无争的帅哥 提交于 2019-12-13 03:04:13
问题 I am creating an analytics storage process (using elastic search) where I need to add the items to be stored in elastic from my controller. But then I want to wait until after the response has been sent to the user to actually do the processing. I don't want the user to have to wait for this process to complete before getting the server response. I am planning on running the processing part using: App::finish(function(){ // DO THE PROCESSING }) I know that this will run after the response has

How to pass parameter to a class whose dependencies are wired through IoC container?

无人久伴 提交于 2019-12-13 02:38:28
问题 I have a class that works with a network via multiple resources. Its constructor receives arguments that are resolved at runtime by IoC container (StructureMap): public NetworkWorker(IRetryService retryService, ILog log) { ... } What I need is to control the number of resources this class uses on a use-case level - for example, client A need NetworkWorker instance that allows only one operation at a time, while client B need 10 ops at a time. Currently this number is hardcoded in the

How to dynamically bind a dynamically imported type

萝らか妹 提交于 2019-12-13 02:19:15
问题 I am trying to have templates automagically wired to an inversifyjs container but whatever I try it's not working. Please help? private templates = [ {file: './component.html.tpl', obj: 'HtmlTemplate'}, {file: './component.tpl.ts', obj: 'ComponentTemplate'} ]; private container = new Container(); bind(){ // original and working code // this.container.bind<ITemplate>('HtmlTemplate').to(HtmlTemplate); // this.container.bind<ITemplate>('ComponentTemplate').to(ComponentTemplate); this.templates

Null reference error in App.xaml MVVM light

丶灬走出姿态 提交于 2019-12-13 02:16:33
问题 I'll make a WPF application whit one window and by changing the content of the Frame I'll navigate troth my application. For this I'm using MVVM light. But on App.xaml I've got this error in the error list of Visual Studio. Object reference not set to an instance of an object. Here is the code where the error happens: <Application x:Class="Project.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr