[英]Register Enumeration with Castle Windsor
我不确定这是否可能,但我有一个像这样的枚举
public enum StopCode
{
StartProd = 77,
BeaOmstilling = 45,
FlexOmstilling = 47,
PlaStop = 32,
}
在某些情况下,枚举具有不同的值,具体取决于程序运行的国家/地区。
public enum StopCode
{
StartProd = 20,
BeaOmstilling = 25,
FlexOmstilling = 97,
PlaStop = 62,
}
有什么办法可以在温莎城堡中注册两个枚举值。 两个枚举都位于不同的命名空间中。
我认为您无法使用Castle.Windsor切换枚举值,但是您可以尝试以下操作
// declare the enum
public enum StopCode
{
StartProd,
BeaOmstilling,
FlexOmstilling,
PlaStop,
}
// and declare an interface that translates this enum to values
public interface StopCodeConverter
{
int convertFrom(StopCode code);
}
// then your components
public class EnglishStopCodeConverter
{
public int convertFrom(StopCode code) { /* do your translation */ return 0;}
}
public class SpanishStopCodeConverter
{
public int convertFrom(StopCode code) { /* hace su translaciòn */ return 0;}
}
在需要时解决正确的实现,您便拥有了本地化的枚举值。
编辑:即使枚举位于不同的命名空间中,我也不认为更改枚举中的值不是一个好主意,因为不同的类型将导致您的代码沿这些类型拆分。 您还将被迫解决您感兴趣的特定类型
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.