inversion-of-control

Is this a good Spring Architecture (include testing)

為{幸葍}努か 提交于 2019-12-11 10:13:59
问题 I'm currently working on a Spring project. I made a diagram to illustrate what i'm saying. Is the diagram UML below represent a correct/good architecture to follow with Spring ? To explain, the RestController redirects requests. This controller have an interface dependancy injected with the real class (here a class that handle storage of reports with files). The class DatabaseFile implements DatabaseInterface. On one hand, some methods for content treatment ( like getContentFromReport(string)

MEF, can I export/import classes with multiple MetaDataAttribute decorations?

房东的猫 提交于 2019-12-11 09:08:31
问题 How can I make the following code work? It throws an error saying that there are two meta data attributes of identical names, though I do not see why. The error message is as follows: An unhandled exception of type 'System.InvalidOperationException' occurred in System.ComponentModel.Composition.dll Additional information: Member or Type 'ConsoleApplication2.DoSomeMagic' contains multiple metadata entries with the name 'PluginName'. The metadata entries could be coming from the

Spring - autowired fields are null

给你一囗甜甜゛ 提交于 2019-12-11 09:06:10
问题 I faced a problem with Spring Framework: @Autowired are null, but Spring doesn't throw any exceptions, and I can't understand, why are these fields null. I have a class: package com.processing.gates; public class Main { private final ApplicationContext context = Context.getContext(); @Autowired private PaymentGateFactory paymentGateFactory; @Autowired private CalculatorChooser calculatorChooser; //... } And for example I have the following class: package com.processing.gates.comission;

How to resolve an user repository using Windsor IoC at the start of the application?

无人久伴 提交于 2019-12-11 08:49:30
问题 I get an error message "Object reference not set to an instance of an object." when I try to use an UserRepos repository. Question is how can I resolve user repository at the start of the application (ASP.NET MVC) What is wrong here? public class MyApplication : HttpApplication { public IUserRepository UserRepos; public IWindsorContainer Container; protected void Application_Start() { Container = new WindsorContainer(); // Application services Container.Register( Component.For<IUserRepository

ASP.NET MVC and IoC - Chaining Injection

自作多情 提交于 2019-12-11 08:26:16
问题 Please be gentle, I'm a newb to this IoC/MVC thing but I am trying. I understand the value of DI for testing purposes and how IoC resolves dependencies at run-time and have been through several examples that make sense for your standard CRUD operations... I'm starting a new project and cannot come up with a clean way to accomplish user permissions. My website is mostly secured with any pages with functionality (except signup, FAQ, about us, etc) behind a login. I have a custom identity that

IoC spring.net injecting System.Type

断了今生、忘了曾经 提交于 2019-12-11 07:36:47
问题 I am trying to initiate a class that is expecting a System.Type in it's CTOR. Is there a way in spring.net config file to accomplish this, and preferable pass the type of a spring initialised object? Thanks, Lihnid 回答1: I think that this should do it: <constructor-arg name="argumentname" expression="T(namespace.to.my.type, assemblyname)" /> 回答2: This also works: <constructor-arg name="argumentname" value="MyNamespace.MyType, MyAssembly"/> Use VS2010 Add-In for intellisense: http://www

Ninject.Web (webforms extension), injecting outside of a webform page?

梦想的初衷 提交于 2019-12-11 07:33:15
问题 I've been using the Ninject.Web extension to inject business objects, repositories, Entity Framework context etc into my application. This works very well using the [Inject] attribute which can be applied within a webform that inherits from PageBase. I am now running into a snag as I am trying to write a custom membership provider that needs injection done inside of it but of course this provider is not instantiated from within a webform. Forms Authentication will instantiate the object when

Using IoC container as a service locator for HttpHandler

落爺英雄遲暮 提交于 2019-12-11 07:28:45
问题 This question relates to my other post. Ok so after a bit more messing around I decided to do it this way. Which seems to work fine when I run it, although I'm getting the following error in NUnit: Could not load file or assembly 'Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) So not sure what is happening there???

Unable to log messages using IActivityLogger and the Bot Builder for C#

混江龙づ霸主 提交于 2019-12-11 07:18:02
问题 I need to log the messages between my users and my bot. After some research I found this post by sGambolati explaining how this can be achieved: https://stackoverflow.com/a/42145416. However this approach doesn't seems to be working for me. I even tried the same snippets he provided and I still don't see the log in the debug output window. Here's the code according to his implementation: The logger class: public class DebugActivityLogger : IActivityLogger { public async Task LogAsync

Android IOC Dagger Framework - How to inject a nested field ?

为君一笑 提交于 2019-12-11 07:13:23
问题 I'm using Dagger for Android for dependency injections. I have a UserService object in a Main Class: public class Main implements Runnable { @Inject UserService service; @Override public void run() { for (User f : service.getUserByName("toto")) { System.out.print(f.getM_Nom()); } } public static void main(String[] args) { ObjectGraph objectGraph = ObjectGraph.create(new UserModule()); Main m = objectGraph.get(Main.class); m.run(); } } I managed to inject the "service" field and to call the