castle-windsor

C# and IoC transitive dependencies removed

人盡茶涼 提交于 2020-01-04 04:34:19
问题 I have a solution in which I use IoC (windsor). The projects in the solution are as follows: Interfaces - Holds all the interface contracts I'll use. IoC.Installers - Holds all the installers for my dependencies (has reference to impl. and interfaces) IoC - Holds a singleton class that holds the IoC container. The class performs the initialization process of the container. Console - The project that uses the IoC to resolve dependencies (has reference to interfaces an IoC) The problem: Because

Sharing instance of class between other classes in Castle Windsor

怎甘沉沦 提交于 2020-01-03 19:45:31
问题 I'm trying to figure out the best way to share an instance of a class between two other classes that depend on it. Say I have these classes: class A { public A(B b, C c) {} } class B { public B(IDFactory factory) {} } class C { public C(IDFactory factory) {} } interface IDFactory { D GetD(); } class D {} And for each instance of A , I want the D used by c and d to be a single instance of D . When I create a new instance of A (say using a factory), I want c and d to share a new instance of D.

Sharing instance of class between other classes in Castle Windsor

ぃ、小莉子 提交于 2020-01-03 19:44:51
问题 I'm trying to figure out the best way to share an instance of a class between two other classes that depend on it. Say I have these classes: class A { public A(B b, C c) {} } class B { public B(IDFactory factory) {} } class C { public C(IDFactory factory) {} } interface IDFactory { D GetD(); } class D {} And for each instance of A , I want the D used by c and d to be a single instance of D . When I create a new instance of A (say using a factory), I want c and d to share a new instance of D.

Sharing instance of class between other classes in Castle Windsor

走远了吗. 提交于 2020-01-03 19:44:05
问题 I'm trying to figure out the best way to share an instance of a class between two other classes that depend on it. Say I have these classes: class A { public A(B b, C c) {} } class B { public B(IDFactory factory) {} } class C { public C(IDFactory factory) {} } interface IDFactory { D GetD(); } class D {} And for each instance of A , I want the D used by c and d to be a single instance of D . When I create a new instance of A (say using a factory), I want c and d to share a new instance of D.

CastleWindsor LifeStyle.PerWebRequest behaves like singleton

大憨熊 提交于 2020-01-03 17:04:27
问题 I am trying to create a UserService that I can inject in my classes, that will hold the user currently logged in to my system. I am using CastleWindsor as my container. Now my problem is that I am trying to make my UserService disposable, so that the databaseconnection fetching the user on creating will also be disposed when the object is destroyed. I added the following setup in my Global.asax.cs: private static void BootstrapContainer() { _container = new WindsorContainer().Install

Castle WCF facility Container Configuration

五迷三道 提交于 2020-01-03 05:33:17
问题 I'm having real trouble with the WCF Facility provided by Castle Windsor. I'm not finding appropriate documentation which could point me to some examples with the current version of WCF Facility. Following is my scenario: I want to write a WCF service, exposed over TCP which will be hosted by a Windows Service. I'm falling short of how to configure the WCF facility, where to configure it whether it should be in the WCF service or in the windows service host. Also how would I configure the WCF

Castle Windsor DI installer: dependency factory method has nested dependency on ApiController property

你说的曾经没有我的故事 提交于 2020-01-03 05:18:08
问题 I am trying to implement DI with Castle Windsor. Currently I have a controller with overloaded constructors like this (this is an antipattern as described here: https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=97): public class MyController : ApiController { protected IStorageService StorageService; protected MyController() { StorageService = StorageServiceFactory.CreateStorageService(User.Identity as ClaimsIdentity); } protected MyController(IStorageService storageService) {

Could not load assembly 'System.Runtime.Loader' during startup registration

两盒软妹~` 提交于 2020-01-03 02:22:12
问题 When you create new Xamarin.Forms project using .NET Standard, install Castle Windsor and run the project on Android it will fail with the following error D/Mono ( 5829): Assembly Loader probing location: 'System.Runtime.Loader'. F/monodroid-assembly( 5829): Could not load assembly 'System.Runtime.Loader' during startup registration. F/monodroid-assembly( 5829): This might be due to an invalid debug installation. F/monodroid-assembly( 5829): A common cause is to 'adb install' the app directly

How to use .net core dependency injection in multiprojects solution?

不打扰是莪最后的温柔 提交于 2020-01-02 15:14:49
问题 I'm new to asp.net core. What I'm trying to do is to build multi projects solution and use dependency injection to pass interfaces between projects. What I know is that in ASP.NET core project we have ConfigureServices method in startup.cs file to register our interfaces and their implementations like this: public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); services.AddTransient<IMyInterface,MyImplementation>(); ..... } This is good if

Intercept Properties With Castle Windsor IInterceptor

只愿长相守 提交于 2020-01-02 07:39:37
问题 Does anyone have a suggestion on a better way to intercept a properties with Castle DynamicProxy? Specifically, I need the PropertyInfo that I'm intercepting, but it's not directly on the IInvocation, so what I do is: public static PropertyInfo GetProperty(this MethodInfo method) { bool takesArg = method.GetParameters().Length == 1; bool hasReturn = method.ReturnType != typeof(void); if (takesArg == hasReturn) return null; if (takesArg) { return method.DeclaringType.GetProperties() .Where