You can create Dictionary<string, Action>one that maps attribute names to actions. Then, by analyzing the xml, you can find the fragment in the dictionary and execute it.
Quick example:
var attributeActions = new Dictionary<string, Action>();
attributeActions["level1A"] = () => { };
attributeActions["level2A"] = () => { };
...
attributActions[node.Attributes["name"]]();
, , , :
public static void Execute<TKey>(this IDictionary<TKey, Action> actionMap, TKey key)
{
Action action;
if (actionMap.TryGet(key, out action))
{
action();
}
}
:
attributActions.Execute(node.Attributes["name"]);
Action ( void), Action<T> Func<T, R>, / .