Пример #1
0
 public static JSONClass GetFields(MonoHelper source, JSONClass fieldArray)
 {
     System.Type t = source.GetType();
     BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
                             BindingFlags.Static | BindingFlags.Instance |
                             BindingFlags.FlattenHierarchy;
     FieldInfo[] fields = t.GetFields(flags);
     FieldInfo[] badFieldArray = typeof(MonoHelper).GetFields(flags);
     List<string> badFields = new List<string>();
     foreach (FieldInfo field in badFieldArray)
     {
         badFields.Add(field.Name);
     }
     foreach (FieldInfo field in fields)
     {
         object fieldObj = field.GetValue(source);
         if (fieldObj == null)
         {
             continue;
         }
         string fieldName = field.Name;
         if (badFields.Contains(fieldName) || System.Attribute.IsDefined(field, typeof(DontSave)))
         {
             continue;
         }
         JSONClass fieldData = SaveGame.SaveField(fieldObj, fieldName);
         if (fieldData == null)
         {
             continue;
         }
         fieldArray.Add(fieldName, fieldData);
     }
     return fieldArray;
 }