Beispiel #1
0
        internal void Set(string name, string value)
        {
            if (!Formal.ContainsKey(name))
            {
                throw new MissingFlagException(name);
            }

            var flag = Formal[name];

            flag.Set(value);
            Actual[name] = flag;
        }
Beispiel #2
0
        internal void Set <T>(string name, T value)
        {
            if (!Formal.ContainsKey(name))
            {
                throw new MissingFlagException(name);
            }
            var flag = Formal[name];

            ((IFlag <T>)flag).Value = value;

            Actual[name] = flag;
        }
Beispiel #3
0
 /// <summary>
 /// Pass a user-implemented IFlag directly to the FlagSet
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="flag"></param>
 /// <returns></returns>
 public T Var <T>(T flag) where T : IFlag
 {
     if (Formal != null && Formal.ContainsKey(flag.Name))
     {
         var msg = Name == "" ? $"flag redefined: {flag.Name}" : $"{Name} flag redefined: {flag.Name}";
         Output().WriteLine(msg);
         throw new InvalidOperationException(msg);
     }
     if (Formal == null)
     {
         Formal = new Dictionary <string, IFlag>();
     }
     Formal.Add(flag.Name, flag);
     return(flag);
 }