コード例 #1
0
        public void SetValue <T>(string key, T value)
        {
            Type   type     = typeof(T);
            object newValue = value;

            if (type == typeof(Enum) || type.IsSubclassOf(typeof(Enum)))
            {
                type     = typeof(string);
                newValue = value.ToString();
            }
            int  index  = args_list.FindIndex(item => { return(item.key == key); });
            bool hasKey = index != -1;

            if (hasKey)
            {
                args_list[index].value.SetValueByType(typeof(T), newValue);
            }
            else
            {
                StrValueBasePair pair = new StrValueBasePair();
                pair.key   = key;
                pair.value = new ValueBase();
                pair.value.SetValueByType(typeof(T), newValue);
                args_list.Add(pair);
            }
            if (!args_dict.ContainsKey(key))
            {
                args_dict.Add(key, new ValueBase());
            }
            args_dict[key].SetValueByType(typeof(T), newValue);
        }
コード例 #2
0
 public void OnBeforeSerialize()
 {
     this.args_list.Clear();
     foreach (var item in this.args_dict)
     {
         StrValueBasePair value = new StrValueBasePair();
         value.key   = item.Key;
         value.value = item.Value;
         this.args_list.Add(value);
     }
 }