castle-windsor

Castle Windsor IoC inject Property into Constructor

孤人 提交于 2019-12-24 01:19:41
问题 I have a session manager class that has a session property. I need to pass that into another class as a constructor parameter. How should I configure the installer for castle windsor? e.g. public interface ISessionManager { ISession CurrentSession { get; set; } } public class SessionManager : ISessionManager { private ISession _session; public ISession CurrentSession { get { return _session ?? (_session = NHibernateHelper.OpenSession()); } set { _session = value; } } } public interface

Nlog 3.1 with Castle Windsor not logging

喜欢而已 提交于 2019-12-24 00:35:36
问题 I'm trying to use NLog (3.1) with Windsor Castle Facility, but it's not working for me (no errors, nothing happens) These are my steps so far: Downloaded from Nuget: Castle Windsor NLog integration Downloaded from Nuget: NLog Configuration Updates nlog config like this: <target xsi:type="File" name="f" fileName="d:\nlog.log" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" /> <logger name="*" minlevel="Trace" writeTo="f" /> Added Windsor Installer public class

How to register separate instance of a class using Windsor Container

会有一股神秘感。 提交于 2019-12-23 20:16:38
问题 Not very familiar with Windsor Container, modifying code written by other person. We have code which initializes all objects in WindsorContainer which has PgDataAccess (own class) data type property public PgDataAccess da { get; set; } Code is the following: _windsorContainer.Register(Component.For<PgDataAccess>().UsingFactoryMethod(() => { var dataAccess = new PgDataAccess(); dataAccess.ConnectionString = connectionString; return dataAccess; })); According to some errors seems we had same

Can Castle.Windsor TypedFactoryFacility construct a type with only some ref arguments passed inline?

此生再无相见时 提交于 2019-12-23 20:07:14
问题 I have hit a problem in my use of Castle.Windsor's TypedFactoryFacility concept, and not sure how to resolve it (or if I can). I have a ViewModel defined like so; public class MyViewModel : IMyViewModel { // constructor which I aim to access through the factory public MyViewModel( ISomeContainerResolvableDependency a, ISomePassedInDependency b) { ... } } And a corresponding factory interface defined like; public interface IMyViewModelFactory { IMyViewModel Create(ISomePassedInDependency a);

Castle Windsor, Fluent Nhibernate, and Automapping Isession closed problem

好久不见. 提交于 2019-12-23 19:28:38
问题 I'm new to the whole castle Windsor, Nhibernate, Fluent and Automapping stack so excuse my ignorance here. I didn't want to post another question on this as it seems there are already a huge number of questions that try to get a solution the Windsor nhib Isession management problem, but none of them have solved my problem so far. I am still getting a ISession is closed exception when I'm trying to call to the Db from my Repositories,Here is my container setup code. container.AddFacility

How can I register all my services with castle windsor wcf facility

谁都会走 提交于 2019-12-23 18:18:49
问题 Basicly I can register one service like this. Container.Register(Component.For<IMyService>() .AsWcfClient(new DefaultClientModel() { Endpoint = WcfEndpoint .BoundTo(new NetNamedPipeBinding()) .At("net.pipe://localhost/MyService") }) .LifeStyle.PerWebRequest); But I could not figure out how to register all my services with similar configuration. the thing I was hoping to run is this... Container.Register( AllTypes.FromAssemblyNamed("My.Server.MyContracts") .Pick().If(x => x.Name.EndsWith(

Castle Windsor - Example of using InstallerFactory

三世轮回 提交于 2019-12-23 12:13:11
问题 Does anyone have some sample code of using a castle windsor InstallerFactory for ordering the installation of Installers? Can't seem to find it in the docs or elsewhere. Cheers 回答1: You can only use the InstallerFactory in conjunction with the FromAssembly class. When using FromAssembly you should not rely on the order in which your installers will be instantiated/installed. It is non-deterministic which means you never know what it's going to be. If you need to install the installers in some

Technique for using AutoFixture to integration test an application using Castle Windsor

时光毁灭记忆、已成空白 提交于 2019-12-23 09:38:31
问题 I'm new to AutoFixture, so I don't know if the following idea is going to make sense or be a reasonable thing to do. I've got an application that I'm in charge of integration testing , and it makes heavy use of Castle Windsor. To simplify dependency management and make my tests more like the application code, I've been building the Windsor container in my test initialize method and the using container.Resolve to instantiate the code I'm testing. I'd like to move away from that approach since

The factory was disposed and can no longer be used. NHibernatefacility

霸气de小男生 提交于 2019-12-23 09:36:30
问题 I have been trying for three days to figure out this NHibernatefacility thing with Castle and wcf and it's really getting frustrating. After solving a good dozen of errors, i have come to this one which seems pretty obvious but i can't solve. This is my global.asax's Application_Start container.AddFacility<AutoTxFacility>(); container.Register(Component.For<INHibernateInstaller>().ImplementedBy<NHibernateInstaller>()); container.AddFacility<NHibernateFacility>(); container.AddFacility

Can Windsor cooperate with another IoC container?

江枫思渺然 提交于 2019-12-23 09:36:26
问题 In the core of our application, we use Castle Windsor to manage our dependencies. We'll be loading plugins from third parties which may be using their own IoC containers. We'd like them to be able to receive dependencies from the core, e.g. through constructor injection of the core's services, but also receive dependencies from their own IoC container. It seems like if they supplied a service provider interface, Windsor could use it to resolve unknown dependencies, ignoring the results (since