17 static readonly Dictionary<XName, MethodInfo> readMethodsByName;
24 readMethodsByName = typeof(
Instruction).Assembly.GetTypes()
27 .Select(i =>
new { ElementName = MapXmlSerializer.NS + i.GetCustomAttribute<
InstructionAttribute>().ElementName,
Type = i })
28 .Select(i =>
new { i.ElementName, Method = i.Type.GetMethod(
"Read", BindingFlags.Public | BindingFlags.Static) })
29 .ToDictionary(i => i.ElementName, i => i.Method);
39 if (readMethodsByName.TryGetValue(element.Name, out var m) ==
false)
40 throw new MapXmlException($
"Could not find instruction type for '{element.Name}'.");
42 return (
Instruction)m.Invoke(
null,
new[] { element });