private object[] ReadSimpleListProperty(string path, string collectionElementProperty, Type type, object obj, int i)
 {
     object[] toReturn  = new object[3];
     object[] listValue = SensorsUtility.GetListProperty(path, collectionElementProperty, type, obj, i);
     if (listValue[0] != null && listValue[1] != null)
     {
         FieldOrProperty toRead = (FieldOrProperty)listValue[1];
         IList           list   = (IList)listValue[0];
         toReturn[0] = toRead.GetValue(list[i]).GetType(); //Property type of the element of the collection
         toReturn[1] = list.Count;
         toReturn[2] = list[i].GetType();                  //Collection Element Type
         return(toReturn);
     }
     else if (listValue[0] != null)
     {
         toReturn[1] = 0;
         toReturn[2] = listValue[0].GetType().GetGenericArguments()[0];
         foreach (FieldOrProperty member in ReflectionExecutor.GetFieldsAndProperties(toReturn[2]))
         {
             if (member.Name().Equals(currentSubProperty))
             {
                 toReturn[0] = member.Type();
                 return(toReturn);
             }
         }
     }
     return(null);
 }
 private object[] ReadSimpleArrayProperty(string path, string collectionElementProperty, Type type, object obj, int i, int j)
 {
     object[] matrixValue = SensorsUtility.GetArrayProperty(path, collectionElementProperty, type, obj, i, j);//matrixValue[0] is the actual matrix, matrixValue[1] is the Property
     object[] toReturn    = new object[4];
     if (matrixValue[0] != null && matrixValue[1] != null)
     {
         MyDebugger.MyDebug("READING THE MATRIX!");
         FieldOrProperty toRead = (FieldOrProperty)matrixValue[1];
         Array           matrix = (Array)matrixValue[0];
         toReturn[0] = toRead.GetValue(matrix.GetValue(i, j)).GetType(); //Property type of the element of the collection
         toReturn[1] = matrix.GetLength(0);
         toReturn[2] = matrix.GetLength(1);
         toReturn[3] = matrix.GetValue(i, j).GetType(); //Collection Element Type
         MyDebugger.MyDebug("LENGTH " + toReturn[1] + " " + toReturn[2]);
         return(toReturn);
     }
     else if (matrixValue[0] != null)
     {
         toReturn[1] = 0;
         toReturn[2] = 0;
         toReturn[3] = matrixValue[0].GetType().GetGenericArguments()[0];
         foreach (FieldOrProperty member in ReflectionExecutor.GetFieldsAndProperties(toReturn[3]))
         {
             if (member.Name().Equals(currentSubProperty))
             {
                 toReturn[0] = member.Type();
                 return(toReturn);
             }
         }
     }
     return(null);
 }
 public object[] ReadProperty(string _path)
 {
     object[] toReturn = null;
     if (!_path.Contains("^"))
     {
         MyDebugger.MyDebug("SIMPLE PROPERTY");
         toReturn    = new object[1];
         toReturn[0] = ReadSimpleValueProperty(_path, typeof(GameObject), gameObject);
     }
     else
     {
         MyDebugger.MyDebug("COMPOSED PROPERTY");
         toReturn = (object[])SensorsUtility.ReadComposedProperty(gameObject, _path, _path, typeof(GameObject), gameObject, ReadSimplePropertyMethod);
     }
     return(toReturn);
 }
    public void ReadProperty()
    {
        lock (toLock)
        {
            if (!_path.Contains("^"))
            {
                ReadSimplePropertyMethod(_path, typeof(GameObject), gameObject);
            }
            else
            {
                SensorsUtility.ReadComposedProperty(gameObject, _path, _path, typeof(GameObject), gameObject, ReadSimplePropertyMethod);
            }

            dataAvailable = true;
        }
    }
    private void ReadSimpleListProperty(string path, Type type, object obj)
    {
        object[] listValue = SensorsUtility.GetListProperty(path, collectionElementProperty, type, obj, indexes[0]);
        if (listValue[0] != null && listValue[1] != null)
        {
            FieldOrProperty toRead = (FieldOrProperty)listValue[1];
            IList           list   = (IList)listValue[0];

            propertyValues.Add((T)Convert.ChangeType(toRead.GetValue(list[indexes[0]]), typeof(T)));
        }

        else
        {
            MyDebugger.MyDebug("Destroing " + path);
            SensorsManager.GetInstance().removeSensor(brain, this);
            Destroy(this);
            return;
        }
    }
    private void ReadSimpleArrayProperty(string path, Type type, object obj)
    {
        //MyDebugger.MyDebug("READING");

        object[] matrixValue = SensorsUtility.GetArrayProperty(path, collectionElementProperty, type, obj, indexes[0], indexes[1]);
        //MyDebugger.MyDebug("Matrix: " + matrixValue[0]);
        //MyDebugger.MyDebug("Property: " + matrixValue[1]);
        if (matrixValue[0] != null && matrixValue[1] != null)
        {
            FieldOrProperty toRead = (FieldOrProperty)matrixValue[1];
            Array           matrix = (Array)matrixValue[0];

            //MyDebugger.MyDebug("Casting " + toRead.GetValue(matrix.GetValue(indexes[0], indexes[1])).GetType() + " to " + typeof(T));
            propertyValues.Add((T)Convert.ChangeType(toRead.GetValue(matrix.GetValue(indexes[0], indexes[1])), typeof(T)));
        }
        else
        {
            SensorsManager.GetInstance().removeSensor(brain, this);
            Destroy(this);
            return;
        }
    }