castle-windsor

Castle project per session lifestyle with ASP.NET MVC

落花浮王杯 提交于 2019-12-03 08:42:40
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 SearchController{ private ISearchOptions _searchOptions; public SearchController(ISearchOptions searchOptions

PooledRedisClientManager not releasing connections

喜你入骨 提交于 2019-12-03 08:37:41
I am storing lists of json data in redis and accessing it using the ServiceStack c# client. I am essentially managing my own foreign keys, where I store a zrange of ids and I use an interface internal to my application to pull the id's from the zrange and then fetch the underlying json objects from Redis and package them as a list to return to other parts of my application. I am using the PooledRedisClientManager as I anticipate Redis to be hosted on a different server from the server executing the code. I am doing all my development work locally on Windows 8, using the MSOpenTech Redis server

Proper Hub dependency lifetime management for SignalR and Castle Windsor

允我心安 提交于 2019-12-03 08:10:52
问题 I have some SignalR hubs which may need to access some transient and singleton dependencies. Hooking the creation of the Hub is easy and works just fine however SignalR does its own Dispose() call on the created Hub rather than notifying the dependency resolver and letting it get involved in the disposal. This isn't such a big deal if the dependencies are registered singletons, but if they're registered as transients then they'll never get disposed (if that was required) and Windsor will keep

Avoiding Service Locator Antipattern with legacy app not designed for IOC

懵懂的女人 提交于 2019-12-03 07:26:25
问题 I have read often that Service Locators in IOC are an anti-pattern. Last year we introduced IOC (Ninject specifically) to our application at work. The app is legacy, it's very big and it's fragmented. There are lots of ways a class, or a chain of classes can get created. Some are created by the web framework (which is custom), some are created by nHibernate. Lots are just scattered around in weird places. How would we handle the different scenarios and not come up with something thats not at

Injecting Dependencies into Domain Model classes with Nhibernate (ASP.NET MVC + IOC)

谁都会走 提交于 2019-12-03 07:25:54
I'm building an ASP.NET MVC application that uses a DDD (Domain Driven Design) approach with database access handled by NHibernate. I have domain model class (Administrator) that I want to inject a dependency into via an IOC Container such as Castle Windsor, something like this: public class Administrator { public virtual int Id { get; set; } //.. snip ..// public virtual string HashedPassword { get; protected set; } public void SetPassword(string plainTextPassword) { IHashingService hasher = IocContainer.Resolve<IHashingService>(); this.HashedPassword = hasher.Hash(plainTextPassword); } } I

Inject AutoMapper

喜欢而已 提交于 2019-12-03 06:50:06
I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle Windsor for my project. So, how do we implement the following dependency injection and set-up using Windsor? I am not looking for line-by-line equivalent implementation in Castle Windsor. If you want to do that, please feel free. Instead, what is Windsor equivalent of StructureMap's Registry and Profile? I need Profile to define CreateMap<> like the

Castle Windsor or Spring.NET - advantages and disadvantages [closed]

落爺英雄遲暮 提交于 2019-12-03 06:42:14
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Yesterday I was reading some articles in this site while I stumbled on an article about this two new IoC tools. Which one should I learn first? Is there some specification about which one should be used when? Mark Seemann Neither Castle.Windsor or Spring.NET

Can I Use Typed Factory Facility to Return Implementation Based on (enum) Parameter?

走远了吗. 提交于 2019-12-03 06:36:14
Not sure if this is possible or not. I need to return the correct implementation of a service based on an enum value. So the hand-coded implementation would look something like: public enum MyEnum { One, Two } public class MyFactory { public ITypeIWantToCreate Create(MyEnum type) { switch (type) { case MyEnum.One return new TypeIWantToCreate1(); break; case MyEnum.Two return new TypeIWantToCreate2(); break; default: return null; } } } The implementations that are returned have additional dependencies which will need to be injected via the container, so a hand-rolled factory won't work. Is this

Windsor Container: How to force dispose of an object?

泄露秘密 提交于 2019-12-03 06:00:34
I have an object that implements IDisposable that is registered with the Windsor Container and I would like to dispose of it so it's Dispose method is called and next time Resolve is called it fetches a new instance. Does container.Release(obj); automatically call Dispose() immediately? Or do I need to do obj.Dispose(); container.Release(obj); Couldn't find anything in the documentation on what exactly Release does EDIT: See my answer below for the results of tests I ran. Now the question becomes, how do I force the container to release an instance of a component with a singleton lifecycle?

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

走远了吗. 提交于 2019-12-03 04:40:13
Can .NET 4 ISet<> HashSet<> replace NHibernate Iesi.Collections ISet , HashSet ? I am using Castle proxy, and NHibernate 3.0 . 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 been removed from the Iesi.Collections dependency. The approach to use System.Collections.Generic.ISet<T>