castle-windsor

Transient Lifestyle requires HttpContext?

北战南征 提交于 2019-12-25 09:16:57
问题 I am registering my component like this: public static void Register(IWindsorContainer container) { container.Register(Classes.FromAssembly(Assembly.GetAssembly(typeof(GenericBaseRepository))) .InSameNamespaceAs<GenericBaseRepository>() .WithService.DefaultInterfaces() .LifestyleTransient()); } I am then resolving it in a piece of code that has no HttpContext: var baseRepository = ContainerManager.Container.Resolve<IBaseRepository>(); (IBaseRepository being an interface implemented by

Creating WindsorViewPageActivator

匆匆过客 提交于 2019-12-25 08:31:56
问题 I was playing with new Asp net mvc 3 RC2. I have created a WindsorViewPageActivator class as follows public class WindsorViewPageActivator : IViewPageActivator { object IViewPageActivator.Create(ControllerContext controllerContext, Type type) { return DependencyResolver.Current.GetService(type); } } and then a WindsorDependencyResolver class public class WindsorDependencyResolver : IDependencyResolver { private readonly IWindsorContainer container; public WindsorDependencyResolver

PerWebRequest and Transient lifeStyles

走远了吗. 提交于 2019-12-25 07:20:48
问题 Can someone please help me understand several things? Do I still have to register PerRequestModule to use LifeStylePerWebRequest? I use Castle.Windsor 3.2.0.0 and it seems everything works without this module. I definetly remember that there was an exception before that tells me "You forget to register this module". What "objects tracked by release policy" really means? I use several Components with LifeStyleTransient but when I Resolve one I get it in "objects tracked by release policy"

What is the expected LifeStyle of a Castle Windsor component activator?

好久不见. 提交于 2019-12-25 06:33:08
问题 I'm using Castle Windsor and DynamicProxy to implement persistence Lazy Loading from scratch (I know NHibernate could be an option etc.) I have implemented a custom component activator to always instantiate my business classes as proxies. I found that the default mixin proxies automatically created when using interceptors were not being used when class methods are called from inside the class itself, which was a problem. So I inherited DefaultComponentActivator and overriding CreateInstance()

How do I specify the class instance I want my Controller's constructor to receive (when working with Web API, DI, and Castle Windsor)?

不想你离开。 提交于 2019-12-25 04:33:31
问题 Perhaps my questions here and here are not clear enough, so I'll try to decrease the verbosity while not reducing the clarity. Say my Controller uses DI (you can verbalize it "in your head" - you don't have to utter it out loud); so it could look like this: private readonly IDepartmentRepository _deptsRepository; public DepartmentsController(IDepartmentRepository deptsRepository) { if (deptsRepository == null) { throw new ArgumentNullException("deptsRepository is null"); } _deptsRepository =

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

安稳与你 提交于 2019-12-25 04:09:18
问题 (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

Wcf Castle Windsor

折月煮酒 提交于 2019-12-25 02:25:09
问题 I am using the Wcf Facility, (windsor 2.5.2) latest version from github repo as of last week. how ever it is not working throwing the following error (when the service starts up) Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are []. here is the setup var container = new WindsorContainer(); container.AddFacility<WcfFacility>() .Register( Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>().LifeStyle

IWcfPolicy - add message headers on the fly

三世轮回 提交于 2019-12-25 01:01:07
问题 Is it somehow possible to add header info (or querystrings) to a wcf request on the fly? I've been messing around a bit with the IWcfPolicy like this: var xmlObjectSerializer = new DataContractSerializer(typeof(string)); var addressHeader = AddressHeader.CreateAddressHeader("client", "http://tempuri.org/", "someValue", xmlObjectSerializer); var endpointAddress = new EndpointAddress(new Uri(url), new AddressHeader[] { addressHeader }); invocation.ChannelHolder.ChannelFactory.Endpoint.Address =

who calls the constructor witth parameter (Castle.Windsor)

别等时光非礼了梦想. 提交于 2019-12-24 21:03:06
问题 I am learning castle.windsor following the tutorial online. this is the simple sample code: public class Form1 { private readonly HttpServiceWatcher serviceWatcher; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } public Form1(HttpServiceWatcher serviceWatcher) : this() { this.serviceWatcher = serviceWatcher; } } HttpServiceWatcher is in the xml conf file. My question is: who is calling the constructor that has the parameter: public Form1

Configure Fluent Nhibernate with NHibernate.Caches.MemCached

徘徊边缘 提交于 2019-12-24 16:32:15
问题 I am trying to configure Fluent NHibernate with MemCache but I get the following error. I am using MVC5+CastleWindsor+FluentNHibernate+UOW private static ISessionFactory CreateNhSessionFactory() { var connStr = System.Configuration.ConfigurationManager.ConnectionStrings["AESConnect"].ConnectionString; return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(connStr)) .Cache(c=>c.ProviderClass(typeof(NHibernate.Caches.MemCache.MemCacheProvider).AssemblyQualifiedName)