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 void cleanDataStructures() { unityASPVariationNames = new Dictionary <string, string>(); floatingPointProperties = new Dictionary <string, double>(); unsignedIntegerProperties = new Dictionary <string, ulong>(); signedIntegerProperties = new Dictionary <string, long>(); boolProperties = new Dictionary <string, bool>(); stringProperties = new Dictionary <string, string>(); charProperties = new Dictionary <string, char>(); //enumProperties = new Dictionary<string, Enum>(); dictionaryPerType = new Dictionary <Type, IDictionary>(); foreach (Type t in ReflectionExecutor.SignedIntegerTypes()) { dictionaryPerType.Add(t, signedIntegerProperties); } foreach (Type t in ReflectionExecutor.UnsignedIntegerTypes()) { dictionaryPerType.Add(t, unsignedIntegerProperties); } foreach (Type t in ReflectionExecutor.FloatingPointTypes()) { dictionaryPerType.Add(t, floatingPointProperties); } dictionaryPerType.Add(typeof(bool), boolProperties); dictionaryPerType.Add(typeof(string), stringProperties); // dictionaryPerType.Add(typeof(Enum), enumProperties); dictionaryPerType.Add(typeof(char), charProperties); }
static SensorsUtility() { actualMonoBehaviourSensor = new Dictionary <Type, Type>(); foreach (Type t in ReflectionExecutor.GetAvailableBasicTypes()) { if (ReflectionExecutor.SignedIntegerTypes().Contains(t)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourSignedIntegerSensor)); } else if (ReflectionExecutor.UnsignedIntegerTypes().Contains(t)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourUnsignedIntegerSensor)); } else if (ReflectionExecutor.FloatingPointTypes().Contains(t)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourFloatingPointSensor)); } else if (t == typeof(bool)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourBoolSensor)); } else if (t == typeof(char)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourCharSensor)); } else if (t == typeof(Enum)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourEnumSensor)); } else if (t == typeof(string)) { actualMonoBehaviourSensor.Add(t, typeof(MonoBehaviourStringSensor)); } } }
public SimpleSensor(SensorConfiguration s) { Debug.Log("configuration " + s); sensorName = s.configurationName; properties = new List <string>(); mappingManager = MappingManager.getInstance(); ReflectionExecutor re = ScriptableObject.CreateInstance <ReflectionExecutor>(); gO = re.GetGameObjectWithName(s.gOName); Debug.Log("game object is " + gO); gOName = s.gOName; cleanDataStructures(); properties.AddRange(s.properties.Distinct()); foreach (StringIntPair p in s.operationPerProperty) { operationPerProperty.Add(p.Key, p.Value); //Debug.Log(p.Key + " " + p.Value); if (p.Value == Operation.SPECIFIC) { foreach (StringStringPair pair2 in s.specificValuePerProperty) { //Debug.Log(pair2.Key + " " + pair2.Value); if (pair2.Key.Equals(p.Key)) { specificValuePerProperty.Add(p.Key, pair2.Value); break; } } } } //UpdateProperties(); }
public string propertyType; //ARRAY2, LIST public SimpleGameObjectsTracker(Type type) { Type listType = ReflectionExecutor.isListOfType(type); //MyDebugger.MyDebug("is of type " + listType); if (!(listType is null)) { propertyType = "LIST"; objType = listType.AssemblyQualifiedName; name = listType.ToString(); }
public string propertyType; //ARRAY2, LIST public SimpleGameObjectsTracker(Type type) { ReflectionExecutor re = ScriptableObject.CreateInstance <ReflectionExecutor>(); Type listType = re.isListOfType(type); //Debug.Log("is of type " + listType); if (!(listType is null)) { propertyType = "LIST"; objType = listType.AssemblyQualifiedName; name = listType.ToString(); }
public SimpleActuator(List <string> propertiesToTrack, object obj)//ONLY FOR BASIC TYPE PROPERTIES IN OBJ { gO = obj; gOName = ""; actuatorName = obj.GetType().ToString(); cleanDataStructures(); properties = new List <string>(); properties.AddRange(propertiesToTrack); ReflectionExecutor re = ScriptableObject.CreateInstance <ReflectionExecutor>(); cleanDataStructures(); populateDataStructures(); }
public SimpleSensor(List <string> propertiesToTrack, string name, object obj)//ONLY FOR BASIC TYPE PROPERTIES IN OBJ { gO = obj; gOName = ""; sensorName = name; cleanDataStructures(); properties = new List <string>(); properties.AddRange(propertiesToTrack.Distinct()); mappingManager = MappingManager.getInstance(); ReflectionExecutor re = ScriptableObject.CreateInstance <ReflectionExecutor>(); init(); }
internal static void avg() { Type valuesType = values.GetType().GetGenericArguments()[0]; if (ReflectionExecutor.SignedIntegerTypes().Contains(valuesType)) { longAvg(); } else if (ReflectionExecutor.FloatingPointTypes().Contains(valuesType)) { doubleAvg(); } else if (ReflectionExecutor.UnsignedIntegerTypes().Contains(valuesType)) { unsignedAvg(); } }
public SimpleActuator(ActuatorConfiguration s) { actuatorName = s.configurationName; properties = new List <string>(); gO = ReflectionExecutor.GetGameObjectWithName(s.gOName); // MyDebugger.MyDebug(s.gOName); // MyDebugger.MyDebug(gO); gOName = s.gOName; cleanDataStructures(); foreach (string st in s.properties) { if (!properties.Contains(st)) { properties.Add(st); } } populateDataStructures(); }
public SimpleActuator(ActuatorConfiguration s) { actuatorName = s.configurationName; properties = new List <string>(); ReflectionExecutor re = ScriptableObject.CreateInstance <ReflectionExecutor>(); gO = re.GetGameObjectWithName(s.gOName); // Debug.Log(s.gOName); // Debug.Log(gO); gOName = s.gOName; cleanDataStructures(); foreach (string st in s.properties) { if (!properties.Contains(st)) { properties.Add(st); } } populateDataStructures(); }
static Operation() { operationsPerType = new Dictionary <Type, Type>(); actionPerOperation = new Dictionary <Type, Dictionary <int, Action> >(); operationsPerType.Add(typeof(bool), typeof(boolOperations)); operationsPerType.Add(typeof(string), typeof(stringOperations)); foreach (Type t in ReflectionExecutor.SignedIntegerTypes()) { operationsPerType.Add(t, typeof(numericOperations)); } foreach (Type t in ReflectionExecutor.UnsignedIntegerTypes()) { operationsPerType.Add(t, typeof(numericOperations)); } foreach (Type t in ReflectionExecutor.FloatingPointTypes()) { operationsPerType.Add(t, typeof(numericOperations)); } operationsPerType.Add(typeof(Enum), typeof(stringOperations)); operationsPerType.Add(typeof(char), typeof(stringOperations)); actionPerOperation.Add(typeof(stringOperations), new Dictionary <int, Action>()); actionPerOperation.Add(typeof(boolOperations), new Dictionary <int, Action>()); actionPerOperation.Add(typeof(numericOperations), new Dictionary <int, Action>()); actionPerOperation.Add(typeof(matrixOperations), new Dictionary <int, Action>()); actionPerOperation[typeof(numericOperations)].Add(0, newest); actionPerOperation[typeof(numericOperations)].Add(1, oldest); actionPerOperation[typeof(numericOperations)].Add(2, specificValue); actionPerOperation[typeof(numericOperations)].Add(3, max); actionPerOperation[typeof(numericOperations)].Add(4, min); actionPerOperation[typeof(numericOperations)].Add(5, avg); actionPerOperation[typeof(matrixOperations)].Add(0, allMatrix); actionPerOperation[typeof(boolOperations)].Add(0, newest); actionPerOperation[typeof(boolOperations)].Add(1, oldest); actionPerOperation[typeof(boolOperations)].Add(2, specificValue); actionPerOperation[typeof(boolOperations)].Add(3, conjunction); actionPerOperation[typeof(boolOperations)].Add(4, disjunction); actionPerOperation[typeof(stringOperations)].Add(0, newest); actionPerOperation[typeof(stringOperations)].Add(1, oldest); actionPerOperation[typeof(stringOperations)].Add(2, specificValue); }
public void populate() { mappers.Add(typeof(SimpleSensor), ASPSimpleSensorMapper.getInstance()); mappers.Add(typeof(AdvancedSensor), ASPAdvancedSensorMapper.getInstance()); mappers.Add(typeof(SimpleActuator), ASPActuatorMapper.getInstance()); mappers.Add(typeof(bool), ASPBoolMapper.getInstance()); foreach (Type t in ReflectionExecutor.SignedIntegerTypes()) { mappers.Add(t, ASPSignedIntegerMapper.getInstance()); } foreach (Type t in ReflectionExecutor.UnsignedIntegerTypes()) { mappers.Add(t, ASPUnsignedIntegerMapper.getInstance()); } foreach (Type t in ReflectionExecutor.FloatingPointTypes()) { mappers.Add(t, ASPFloatingPointMapper.getInstance()); } mappers.Add(typeof(string), ASPStringMapper.getInstance()); mappers.Add(typeof(Enum), ASPEnumMapper.getInstance()); mappers.Add(typeof(char), ASPCharMapper.getInstance()); }
public List <FieldOrProperty> GetFieldsAndProperties(object gO) { return(ReflectionExecutor.GetFieldsAndProperties(gO)); }
public bool IsMappable(FieldOrProperty obj) { return(ReflectionExecutor.isMappable(obj)); }
public int IsArrayOfRank(FieldOrProperty obj) { return(ReflectionExecutor.isArrayOfRank(obj)); }
internal Type TypeOf(FieldOrProperty f) { return(ReflectionExecutor.TypeOf(f)); }
public GameObjectsTracker() { re = ScriptableObject.CreateInstance <ReflectionExecutor>(); updateGameObjects(); }
public void updateGameObjects() { AvailableGameObjects = ReflectionExecutor.GetGameObjects(); }
public GameObject GetGameObject(string chosenGO) { return(ReflectionExecutor.GetGameObjectWithName(chosenGO)); }
public List <Component> GetComponents(GameObject gO) { return(ReflectionExecutor.GetComponents(gO)); }
public bool IsBaseType(FieldOrProperty obj) { return(ReflectionExecutor.IsBaseType(obj)); }