public void HandleAttribute(PropertyAttribute attribute, System.Reflection.FieldInfo field, System.Type propertyType) { if (attribute is TooltipAttribute) this.tooltip = (attribute as TooltipAttribute).tooltip; else if (attribute is ContextMenuItemAttribute) { if (propertyType.IsArrayOrList()) return; if (this.contextMenuItems == null) this.contextMenuItems = new List<ContextMenuItemAttribute>(); this.contextMenuItems.Add(attribute as ContextMenuItemAttribute); } else this.HandleDrawnType(attribute.GetType(), propertyType, field, attribute); }
public void HandleDrawnType(System.Type drawnType, System.Type propertyType, System.Reflection.FieldInfo field, PropertyAttribute attribute) { System.Type drawerTypeForType = ScriptAttributeUtility.GetDrawerTypeForType(drawnType); if (drawerTypeForType == null) return; if (typeof (PropertyDrawer).IsAssignableFrom(drawerTypeForType)) { if (propertyType != null && propertyType.IsArrayOrList()) return; this.m_PropertyDrawer = (PropertyDrawer) Activator.CreateInstance(drawerTypeForType); this.m_PropertyDrawer.m_FieldInfo = field; this.m_PropertyDrawer.m_Attribute = attribute; } else { if (!typeof (DecoratorDrawer).IsAssignableFrom(drawerTypeForType) || field != null && field.FieldType.IsArrayOrList() && !propertyType.IsArrayOrList()) return; DecoratorDrawer instance = (DecoratorDrawer) Activator.CreateInstance(drawerTypeForType); instance.m_Attribute = attribute; if (this.m_DecoratorDrawers == null) this.m_DecoratorDrawers = new List<DecoratorDrawer>(); this.m_DecoratorDrawers.Add(instance); } }
private static System.Reflection.FieldInfo GetFieldInfoFromPropertyPath(System.Type host, string path, out System.Type type) { System.Reflection.FieldInfo fieldInfo1 = (System.Reflection.FieldInfo) null; type = host; string[] strArray = path.Split('.'); for (int index = 0; index < strArray.Length; ++index) { string name = strArray[index]; if (index < strArray.Length - 1 && name == "Array" && strArray[index + 1].StartsWith("data[")) { if (type.IsArrayOrList()) type = type.GetArrayOrListElementType(); ++index; } else { System.Reflection.FieldInfo fieldInfo2 = (System.Reflection.FieldInfo) null; for (System.Type type1 = type; fieldInfo2 == null && type1 != null; type1 = type1.BaseType) fieldInfo2 = type1.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo2 == null) { type = (System.Type) null; return (System.Reflection.FieldInfo) null; } fieldInfo1 = fieldInfo2; type = fieldInfo1.FieldType; } } return fieldInfo1; }