2014-03-25 218 views
0

註冊枚舉我不知道這是可能的,但我有像這樣與溫莎城堡

public enum StopCode 
{ 
    StartProd = 77, 
    BeaOmstilling = 45, 
    FlexOmstilling = 47, 
    PlaStop = 32, 
} 

一個枚舉和枚舉具有取決於哪個國家的程序運行某些情況下,不同的值。

public enum StopCode 
{ 
    StartProd = 20, 
    BeaOmstilling = 25, 
    FlexOmstilling = 97, 
    PlaStop = 62, 
} 

有沒有什麼辦法,我可以在溫莎城堡註冊兩個枚舉值。兩個枚舉都在不同的命名空間中。

+0

你找到了一種方法去做你想要的嗎? – samy

回答

1

我不認爲你可以使用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;} 
} 

需要的時候解決的正確執行,你有你的本地化枚舉值。


編輯:即使在不同的命名空間枚舉我不認爲這是改變的枚舉值,因爲不同類型的將導致沿着這些類型的分割你的代碼是一個好主意。你也將被迫解決你感興趣的具體類型