Created
August 16, 2013 13:43
-
-
Save nekman/6250089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example | |
{ | |
const int VAGVAL1 = 1; | |
const int VAGVAL2 = 2; | |
const int VAGVAL3 = 3; | |
readonly IDictionary<int, Action> _lookupMap; | |
public Example() { | |
_lookupMap = new Dictionary<int, Action>() { | |
{ VAGVAL1, Action1 }, | |
{ VAGVAL2, Action2 }, | |
{ VAGVAL3, Action3 } | |
}; | |
} | |
public void Metod(int vagvalsparameter) { | |
Action result = null; | |
_lookupMap.TryGetValue(vagvalsparameter, out result); | |
if (result != null) { | |
result(); | |
} | |
} | |
private void Action1() { | |
// do action 1 | |
} | |
private void Action2() { | |
// do action 2 | |
} | |
private void Action3() { | |
// do action 3 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment