private void InitializeNamedArguments() { var props = typeof(T).GetTypeInfo().GetProperties().Where(p => p.GetCustomAttribute <NamedArgumentAttribute>() != null); foreach (var prop in props) { var arg = prop.ToNamedArgument(); var sn = GetShortName(arg); if (sn.HasValue) { if (ShortNameArguments.ContainsKey(sn.Value)) { throw new DuplicateArgumentException(sn.ToString()); } ShortNameArguments.Add(sn.Value, arg); } var ln = GetLongName(arg); if (ln != null) { if (LongNameArguments.ContainsKey(ln)) { throw new DuplicateArgumentException(ln); } LongNameArguments.Add(ln, arg); } } }
public void InitializeTriggers(IEnumerable <ITerminatingTrigger> triggers) { Triggers = triggers; if (triggers == null) { return; } foreach (var trigger in Triggers.Where(p => p != null)) { var sn = GetShortName(trigger, String.Format( "Trigger '{0}' argument {1} is not a valid short name. {2}", trigger.PluginName, trigger.ShortName, ArgumentValidation.IsAllowedShortNameExplanation)); if (sn.HasValue) { if (ShortNameArguments.ContainsKey(sn.Value)) { throw new DuplicateArgumentException(sn.ToString()); } ShortNameArguments.Add(sn.Value, trigger); } var ln = GetLongName(trigger, String.Format( "Trigger '{0}' argument {1} is not a valid long name. {2}", trigger.PluginName, trigger.LongName, ArgumentValidation.IsAllowedLongNameExplanation)); if (ln != null) { if (LongNameArguments.ContainsKey(ln)) { throw new DuplicateArgumentException(ln); } LongNameArguments.Add(ln, trigger); } } }