예제 #1
0
 private static void AddAnyRu(KeyDictionary dictionary, Keys key, object any, string letter)
 {
     if (dictionary.ContainsKey(key))
     {
         throw new Exception("Duplicate key: " + key);
     }
     else
     {
         dictionary.Add(key, AnyRu(any, letter));
     }
 }
예제 #2
0
        /// <summary>
        /// Cast key to derived enum
        /// </summary>
        /// <param name="key">Key to cast</param>
        /// <returns>Derived enum matching key OR new enum if not exists</returns>
        protected new static TDerived From(int key)
        {
            if (KeyDictionary.ContainsKey(key))
            {
                return((TDerived)KeyDictionary[key]);
            }

            var result = new TDerived
            {
                Key = key
            };

            KeyDictionary.Add(key, result);
            return(result);
        }
예제 #3
0
        //private void AddToDictionary(
        //    PoeNinjaDataService.ItemJsonResponse.Line line,
        //    string attribute,
        //    bool useNameForKeyGeneration = true,
        //    bool useBaseTypeForKeyGeneration = false)
        //{
        //    line.Name = line.Name.Trim();

        //    var keyNode = new KeyNode
        //    {
        //        Description = line.Name,
        //        Key = FormatStringToKey(line, useNameForKeyGeneration, useBaseTypeForKeyGeneration),
        //    };

        //    keyNode.Attributes.Add($"[Name(Name = \"{line.Name}\")]");

        //    if(line.Id != -1)
        //    {
        //        keyNode.Attributes.Add($"[{attribute}(PoeNinjaId = \"{line.Id}\")]");
        //        keyNode.Attributes.Add($"[PoeNinja]");
        //    }
        //    else
        //    {
        //        keyNode.Attributes.Add($"[{attribute}()]");
        //    }

        //    AddToDictionary(keyNode);
        //}

        private void AddToDictionary(KeyNode keyNode)
        {
            if(!KeyDictionary.ContainsKey(keyNode.Key))
            {
                KeyDictionary.Add(keyNode.Key, keyNode);

                return;
            }

            var existing = (KeyNode)KeyDictionary[keyNode.Key];

            foreach(var a in keyNode.Attributes)
            {
                if(existing.Attributes.Any(o => o.Equals(a, StringComparison.OrdinalIgnoreCase)))
                {
                    continue;
                }

                existing.Attributes.Add(a);
            }

        }
예제 #4
0
 /// <summary>
 /// Check if enum contains key
 /// </summary>
 /// <param name="key">Key to check</param>
 /// <returns>True if the enum key exists</returns>
 public static bool Contains(TKey key)
 {
     return(KeyDictionary.ContainsKey(key));
 }