示例#1
0
 private void FindVariableUsage(object obj, int currentDepth = 0)
 {
     if (obj != null && currentDepth < 7)
     {
         NamedVariable namedVariable = obj as NamedVariable;
         if (namedVariable != null && namedVariable.get_UsesVariable())
         {
             this.AddVariableUsage(namedVariable);
             return;
         }
         SkillVar fsmVar = obj as SkillVar;
         if (fsmVar != null && !string.IsNullOrEmpty(fsmVar.variableName))
         {
             this.AddVariableUsage(fsmVar.get_NamedVar());
             return;
         }
         if (obj.GetType().get_IsArray())
         {
             Array array = (Array)obj;
             for (int i = 0; i < array.get_Length(); i++)
             {
                 this.FindVariableUsage(array.GetValue(i), currentDepth);
             }
             return;
         }
         IEnumerable <FieldInfo> serializedFields = TypeHelpers.GetSerializedFields(obj.GetType());
         using (IEnumerator <FieldInfo> enumerator = serializedFields.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 FieldInfo current = enumerator.get_Current();
                 SkillSearch.currentInfo.fieldInObject = obj;
                 SkillSearch.currentInfo.field         = current;
                 object value = current.GetValue(obj);
                 this.FindVariableUsage(value, currentDepth + 1);
             }
         }
     }
 }
示例#2
0
 public static IEnumerable <FieldInfo> GetSerializedFields(Type type)
 {
     return(TypeHelpers.GetSerializedFields(type));
 }