public static void DecodeFromJson(this System.Collections.Generic.IDictionary <string, string> self, string encodedDictionary)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            System.Collections.Generic.Dictionary <string, object> dictionary = javaScriptSerializer.DeserializeObject(encodedDictionary) as System.Collections.Generic.Dictionary <string, object>;
            if (dictionary == null)
            {
                throw new System.ArgumentException("Invalid request format.", "encodedDictionary");
            }
            foreach (System.Collections.Generic.KeyValuePair <string, object> current in dictionary)
            {
                if (current.Value == null)
                {
                    self.Add(current.Key, null);
                }
                else if (current.Value is object[])
                {
                    self.Add(current.Key, javaScriptSerializer.Serialize(current.Value));
                }
                else
                {
                    self.Add(current.Key, current.Value.ToString());
                }
            }
        }
Esempio n. 2
0
 protected override void InitializeRequiresDictionary(string directiveName, System.Collections.Generic.IDictionary <string, string> requiresDictionary)
 {
     base.InitializeRequiresDictionary(directiveName, requiresDictionary);
     requiresDictionary.Add("GeneratedCodeFolder", "GeneratedCode");
     requiresDictionary.Add("GeneratedResourceFile", "DomainModelResx");
     requiresDictionary.Add("ProjectDefaultNamespace", System.String.Empty);
 }
        public void initialize()
        {
            //kodlama karsiliklari dosyasini oku
            StreamReader reader = new KaynakYukleyici().getReader("kaynaklar/tr/bilgi/kodlama-donusum.txt");
            String       s;

            while ((s = reader.ReadLine()) != null)
            {
                // bos ve # isaretli satirlari atla
                if (s.Length == 0 || s[0] == '#')
                {
                    continue;
                }
                s = toNative(s);
                Char c = s[0];

                //satirdan turkce karaktere karsilik duzen kod cekiliyor. ve bu kod map'a yerletiriliyor
                String kod = s.Substring(2);
                if (donusumler.ContainsKey(c))
                {
                    IList a = donusumler[c];
                    a.Add(kod);
                }
                else
                {
                    IList yeni = new ArrayList();
                    yeni.Add(kod);
                    donusumler.Add(c, yeni);
                }
            }
        }
Esempio n. 4
0
 public static void AddAll(System.Collections.Generic.IDictionary <string, string> hashtable, System.Collections.Generic.ICollection <string> items)
 {
     foreach (string s in items)
     {
         hashtable.Add(s, s);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Adds a new collection, it's assumed to be sorted.
        /// </summary>
        private uint AddCollection(int[] collection)
        {
            uint id;

            if (_collectionReverseIndex != null)
            {
                // check duplicates.
                if (_collectionReverseIndex.TryGetValue(collection, out id))
                { // collection already exists.
                    return(id + 2);
                }
            }

            id = (uint)_collectionIndex.Add(collection);
            if (_index != null)
            { // use next id.
                _index.EnsureMinimumSize(_nextId + 1);
                _index[_nextId] = id;
                id = _nextId;
                _nextId++;
            }

            _collectionReverseIndex?.Add(collection, id);
            return(id + 2);
        }
Esempio n. 6
0
 /// <summary>
 /// 输出数据结构。
 /// </summary>
 /// <returns></returns>
 protected void ToObject(System.Collections.Generic.IDictionary <string, object> o)
 {
     if (_list.Count == 0)
     {
         return;
     }
     o.Add("items", ToObjectList());
 }
Esempio n. 7
0
 public void InheritTypes(TypeMap inheritedTypeMap)
 {
     foreach (var includedDerivedType in inheritedTypeMap._includedDerivedTypes
              .Where(includedDerivedType => !_includedDerivedTypes.Contains(includedDerivedType)))
     {
         _includedDerivedTypes.Add(includedDerivedType);
     }
 }
 public static void Decode(this System.Collections.Generic.IDictionary <string, string> self, string encodedDictionary, char separator, char keyValueSplitter, DictionaryExtension.Encoder keyDecoder, DictionaryExtension.Encoder valueDecoder, bool endsWithSeparator)
 {
     if (encodedDictionary == null)
     {
         throw new System.ArgumentNullException("encodedDictionary");
     }
     if (keyDecoder == null)
     {
         throw new System.ArgumentNullException("keyDecoder");
     }
     if (valueDecoder == null)
     {
         throw new System.ArgumentNullException("valueDecoder");
     }
     if (endsWithSeparator && encodedDictionary.LastIndexOf(separator) == encodedDictionary.Length - 1)
     {
         encodedDictionary = encodedDictionary.Substring(0, encodedDictionary.Length - 1);
     }
     string[] array = encodedDictionary.Split(new char[]
     {
         separator
     });
     for (int i = 0; i < array.Length; i++)
     {
         string   text   = array[i];
         string[] array2 = text.Split(new char[]
         {
             keyValueSplitter
         });
         if ((array2.Length == 1 || array2.Length > 2) && !string.IsNullOrEmpty(array2[0]))
         {
             throw new System.ArgumentException("The request is not properly formatted.", "encodedDictionary");
         }
         if (array2.Length != 2)
         {
             throw new System.ArgumentException("The request is not properly formatted.", "encodedDictionary");
         }
         string text2 = keyDecoder(array2[0].Trim());
         string value = valueDecoder(array2[1].Trim().Trim(new char[]
         {
             '"'
         }));
         try
         {
             self.Add(text2, value);
         }
         catch (System.ArgumentException)
         {
             string message = string.Format(System.Globalization.CultureInfo.InvariantCulture, "The request is not properly formatted. The parameter '{0}' is duplicated.", new object[]
             {
                 text2
             });
             throw new System.ArgumentException(message, "encodedDictionary");
         }
     }
 }
Esempio n. 9
0
 public static void AddAllIfNotContains(System.Collections.Generic.IDictionary <string, string> hashtable, System.Collections.Generic.ICollection <string> items)
 {
     foreach (string s in items)
     {
         if (hashtable.ContainsKey(s) == false)
         {
             hashtable.Add(s, s);
         }
     }
 }
        public static TValue GetOrCreate <TKey, TValue>(this System.Collections.Generic.IDictionary <TKey, TValue> dictionary, TKey key) where TValue : new()
        {
            TValue ret;

            if (!dictionary.TryGetValue(key, out ret))
            {
                ret = new TValue();
                dictionary.Add(key, ret);
            }
            return(ret);
        }
Esempio n. 11
0
 internal static void AddErrors(System.Collections.Generic.IDictionary <string, HashSet <string> > errors, string propertyName, HashSet <string> validationResults)
 {
     if (errors.ContainsKey(propertyName))
     {
         errors[propertyName] = validationResults;
     }
     else
     {
         errors.Add(propertyName, validationResults);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Adds a new string.
        /// </summary>
        private int AddString(string value, bool key)
        {
            int id;

            if ((_mode & AttributesIndexMode.ReverseStringIndex) == AttributesIndexMode.ReverseStringIndex ||
                (((_mode & AttributesIndexMode.ReverseStringIndexKeysOnly) == AttributesIndexMode.ReverseStringIndexKeysOnly) && key))
            {
                if (!_stringReverseIndex.TryGetValue(value, out id))
                { // the key doesn't exist yet.
                    id = (int)_stringIndex.Add(value);
                    _stringReverseIndex.Add(value, id);
                }
                return(id);
            }
            return((int)_stringIndex.Add(value));
        }
Esempio n. 13
0
 protected override void InitializeProvidesDictionary(string directiveName, System.Collections.Generic.IDictionary <string, string> providesDictionary)
 {
     base.InitializeProvidesDictionary(directiveName, providesDictionary);
     providesDictionary.Add("GeneratedResourceName", "GeneratedResourceName");
     providesDictionary.Add("GeneratedNamespace", "GeneratedNamespace");
 }
Esempio n. 14
0
    /// <summary>
    /// Call InitUnit at Monobehavior.Awake().
    /// Put all kinds of data into dictionary.
    /// </summary>
    public void InitUnitData()
    {
        HP = MaxHP;
        if (AttackData != null)
        {
            foreach (AttackData attackData in AttackData)
            {
                AttackDataDict.Add(attackData.Name, attackData);
            }
        }
        if (MoveData != null)
        {
            foreach (MoveData moveData in MoveData)
            {
                MoveDataDict.Add(moveData.Name, moveData);
            }
        }
        if (IdleData != null)
        {
            foreach (IdleData idleData in IdleData)
            {
                IdleDataDict.Add(idleData.Name, idleData);
            }
        }
        if (EffectData != null)
        {
            foreach (EffectData effectData in EffectData)
            {
                EffectDataDict.Add(effectData.Name, effectData);
            }
        }
        if (RotateData != null)
        {
            foreach (RotateData rotateData in RotateData)
            {
                RotateDataDict.Add(rotateData.Name, rotateData);
            }
        }
        if (ReceiveDamageData != null)
        {
            foreach (ReceiveDamageData receiveDamageData in ReceiveDamageData)
            {
                foreach (DamageForm _form in receiveDamageData.ApplicableDamageForm)
                {
                    if (ReceiveDamageDataDict.ContainsKey(_form) == false)
                    {
                        System.Collections.Generic.IList <ReceiveDamageData> L = new System.Collections.Generic.List <ReceiveDamageData> ();
                        L.Add(receiveDamageData);
                        ReceiveDamageDataDict [_form] = L;
                    }
                    else
                    {
                        ReceiveDamageDataDict [_form].Add(receiveDamageData);
                    }
                }
            }
        }

        if (DeathData != null)
        {
            foreach (DeathData dieData in DeathData)
            {
                foreach (DamageForm _damageForm in dieData.ApplicableDamageForm)
                {
                    if (DeathDataDict.ContainsKey(_damageForm) == false)
                    {
                        System.Collections.Generic.IList <DeathData> L = new System.Collections.Generic.List <DeathData> ();
                        L.Add(dieData);
                        DeathDataDict [_damageForm] = L;
                    }
                    else
                    {
                        DeathDataDict [_damageForm].Add(dieData);
                    }
                }
            }
        }

        if (DecalData != null)
        {
            foreach (DecalData decal in DecalData)
            {
                DecalDataDict.Add(decal.Name, decal);
            }
        }

        if (AudioData != null)
        {
            foreach (AudioData audioData in AudioData)
            {
                this.AudioDataDict.Add(audioData.Name, audioData);
            }
        }
    }
Esempio n. 15
0
 public static System.Collections.Generic.IDictionary <string, string> Merger(this System.Collections.Generic.IDictionary <string, string> dictionary, object o, bool nullValueAsKey, ECase keyECase, bool includeInheritedProperty)
 {
     if (o != null)
     {
         if (o is System.Collections.Generic.IDictionary <string, string> )
         {
             System.Collections.Generic.IDictionary <string, string> dictionary2 = o as System.Collections.Generic.IDictionary <string, string>;
             foreach (string text in dictionary2.Keys)
             {
                 if (dictionary.ContainsKey(text.ToUpper()))
                 {
                     dictionary[text.ToUpper()] = dictionary2[text];
                 }
                 else
                 {
                     dictionary.Add(text.ToUpper(), dictionary2[text]);
                 }
             }
         }
         else
         {
             System.Reflection.PropertyInfo[] array  = includeInheritedProperty ? o.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public) : o.GetType().GetProperties(System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
             System.Reflection.PropertyInfo[] array2 = array;
             for (int i = 0; i < array2.Length; i++)
             {
                 System.Reflection.PropertyInfo propertyInfo = array2[i];
                 string text = propertyInfo.Name;
                 if (keyECase == ECase.UPPER)
                 {
                     text = text.ToUpper();
                 }
                 else
                 {
                     if (keyECase == ECase.LOWER)
                     {
                         text = text.ToLower();
                     }
                 }
                 object value = propertyInfo.GetValue(o, null);
                 if (value != null)
                 {
                     if (!dictionary.ContainsKey(text))
                     {
                         dictionary.Add(text, value.ToString());
                     }
                     else
                     {
                         dictionary[text] = value.ToString();
                     }
                 }
                 else
                 {
                     if (nullValueAsKey)
                     {
                         if (!dictionary.ContainsKey(text))
                         {
                             dictionary.Add(text, null);
                         }
                         else
                         {
                             dictionary[text] = null;
                         }
                     }
                 }
             }
         }
     }
     return(dictionary);
 }