Esempio n. 1
0
 public static void CheckReferences(Behavior behavior, List <Task> taskList)
 {
     for (int i = 0; i < taskList.Count; i++)
     {
         TaskReferences.CheckReferences(behavior, taskList[i], taskList);
     }
 }
Esempio n. 2
0
 private static void CheckReferences(BehaviorSource behaviorSource, Task task)
 {
     FieldInfo[] allFields = TaskUtility.GetAllFields(task.GetType());
     for (int i = 0; i < allFields.Length; i++)
     {
         if (!allFields[i].FieldType.IsArray && (allFields[i].FieldType.Equals(typeof(Task)) || allFields[i].FieldType.IsSubclassOf(typeof(Task))))
         {
             Task task2 = allFields[i].GetValue(task) as Task;
             if (task2 != null)
             {
                 Task task3 = TaskReferences.FindReferencedTask(behaviorSource, task2);
                 if (task3 != null)
                 {
                     allFields[i].SetValue(task, task3);
                 }
             }
         }
         else if (allFields[i].FieldType.IsArray && (allFields[i].FieldType.GetElementType().Equals(typeof(Task)) || allFields[i].FieldType.GetElementType().IsSubclassOf(typeof(Task))))
         {
             Task[] array = allFields[i].GetValue(task) as Task[];
             if (array != null)
             {
                 IList list = Activator.CreateInstance(typeof(List <>).MakeGenericType(new Type[]
                 {
                     allFields[i].FieldType.GetElementType()
                 })) as IList;
                 for (int j = 0; j < array.Length; j++)
                 {
                     Task task4 = TaskReferences.FindReferencedTask(behaviorSource, array[j]);
                     if (task4 != null)
                     {
                         list.Add(task4);
                     }
                 }
                 Array array2 = Array.CreateInstance(allFields[i].FieldType.GetElementType(), list.Count);
                 list.CopyTo(array2, 0);
                 allFields[i].SetValue(task, array2);
             }
         }
     }
     if (task.GetType().IsSubclassOf(typeof(ParentTask)))
     {
         ParentTask parentTask = task as ParentTask;
         if (parentTask.Children != null)
         {
             for (int k = 0; k < parentTask.Children.Count; k++)
             {
                 TaskReferences.CheckReferences(behaviorSource, parentTask.Children[k]);
             }
         }
     }
 }
Esempio n. 3
0
 public static void CheckReferences(BehaviorSource behaviorSource)
 {
     if (behaviorSource.RootTask != null)
     {
         TaskReferences.CheckReferences(behaviorSource, behaviorSource.RootTask);
     }
     if (behaviorSource.DetachedTasks != null)
     {
         for (int i = 0; i < behaviorSource.DetachedTasks.Count; i++)
         {
             TaskReferences.CheckReferences(behaviorSource, behaviorSource.DetachedTasks[i]);
         }
     }
 }