private static AbstractTemplateDeserializer GetDeserializer(string command, TemplateCommandEnum cmd) { var commandName = command.ToUpper(); if (m_CommandDeserializers == null) { m_CommandDeserializers = InitCommandDeserializers(); } if (!m_CommandDeserializers.ContainsKey(cmd)) { throw new ArgumentOutOfRangeException(nameof(command), $"Command {commandName} ({cmd}) not deserializable"); } var type = m_CommandDeserializers[cmd]; ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes); AbstractTemplateDeserializer instance = (AbstractTemplateDeserializer)ctor?.Invoke(new object[0]); if (instance == null) { throw new ArgumentOutOfRangeException(nameof(command), $"Deserializer for {commandName} ({cmd}) not instanciable"); } return(instance); }
public TemplateCommandAttribute(TemplateCommandEnum command, params TemplateCommandEnum[] aliases) { Commands = new[] { command }.Union(aliases).ToArray(); }