简体   繁体   English

如何在Unity IoC中进行以下NInject注册?

[英]How would I do the following NInject registration with Unity IoC?

I want to be able to do the following type registration with unity, does anyone know how? 我希望能够统一进行以下类型注册,有人知道吗?

 Bind<ILogger>().To<AssemblyEditorLogger>()
   .WithConstructorArgument("currentClassName",
                            x => x.Request.ParentContext != null ? 
                            x.Request.ParentContext.Request.Service.FullName : typeof (BootStrapper).FullName);

Basically in Unity how do I get access to the type of class we are creating the instance for - I am using constructor injection. 基本上在Unity中,我如何访问要为其创建实例的类的类型-我正在使用构造函数注入。

Related to this question . 与这个问题有关

You can get access to the type the same way it is done for LogManager.GetLogger() . 您可以使用对LogManager.GetLogger()相同的方式来访问类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Unity IoC时如何实现Ninject .InSingletonScope() - How can I implement Ninject .InSingletonScope() when using Unity IoC 如何将UnityContainer作为参数传递给Unity IOC xml配置文件中的注册 - How do I pass the UnityContainer as a parameter to a registration in a Unity IOC xml configuration file 如何使用Ninject IOC更好地完成这项工作 - How can i do this better using Ninject IOC 如何将Unity IoC容器与Template10一起使用? - How do I use a Unity IoC container with Template10? 如何在MVC验证属性中使用Unity IoC? - How do I use Unity IoC in an MVC Validation Attribute? 为什么我应该在ASP.Net应用程序中使用IoC Container(Autofac,Ninject,Unity等)进行依赖注入? - Why should I use IoC Container (Autofac, Ninject, Unity etc) for Dependency Injection in ASP.Net Applications? Unity和Simple Injector之间的IoC注册差异 - IoC Registration differences between Unity and Simple Injector Unity IoC - 单元测试类型的注册是否正确 - Unity IoC - unit test the registration of types correct 如何在多个类中访问同一IoC容器(即Unity)? - How do I access the same IoC container (i.e. Unity) in multiple classes? 如何在运行时使用Unity IoC选择注册的依赖类型? - How do I choose a registered dependent type at runtime using Unity IoC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM