public UserPropertyDrawer GetPropertyDrawer(Type propertyType) { UserPropertyDrawer drawer = null; if (mPropertyDrawers.Count == 0) { var customTypes = CoreUtil.FindSubTypes(typeof(UserPropertyDrawer)); foreach (var type in customTypes) { var attributes = type.GetCustomAttributes(typeof(UserPropertyDrawerAttribute), true); var drawerType = attributes.Length > 0 ? ((UserPropertyDrawerAttribute)attributes[0]).type : null; if (drawerType != null) { var instance = (UserPropertyDrawer)CoreUtil.CreateInstance(type, null); mPropertyDrawers.Add(drawerType, instance); } } } if (propertyType.IsArray) { drawer = mPropertyDrawers[typeof(Array)]; } else if (mPropertyDrawers.ContainsKey(propertyType)) { drawer = mPropertyDrawers[propertyType]; } return(drawer); }
public UserDrawer GetUserDrawer(Type leafType) { if (mUserDrawers.Count == 0) { var customTypes = CoreUtil.FindSubTypes(typeof(UserDrawer)); foreach (var type in customTypes) { var attributes = type.GetCustomAttributes(typeof(UserDrawerAttribute), true); var drawerType = attributes.Length > 0 ? ((UserDrawerAttribute)attributes[0]).type : null; if (drawerType != null) { var instance = (UserDrawer)CoreUtil.CreateInstance(type, null); mUserDrawers.Add(drawerType, instance); } } } if (!mUserDrawers.ContainsKey(leafType)) { mUserDrawers.Add(leafType, new UserDrawer()); } return(mUserDrawers[leafType]); }