The action filter that I want to introduce at the beginning, like this
public class UserAuthorisation : AuthorizeAttribute
{
public IWcfClientProxy<IAppFrameworkServiceChannel>
FrameworkServiceProxy { get; set; }
I installed my container as follows:
container.Register<IWcfClientProxy<IAppFrameworkServiceChannel>>(
()=> new WcfClientProxy<IAppFrameworkServiceChannel>());
container.RegisterInitializer<UserAuthorisation>(handler =>
{
handler.FrameworkServiceProxy = container
.GetInstance<IWcfClientProxy<IAppFrameworkServiceChannel>>();
});
When I run this, the property FrameworkServiceProxyis null.
I read this post: Simple Injector: introducing the property into the base class and following the answer. I also read an example on this page Simple Injection Documentation .
I am not injecting into the base class and maybe this is the problem?
## UPDATE ##
I am adding more information as I think it should work from what was said in Stevens answer.
I am using the NuGet package for MVC 3. This adds the following to the application:
public static class SimpleInjectorInitializer
{
public static void Initialize()
{
var container = new Container();
InitializeContainer(container);
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
container.RegisterMvcAttributeFilterProvider();
container.Verify();
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
}
private static void InitializeContainer(Container container)
{
container.Register<IWcfClientProxy<IAppFrameworkServiceChannel>>(() => new WcfClientProxy<IAppFrameworkServiceChannel>());
container.RegisterInitializer<UserAuthorisation>(handler =>
{
handler.FrameworkServiceProxy = container.GetInstance<IWcfClientProxy<IAppFrameworkServiceChannel>>();
});
}
container.RegisterMvcAttributeFilterProvider();, , , , ( ), .
Global.asax.cs :
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new UserAuthorisation());
}
, , , - , ?