예제 #1
0
 public T this[ulong hash]
 {
     get
     {
         foreach (var pair in this)
         {
             if (pair.Key == hash)
             {
                 return(pair.Value);
             }
         }
         throw new KeyNotFoundException($"The given key '{Hash40Util.FormatToString(hash)}' was not present in the dictionary.");
     }
     set
     {
         foreach (var pair in this)
         {
             if (pair.Key == hash)
             {
                 pair.Value = value;
                 return;
             }
         }
         throw new KeyNotFoundException($"The given key '{Hash40Util.FormatToString(hash)}' was not present in the dictionary.");
     }
 }
예제 #2
0
 public IEnumerable <T> IndexEnumerable(string keyName, IDictionary <string, ulong> labels)
 {
     try { return(IndexEnumerable(Hash40Util.LabelToHash40(keyName, labels))); }
     catch (KeyNotFoundException)
     {
         throw new KeyNotFoundException($"The given key '{keyName}' was not present in the dictionary.");
     }
 }
예제 #3
0
 public void Add(string keyName, IDictionary <string, ulong> labels, T value)
 {
     try { Add(Hash40Util.LabelToHash40(keyName, labels), value); }
     catch (ArgumentException)
     {
         throw new ArgumentException($"An item with the key '{keyName}' has already been added");
     }
 }
예제 #4
0
 public void Add(string keyName, T value)
 {
     try { Add(Hash40Util.StringToHash40(keyName), value); }
     catch (ArgumentException)
     {
         throw new ArgumentException($"An item with the key '{keyName}' has already been added");
     }
 }
예제 #5
0
 public string ToString(IDictionary <ulong, string> labels)
 {
     if (TypeKey == ParamType.hash40)
     {
         return(Hash40Util.FormatToString((ulong)Value, labels));
     }
     return(Value.ToString());
 }
예제 #6
0
        public IEnumerable <T> IndexEnumerable(ulong hash)
        {
            int count = 0;

            foreach (var pair in this)
            {
                if (pair.Key == hash)
                {
                    count++;
                    yield return(pair.Value);
                }
            }
            if (count == 0)
            {
                throw new KeyNotFoundException($"The given key '{Hash40Util.FormatToString(hash)}' was not present in the dictionary.");
            }
        }
예제 #7
0
        public void SetValue(string value, IDictionary <string, ulong> labels)
        {
            switch (TypeKey)
            {
            case ParamType.@bool:
                Value = bool.Parse(value);
                break;

            case ParamType.@sbyte:
                Value = sbyte.Parse(value);
                break;

            case ParamType.@byte:
                Value = byte.Parse(value);
                break;

            case ParamType.@short:
                Value = short.Parse(value);
                break;

            case ParamType.@ushort:
                Value = ushort.Parse(value);
                break;

            case ParamType.@int:
                Value = int.Parse(value);
                break;

            case ParamType.@uint:
                Value = uint.Parse(value);
                break;

            case ParamType.@float:
                Value = float.Parse(value);
                break;

            case ParamType.hash40:
                Value = Hash40Util.LabelToHash40(value, labels);
                break;

            case ParamType.@string:
                Value = value;
                break;
            }
        }
예제 #8
0
 public T this[string keyName, IDictionary <string, ulong> labels]
 {
     get
     {
         try { return(this[Hash40Util.LabelToHash40(keyName, labels)]); }
         catch (KeyNotFoundException)
         {
             throw new KeyNotFoundException($"The given key '{keyName}' was not present in the dictionary.");
         }
     }
     set
     {
         try { this[Hash40Util.LabelToHash40(keyName, labels)] = value; }
         catch (KeyNotFoundException)
         {
             throw new KeyNotFoundException($"The given key '{keyName}' was not present in the dictionary.");
         }
     }
 }
예제 #9
0
 public T this[string keyName]
 {
     get
     {
         try { return(this[Hash40Util.StringToHash40(keyName)]); }
         catch (KeyNotFoundException)
         {
             throw new KeyNotFoundException($"The given key '{keyName}' was not present in the dictionary.");
         }
     }
     set
     {
         try { this[Hash40Util.StringToHash40(keyName)] = value; }
         catch (KeyNotFoundException)
         {
             throw new KeyNotFoundException($"The given key '{keyName}' was not present in the dictionary.");
         }
     }
 }
예제 #10
0
 public bool ContainsKey(string keyName, IDictionary <string, ulong> labels)
 {
     return(ContainsKey(Hash40Util.LabelToHash40(keyName, labels)));
 }
예제 #11
0
 public bool ContainsKey(string keyName)
 {
     return(ContainsKey(Hash40Util.StringToHash40(keyName)));
 }