How Can I Inject My Services To GetVaryByCustomString With Ninject

54 views Asked by At

I have an ASP.NET MVC application, i use Ninject for DI and i use output cache system. But i need to take some informations from my business layer(services). But i don't know how can i inject my services to GetVaryByCustomString method. What's your solution?

    public override string GetVaryByCustomString(HttpContext context, string arg)
    {
       //I need some services here, for example product service. 
       //I need like this
       //var prodManager = Ninject.Get<IProductService>();
       //prodManager.ToSomeMethod();
    }
1

There are 1 answers

0
Yargicx On BEST ANSWER

I've found my solution.

public override string GetVaryByCustomString(HttpContext context, string arg)
{
   var prodManager = DependencyResolver.Current.GetService<IProductService>();
   prodManager.ToSomeMethod();
}