public static bool TryGetCustomDrawerForClass(IDrawerProvider drawerProvider, Type classType, out Type drawerType) { IUseDrawer useDrawerAttribute; if (AttributeUtility.TryGetImplementingAttribute(classType, out useDrawerAttribute)) { drawerType = useDrawerAttribute.GetDrawerType(classType, drawerProvider.GetClassMemberDrawerType(classType), drawerProvider); return(true); } drawerType = null; return(false); }
public static bool TryGetCustomDrawerForClassMember(IDrawerProvider drawerProvider, MemberInfo member, out Type drawerType) { IUseDrawer useDrawerAttribute; if (AttributeUtility.TryGetImplementingAttribute(member, out useDrawerAttribute)) { var declaringType = member.DeclaringType; drawerType = useDrawerAttribute.GetDrawerType(declaringType, drawerProvider.GetClassMemberDrawerType(declaringType), drawerProvider); return(true); } drawerType = null; return(false); }
/// <inheritdoc/> public Type GetClassMemberDrawerType([NotNull] Type fieldType) { return(wrappedProvider.GetClassMemberDrawerType(fieldType)); }
private static void BuildDictionaries(IDrawerProvider drawerProvider, Type[] types) { #if DEV_MODE && DEBUG_BUILD Debug.Log("UseDrawerAttributeUtility.BuildDictionaries - building from " + types.Length + " types..."); #endif for (int t = types.Length - 1; t >= 0; t--) { var type = types[t]; var attributes = type.GetCustomAttributes(false); Compatibility.PluginAttributeConverterProvider.ConvertAll(ref attributes); for (int a = attributes.Length - 1; a >= 0; a--) { var attribute = attributes[a]; var useDrawerAttribute = attribute as IUseDrawer; if (useDrawerAttribute == null) { continue; } var drawerType = useDrawerAttribute.GetDrawerType(type, drawerProvider.GetClassDrawerType(type)); #if DEV_MODE && DEBUG_BUILD Debug.LogError("IUseDrawer: use drawer " + drawerType.Name + " for class " + type.Name); #endif try { drawersByClassType.Add(type, drawerType); } catch (Exception e) { Debug.LogError(e); } } var members = type.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly); for (int m = members.Length - 1; m >= 0; m--) { var member = members[m]; attributes = member.GetCustomAttributes(false); Compatibility.PluginAttributeConverterProvider.ConvertAll(ref attributes); for (int a = attributes.Length - 1; a >= 0; a--) { var useDrawerAttribute = attributes[a] as IUseDrawer; if (useDrawerAttribute == null) { continue; } var memberType = member.DeclaringType; var drawerType = useDrawerAttribute.GetDrawerType(memberType, drawerProvider.GetClassMemberDrawerType(memberType)); #if DEV_MODE && DEBUG_BUILD Debug.Log("IUseDrawer: use drawer " + drawerType.Name + " for class member \"" + member.Name + "\" of class " + type.Name); #endif try { drawersByMember.Add(member, drawerType); } catch (Exception e) { Debug.LogError(e); } } } } }