public void OnAfterDeserialize()
 {
     foreach ((FieldInfo fi, Type type) in _fields)
     {
         if (fi.FieldType == typeof(bool))
         {
             if (BoolValues.TryGetValue($"{type.Name}:{fi.Name}", out bool val))
             {
                 fi.SetValue(null, val);
             }
         }
         else if (fi.FieldType == typeof(float))
         {
             if (FloatValues.TryGetValue($"{type.Name}:{fi.Name}", out float val))
             {
                 fi.SetValue(null, val);
             }
         }
         else if (fi.FieldType == typeof(int))
         {
             if (IntValues.TryGetValue($"{type.Name}:{fi.Name}", out int val))
             {
                 fi.SetValue(null, val);
             }
         }
     }
 }
Exemplo n.º 2
0
        public void OnAfterDeserialize()
        {
            foreach (KeyValuePair <FieldInfo, Type> pair in _fields)
            {
                FieldInfo fi = pair.Key;

                if (fi.FieldType == typeof(bool))
                {
                    if (BoolValues.TryGetValue($"{pair.Value.Name}:{fi.Name}", out bool val))
                    {
                        fi.SetValue(null, val);
                    }
                }
                else if (fi.FieldType == typeof(float))
                {
                    if (FloatValues.TryGetValue($"{pair.Value.Name}:{fi.Name}", out float val))
                    {
                        fi.SetValue(null, val);
                    }
                }
                else if (fi.FieldType == typeof(int))
                {
                    if (IntValues.TryGetValue($"{pair.Value.Name}:{fi.Name}", out int val))
                    {
                        fi.SetValue(null, val);
                    }
                }
            }
        }