我正在使用Ninject在我的应用程序中实现IoC/DI。它在整个应用程序中一直运行良好,除了一种情况,我在其中设置了User Defined Class类型的构造函数参数。Ninject将方法set构造方法的参数设置为null
该类有四个属性,它们都是用户定义类型的类型,它们都是序列化的枚举。
现在,当我解决内核的依赖关系时,它将引发异常作为构造函数参数值设置为null。我不知道为什么。
是因为seriazlizeable枚举或别的东西。我无法改变我的类型,所以请在我不需要改变类型的情况下给我一些建议。
编辑
IManager manager = GlobalData.Kernel.Get<IManager> (new ConstructorArgument("context", Context));
// Context Class code is here
public class Context {
public string ContextCode { get; set; }
public Module Module { get; set; }
public Screen Screen { get; set; } }
模块和屏幕是可序列化枚举
你可以添加代码示例吗? –
IManager manager = GlobalData.Kernel.Get (new ConstructorArgument(“context”,Context));上下文类代码在这里公共类上下文 { public string ContextCode {get;组; } public Module Module {get;组; } public Screen Screen {get;组; } }模块和屏幕是可序列化的枚举 –