构造函数的参数枚举和魔术字符串 [英] Constructor Argument Enums and Magic Strings
问题描述
我的工作我的C#.NET应用程序和使用实现使用Ninject的IoC / DI模式,现在Ninject有 ConstructorArgument
这两个参数(argName,argValue评为一类)。
I am working on my c# .net application and use implement IoC/DI pattern using Ninject, Now Ninject has a class named ConstructorArgument
which takes two arguments(argName,argValue).
所以,我需要通过静态argName这样的事情
So i need to pass static argName something like this
new ConstructorArgument("strVar","")
似乎并不通过硬codeD字符串像一个不错的选择。
passing hardcoded string does not seems like a good option.
所以我要创造这样使用反射的构造函数参数的动态枚举,所以我不需要通过硬codeD字符串。
So i want to create something like dynamics enums using reflection for the constructor arguments, so i dont need to pass hardcoded strings.
请指导我通过这个过程还是建议我别的东西来实现这一点。
Please guide me through this process or suggest me something else to achieve this.
推荐答案
请参阅:的 http://www.planetgeek.ch/2011/05/28/ninject-constructor-selection-$p$pview/ 并使用当前连续一体化的构建或等待2.4释放。
See: http://www.planetgeek.ch/2011/05/28/ninject-constructor-selection-preview/ and use the current continuous intergration build or wait for 2.4 release.
这篇关于构造函数的参数枚举和魔术字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!