Hi everybody!
I need to implement multi-tenancy and i like the way it is solved here.
The problem implementing this scenario (in my project) is that the following code snippet
var handlerSelectors = windsorContainer.ResolveAll<IHandlerSelector>();
gives me something ( {Castle.MicroKernel.IHandlerSelector[0]}).
The following snippet...
I'm currently using Castle-Windsor with the WCF Facility to inject all my WCF services. I've just started adding permission requirements using a custom IAuthorizationPolicy, which seems to work when done on a per-method basis on the service, but when the service class itself is marked up with the requirements, I get an exception thrown.
...
I'm wondering how I should store/reference my dependency injection container(s). Is it alright to have a container be a static property on a static class? Or should I have the container be an instance variable on the application? I'm wondering what the pros and cons of each option are, and what is the best practice for this in web, mvc, ...
Hello stackoverflow! Long-time reader first time writer here. I am currently undertaking a conversion from to the use of Ninject to the current release of Castle Windsor for a simple C# .NET application.
For the most part, the conversion has gone well and the implementation of the containers has executed flawlessly. I am however hav...
I currently have the following registration set up
private static void AddFrameworkComponentsTo(IWindsorContainer container)
{
container.AddComponent<ITypeConverter, TypeConversionFacade>();
container.AddComponent<Framework.Conversion.ITypeConverter<string, int>, StringConverter>();
container.AddComponent<Framework.Conversio...
Configuration:
component id="customerService" service="MyApp.ServiceLayer.ICustomerService`1[[MyApp.DataAccess.Customer, MyApp.DataAccess]], MyApp.ServiceLayer" type="MyApp.ServiceLayer.CustomerService, MyApp.ServiceLayer"
**Controller:**
private ICustomerService _service;
public CustomerController()
{
...
Hi
quick question for my MVP implementation:
currently I have the code below, in which both the presenter and view are resolved via the container.
Then the presenter calls View.Init to pass himself to the view.
I was wondering however if there is a way to let the container fix my circular reference (view -> presenter, presenter -> vie...
I am trying to register multiple NHibernate ISessions (multiple databases) by using the code below. I am getting "There is a component already registered for the given key Castle.MicroKernel.Registration.GenericFactory`1[[NHibernate.ISession, NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]]" as the error...
Hello.
I'm using Castle Windsor with a configuration from my App.config file.
In the code I use :
IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
to get the container.
But for some configurations of my application I don't want to use CastleWindsor (for some migration issues...) and therefore, I don't wan...
I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which ...
In my MVC application, I'm registering all of my controllers using reflection in the Application_Start handler. This basically creates all types that are used on any controller parameter and adds it to the container.
I now have a situation where I have multiple parameters on my controller that are of the same type. Here is a simple exam...
I'm using Castle DictionaryAdapter in order to get the application settings from the app.config as an interface ( based on Getting rid of strings (3): take your app settings to the next level ):
public interface ISettings {
int MaxUsers { get; }
string FeedbackMail { get; }
DateTime LastUserLogin { get; }
}
app.config
<?xml ver...
I know I can specify it in the configuration XML, but I'd like to not have to do so for every controller. For example: I have a controller without any dependencies being injected, but I'd rather not type out the XML component section in the config file or register it programmatically. Any ideas, suggestions, examples? Thanks for all the ...
I have something like this:
public interface IBaseService<TObject>
public class BaseService<TObject, TRepository> : IBaseService<TObject>
where TRepository : IRepository<TObject>
I need to register BaseService To IBaseService
(the IRepository<> is registered)
...
I have several dependency injection services which are dependent on stuff like HTTP context. Right now I'm configuring them as singletons the Windsor container in the Application_Start handler, which is obviously a problem for such services.
What is the best way to handle this? I'm considering making them transient and then releasing th...
This registration works when all the implementations of IService are public:
AllTypes
.Of<IService>()
.FromAssembly(GetType().Assembly)
.WithService.FirstInterface()
For example:
public interface IService {}
public interface ISomeService : IService {}
public class SomeService : ISomeService {}
Resolving ISomeService ret...
When I use this registration:
container.Register(
Component
.For<IFooFactory>()
.ImplementedBy<FooFactory>(),
Component
.For<IFoo>()
.UsingFactoryMethod(kernel => kernel.Resolve<IFooFactory>().CreateFoo())
);
I get this exception:
Castle.MicroKernel.ComponentRegistrationException: Type MyNam...
I'm new to Castle Windsor, so go easy!!
I am developing an MVC web app and one of my controllers has a dependency on knowing the current request Url.
So in my Application_Start I initialise a WindsorContainer (container below), register my controllers and then try the following...
container.AddFacility<FactorySupportFacility>();
conta...
I have a unit test invoking a constructor, passing in a "null" on purpose to test the handling of the null.
I expect the method invoked to throw an ArgumentNullException, but when I step through the code, I see the parameter has actually been initialised.
This has me stumped, although my gut says it has something to do with the DI cont...
interface IFoo<T> { }
interface IBar { }
class BarImpl : IBar { }
class FooImplA : IFoo<IBar> { }
class FooImplB : IFoo<BarImpl> { }
container.Register(
AllTypes.Of(typeof(IFoo<>)).From(assem)
.WithService.FirstInterface());
var bars = container.ResolveAll<IFoo<BarImpl>>();
Is there anyway to setup the Windsor contain...