castle-windsor

Castle project per session lifestyle with ASP.NET MVC

淺唱寂寞╮ 提交于 2019-12-09 06:07:47
问题 I'm really new to Castle Windsor IoC container. I wanted to know if theres a way to store session variables using the IoC container. I was thinking something in the line of this: I want to have a class to store search options: public interface ISearchOptions{ public string Filter{get;set;} public string SortOrder{get;set;} } public class SearchOptions{ public string Filter{get;set;} public string SortOrder{get;set;} } And then inject that into the class that has to use it: public class

Can .NET 4 ISet<> HashSet<> replace NHibernate Iesi.Collections ISet , HashSet?

。_饼干妹妹 提交于 2019-12-09 05:14:12
问题 Can .NET 4 ISet<> HashSet<> replace NHibernate Iesi.Collections ISet , HashSet ? I am using Castle proxy, and NHibernate 3.0 . 回答1: No, not as of this reply. The NHibernate engine uses the Iesi.Collections.ISet interface on internal collection classes which are used as wrappers around collections in your classes which NHibernate persists. There is no direct conversion to System.Collections.Generic.ISet<T> . Update: NHibernate 4 now uses HashSet<T> from the BCL internally, and HashedSet<T> has

Is it correct to have many Castle Windsor containers per application if those containers belong to different tiers?

故事扮演 提交于 2019-12-09 03:51:33
问题 I've been playing around with Castle Windsor lately and realized I could use it to back a container-like object I currently use already. So far I've only read information about an application having only one container instance per application. Is it correct to have many containers per application if those containers belong to different tiers? The reason I ask is because I'd like to take advantage of Windsor's dependency resolution and XML configuration for my own container-like object. I

Can't pass parameter to Windsor Typed Factory Facility

淺唱寂寞╮ 提交于 2019-12-08 19:15:52
问题 I've got a IRunningTaskFactory which is registered with Windsor AsFactory() using the Typed Factory Facility. The interface has a single method that looks like this: RunningTask Create(ITask task); Where RunningTask is registered with Windsor as being transient has a constructor: public RunningTask(ITask task, ITaskConfigurationFactory taskConfigurationFactory) where ITaskConfigurationFactory is registered with Windsor as well. The problem I'm running into is that when I call the Create

Castle Windsor lazy load services

左心房为你撑大大i 提交于 2019-12-08 15:59:17
问题 Occasionally I find myself in a situation where I need to resolve a service only if a certain condition is met. For example, a user might select to send an email or an sms notification. I would like to lazy load the email or sms service depending on what the user chooses so that I don't have to load both of them and waste resources (what if there were, for example, 10 options for the user...?). The problem I have is with using the container outside of my bootstrap code (I dont want my code

Registering 'half-closed' generic component

China☆狼群 提交于 2019-12-08 15:11:41
问题 I have two interfaces: public interface IQuery<TResult> { } public interface IQueryHandler<in TQuery, out TResult> where TQuery : IQuery<TResult> { TResult Handle(TQuery q); } An example of a closed implementation of IQueryHandler: public class EventBookingsHandler : IQueryHandler<EventBookings, IEnumerable<EventBooking>> { private readonly DbContext _context; public EventBookingsHandler(DbContext context) { _context = context; } public IEnumerable<EventBooking> Handle(EventBookings q) {

Castle WCF Client Registration syntax

十年热恋 提交于 2019-12-08 10:52:10
问题 Trying to register a WCF client with Castle WcfIntegration 3.0; is there anything wrong with the following syntax? Container.Kernel.Register( Component.For(serviceType) .AsWcfClient(new DefaultClientModel { Endpoint = WcfEndpoint .FromConfiguration( serviceType.Name. Substring(1) + "Client") }) .LifeStyle.Is(lifestyle)); The problem I'm having is when in the context of a WCF service operation, ServiceSecurityContext.Current is null. This did not happen in the old version of Castle (1.0.3.0).

AOP Caching with Castle Windsor

偶尔善良 提交于 2019-12-08 10:19:30
问题 Can anyone provide a working example of how caching with Castle Windsor would work. I presume as a starting point I define my CacheAspect which inherits from IInterceptor as follows: public class CacheAspect : IInterceptor { public void Intercept(IInvocation invocation) { // Code here to check if data is in cache and if so // put that into invocation.ReturnValue... job done! // If not then invoke the method invocation.Proceed(); // Now cache the result of the invocation } } I can then

Windsor Ioc container: How to register that certain constructors take different implementation of an interface

风格不统一 提交于 2019-12-08 10:03:09
问题 I have lots of classes that take an IMyService as a constructor argument. e.g. ClassA(IMyservice myservice) // this should take a Concrete1 for IMyService ClassB(IMyservice myservice) // this should take a Concrete2 for IMyService How do I do my registration so that ClassB gets a Concrete2 and ClassA gets a Concrete1? Plus, is there a way to make one the default and only specify the instances that deviate from the default? (As the majority will take a Concrete1 and only a small number will

Dependency on Log4Net Logger and Retrieve Logger by Caller Type using Castle Windsor

我是研究僧i 提交于 2019-12-08 07:31:08
问题 I have a thin wrapper around log4net and I am trying to use the type of the calling class to get a logger from log4net.LogManager by using Castle.Windsor . public class Foo: IFoo { private readonly ICommonLog _logger; public Foo(ICommonLog logger) { _logger = logger; } public void FooBar() { _logger.Info("Enter FooBar Method"); } } public class CommonLog : ICommonLog { private readonly log4net.ILog _logger; public CommonLog(Type loggerType) { _logger = log4net.LogManager.GetLogger(loggerType)