public WrappedBaseObject(string variableName, Type type, bool generateMetadata) { this.variableName = variableName; this.dataType = DataTypeHelper.GetWrappedDataTypeFromSystemType(type); bool isArray = type.IsArray; bool isGenericList = TypeUtility.IsGenericList(type); this.attributes = VariableAttributes.None; Type elementType = type; if (isArray || isGenericList) { if (isArray) { this.attributes |= VariableAttributes.IsArray; } else if (isGenericList) { this.attributes |= VariableAttributes.IsList; } elementType = TypeUtility.GetElementType(type); //Debug.Log(elementType); this.dataType = DataTypeHelper.GetWrappedDataTypeFromSystemType(elementType); } if (generateMetadata) { metaData = VariableMetaData.Create(dataType, elementType, attributes); } }
public WrappedVariable(string variableName, object value, Type type, bool generateMetadata) { this.variableName = variableName; this.dataType = DataTypeHelper.GetWrappedDataTypeFromSystemType(type); this.value = value; bool isArray = type.IsArray; bool isGenericList = TypeUtility.IsGenericList(type); this.attributes = VariableAttributes.None; Type elementType = type; if (isArray || isGenericList) { if (isArray) { this.attributes |= VariableAttributes.IsArray; } else if (isGenericList) { this.attributes |= VariableAttributes.IsList; } elementType = TypeUtility.GetElementType(type); //Debug.Log(elementType); this.dataType = DataTypeHelper.GetWrappedDataTypeFromSystemType(elementType); } // Root data type or element type of collection is unknown if (this.dataType == DataType.Unknown) { if (isArray || isGenericList) { IList list = (IList)value; int count = list.Count; List <string> unknownList = new List <string>(count); for (int i = 0; i < count; i++) { unknownList.Add(type.Name); } this.value = unknownList; } else { // Let's just use the type of the value to help us debug this.value = type.Name; } } if (generateMetadata) { metaData = VariableMetaData.Create(dataType, elementType, value, attributes); } }