private static string FormatGroupedTypeName(Type type, ClassGrouping grouping, ClassTypeConstraintAttribute.CustomGroupDelegate customGroupingLogic = null) { switch (grouping) { default: case ClassGrouping.None: return(type.FullName); case ClassGrouping.ByNamespace: return(FormatByNamespace(type)); case ClassGrouping.ByNamespaceFlat: return(FormatByNamespaceFlat(type)); case ClassGrouping.ByAddComponentMenu: return(FormatByAddComponentMenu(type)); case ClassGrouping.Custom: if (customGroupingLogic == null) { return(FormatGroupedTypeName(type, ClassGrouping.ByNamespace)); } else { return(customGroupingLogic(type)); } } }
private static string FormatGroupedTypeName(Type type, ClassGrouping grouping) { string name = type.FullName; switch (grouping) { default: case ClassGrouping.None: return(name); case ClassGrouping.ByNamespace: return(name.Replace('.', '/')); case ClassGrouping.ByNamespaceFlat: int lastPeriodIndex = name.LastIndexOf('.'); if (lastPeriodIndex != -1) { name = name.Substring(0, lastPeriodIndex) + "/" + name.Substring(lastPeriodIndex + 1); } return(name); case ClassGrouping.ByAddComponentMenu: var addComponentMenuAttributes = type.GetCustomAttributes(typeof(AddComponentMenu), false); if (addComponentMenuAttributes.Length == 1) { return(((AddComponentMenu)addComponentMenuAttributes[0]).componentMenu); } return("Scripts/" + type.FullName.Replace('.', '/')); } }
public ActionResult Details(string Id) { ClassGrouping classGrouping = context.Find(Id); if (classGrouping == null) { return(HttpNotFound()); } else { return(View(classGrouping)); } }
private void AddTypes(ClassGrouping classGrouping) { var types = GetFilteredTypes(); AddIncludedTypes(types); RemoveExcludedTypes(types); foreach (var nameTypePair in types) { string menuLabel = TypeNameFormatter.Format(nameTypePair.Value, classGrouping); AddLabelIfNotEmpty(menuLabel, nameTypePair.Value); } }
public ActionResult Create(ClassGrouping classGrouping) { if (!ModelState.IsValid) { return(View(classGrouping)); } else { context.Insert(classGrouping); context.Commit(); return(RedirectToAction("Index")); } }
private static void DisplayDropDown(Rect position, List <Type> types, Type selectedType, ClassTypeConstraintAttribute filter) { var menu = new GenericMenu(); if (filter == null || filter.ShowNoneOption) { menu.AddItem(new GUIContent("(None)"), selectedType == null, s_OnSelectedTypeName, null); menu.AddSeparator(""); } if (filter != null) { foreach (KeyValuePair <Type, string> customDisplay in filter.CustomDisplays) { menu.AddItem(new GUIContent(customDisplay.Value), selectedType == customDisplay.Key, s_OnSelectedTypeName, customDisplay.Key); } } ClassGrouping grouping = ClassGrouping.ByNamespace; if (filter != null) { grouping = filter.Grouping; } for (int i = 0; i < types.Count; ++i) { var type = types[i]; var customLogic = filter == null ? null : filter.CustomGroupingLogic; string menuLabel = FormatGroupedTypeName(type, grouping, customLogic); if (string.IsNullOrEmpty(menuLabel)) { continue; } var content = new GUIContent(menuLabel); menu.AddItem(content, type == selectedType, s_OnSelectedTypeName, type); } menu.DropDown(position); }
public static string Format(Type type, ClassGrouping grouping) { var name = type.FullName ?? string.Empty; switch (grouping) { default: return(name); case ClassGrouping.ByNamespace: return(FormatByNamespace(name)); case ClassGrouping.ByNamespaceFlat: return(FormatByNamespaceFlat(name)); case ClassGrouping.ByAddComponentMenu: return(FormatByAddComponentMenu(type, name)); } }
private static void DisplayDropDown(Rect position, List <Type> types, Type selectedType, ClassGrouping grouping) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("(None)"), selectedType == null, s_OnSelectedTypeName, null); menu.AddSeparator(""); for (int i = 0; i < types.Count; ++i) { var type = types[i]; string menuLabel = FormatGroupedTypeName(type, grouping); if (string.IsNullOrEmpty(menuLabel)) { continue; } var content = new GUIContent(menuLabel); menu.AddItem(content, type == selectedType, s_OnSelectedTypeName, type); } menu.DropDown(position); }
private static void DisplayDropDown(Rect position, List<Type> types, Type selectedType, ClassGrouping grouping) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("(None)"), selectedType == null, s_OnSelectedTypeName, null); menu.AddSeparator(""); for (int i = 0; i < types.Count; ++i) { var type = types[i]; string menuLabel = FormatGroupedTypeName(type, grouping); if (string.IsNullOrEmpty(menuLabel)) continue; var content = new GUIContent(menuLabel); menu.AddItem(content, type == selectedType, s_OnSelectedTypeName, type); } menu.DropDown(position); }
private static string FormatGroupedTypeName(Type type, ClassGrouping grouping) { string name = type.FullName; switch (grouping) { default: case ClassGrouping.None: return name; case ClassGrouping.ByNamespace: return name.Replace('.', '/'); case ClassGrouping.ByNamespaceFlat: int lastPeriodIndex = name.LastIndexOf('.'); if (lastPeriodIndex != -1) name = name.Substring(0, lastPeriodIndex) + "/" + name.Substring(lastPeriodIndex + 1); return name; case ClassGrouping.ByAddComponentMenu: var addComponentMenuAttributes = type.GetCustomAttributes(typeof(AddComponentMenu), false); if (addComponentMenuAttributes.Length == 1) return ((AddComponentMenu)addComponentMenuAttributes[0]).componentMenu; return "Scripts/" + type.FullName.Replace('.', '/'); } }
public ActionResult Create() { ClassGrouping classGrouping = new ClassGrouping(); return(View(classGrouping)); }