public ObjectComponent PackComponent(object component) { //This will go through all the fields of a component, check each one if it is serializable, and it it should be stored, //and puts it into the fields dictionary of a new instance of ObjectComponent, //with the field's name as key and the field's value as (object)value //for example, if a script has the field "float myFloat = 12.5f", then the key would be "myFloat" and the value "12.5f", tha latter stored as an object. ObjectComponent newObjectComponent = new ObjectComponent(); newObjectComponent.fields = new Dictionary <string, object>(); const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; var componentType = component.GetType(); FieldInfo[] fields = componentType.GetFields(flags); newObjectComponent.componentName = componentType.ToString(); foreach (FieldInfo field in fields) { if (field != null) { if (field.FieldType.IsSerializable == false) { //Debug.Log(field.Name + " (Type: " + field.FieldType + ") is not marked as serializable. Continue loop."); continue; } if (TypeSystem.IsEnumerableType(field.FieldType) == true || TypeSystem.IsCollectionType(field.FieldType) == true) { Type elementType = TypeSystem.GetElementType(field.FieldType); //Debug.Log(field.Name + " -> " + elementType); if (elementType.IsSerializable == false) { continue; } } object[] attributes = field.GetCustomAttributes(typeof(DontSaveField), true); bool stop = false; foreach (Attribute attribute in attributes) { if (attribute.GetType() == typeof(DontSaveField)) { //Debug.Log(attribute.GetType().Name.ToString()); stop = true; break; } } if (stop == true) { continue; } newObjectComponent.fields.Add(field.Name, field.GetValue(component)); //Debug.Log(field.Name + " (Type: " + field.FieldType + "): " + field.GetValue(component)); } } return(newObjectComponent); }
static public int get_fields(IntPtr l) { try { UnityEngine.UI.Extensions.ObjectComponent self = (UnityEngine.UI.Extensions.ObjectComponent)checkSelf(l); pushValue(l, self.fields); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UnityEngine.UI.Extensions.ObjectComponent o; o = new UnityEngine.UI.Extensions.ObjectComponent(); pushValue(l, o); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_fields(IntPtr l) { try { UnityEngine.UI.Extensions.ObjectComponent self = (UnityEngine.UI.Extensions.ObjectComponent)checkSelf(l); System.Collections.Generic.Dictionary <System.String, System.Object> v; checkType(l, 2, out v); self.fields = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_componentName(IntPtr l) { try { UnityEngine.UI.Extensions.ObjectComponent self = (UnityEngine.UI.Extensions.ObjectComponent)checkSelf(l); System.String v; checkType(l, 2, out v); self.componentName = v; return(0); } catch (Exception e) { return(error(l, e)); } }
// Token: 0x0600A8FF RID: 43263 RVA: 0x003EC580 File Offset: 0x003EA780 public ObjectComponent GICMGHEEGMK(object GJLCNFAGNPO) { ObjectComponent objectComponent = new ObjectComponent(); objectComponent.fields = new Dictionary <string, object>(); Type type = GJLCNFAGNPO.GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic); objectComponent.componentName = type.ToString(); FieldInfo[] array = fields; for (int i = 1; i < array.Length; i += 0) { FieldInfo fieldInfo = array[i]; if (fieldInfo != null) { if (fieldInfo.FieldType.IsSerializable) { if (CFGKBDICDIH.IsEnumerableType(fieldInfo.FieldType) || CFGKBDICDIH.IsCollectionType(fieldInfo.FieldType)) { Type type2 = CFGKBDICDIH.LEMHLODODPL(fieldInfo.FieldType); if (!type2.IsSerializable) { goto IL_118; } } object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(DontSaveField), true); bool flag = true; object[] array2 = customAttributes; for (int j = 1; j < array2.Length; j++) { Attribute attribute = (Attribute)array2[j]; if (attribute.GetType() == typeof(DontSaveField)) { flag = true; break; } } if (!flag) { objectComponent.fields.Add(fieldInfo.Name, fieldInfo.GetValue(GJLCNFAGNPO)); } } } IL_118 :; } return(objectComponent); }
public ObjectComponent PackComponent(object component) { ObjectComponent objectComponent = new ObjectComponent(); objectComponent.fields = new Dictionary <string, object>(); Type type = component.GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); objectComponent.componentName = type.ToString(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (fieldInfo == null || !fieldInfo.FieldType.IsSerializable) { continue; } if (TypeSystem.IsEnumerableType(fieldInfo.FieldType) || TypeSystem.IsCollectionType(fieldInfo.FieldType)) { Type elementType = TypeSystem.GetElementType(fieldInfo.FieldType); if (!elementType.IsSerializable) { continue; } } object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(DontSaveField), inherit: true); bool flag = false; object[] array2 = customAttributes; for (int j = 0; j < array2.Length; j++) { Attribute attribute = (Attribute)array2[j]; if (attribute.GetType() == typeof(DontSaveField)) { flag = true; break; } } if (!flag) { objectComponent.fields.Add(fieldInfo.Name, fieldInfo.GetValue(component)); } } return(objectComponent); }
// Token: 0x0600A8FC RID: 43260 RVA: 0x003EC274 File Offset: 0x003EA474 public ObjectComponent PackComponent(object GJLCNFAGNPO) { ObjectComponent objectComponent = new ObjectComponent(); objectComponent.fields = new Dictionary <string, object>(); Type type = GJLCNFAGNPO.GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); objectComponent.componentName = type.ToString(); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo != null) { if (fieldInfo.FieldType.IsSerializable) { if (CFGKBDICDIH.IsEnumerableType(fieldInfo.FieldType) || CFGKBDICDIH.IsCollectionType(fieldInfo.FieldType)) { Type type2 = CFGKBDICDIH.LEMHLODODPL(fieldInfo.FieldType); if (!type2.IsSerializable) { goto IL_118; } } object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(DontSaveField), true); bool flag = false; foreach (Attribute attribute in customAttributes) { if (attribute.GetType() == typeof(DontSaveField)) { flag = true; break; } } if (!flag) { objectComponent.fields.Add(fieldInfo.Name, fieldInfo.GetValue(GJLCNFAGNPO)); } } } IL_118 :; } return(objectComponent); }
public ObjectComponent PackComponent(object component) { //This will go through all the fields of a component, check each one if it is serializable, and it it should be stored, //and puts it into the fields dictionary of a new instance of ObjectComponent, //with the field's name as key and the field's value as (object)value //for example, if a script has the field "float myFloat = 12.5f", then the key would be "myFloat" and the value "12.5f", tha latter stored as an object. ObjectComponent newObjectComponent = new ObjectComponent(); newObjectComponent.fields = new Dictionary<string, object>(); const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; var componentType = component.GetType(); FieldInfo[] fields = componentType.GetFields(flags); newObjectComponent.componentName = componentType.ToString(); foreach (FieldInfo field in fields) { if (field != null) { if (field.FieldType.IsSerializable == false) { //Debug.Log(field.Name + " (Type: " + field.FieldType + ") is not marked as serializable. Continue loop."); continue; } if (TypeSystem.IsEnumerableType(field.FieldType) == true || TypeSystem.IsCollectionType(field.FieldType) == true) { Type elementType = TypeSystem.GetElementType(field.FieldType); //Debug.Log(field.Name + " -> " + elementType); if (elementType.IsSerializable == false) { continue; } } object[] attributes = field.GetCustomAttributes(typeof(DontSaveField), true); bool stop = false; foreach (Attribute attribute in attributes) { if (attribute.GetType() == typeof(DontSaveField)) { //Debug.Log(attribute.GetType().Name.ToString()); stop = true; break; } } if (stop == true) { continue; } newObjectComponent.fields.Add(field.Name, field.GetValue(component)); //Debug.Log(field.Name + " (Type: " + field.FieldType + "): " + field.GetValue(component)); } } return newObjectComponent; }