public static bool ExpandGroup(TypeInfo typeInfo) { ExpandGroupAttribute attr = typeInfo.GetCustomAttribute <ExpandGroupAttribute>(); if (attr != null) { return(attr.Expand); } else { return(true); } }
static void ReflectSettings(Assembly assembly, string inputFilePath, List <Setting> settings, List <Type> enumTypes, Dictionary <string, object> constants, List <SettingGroup> groups) { string filePath = Path.GetFileNameWithoutExtension(inputFilePath); Type settingsType = assembly.GetType(filePath + ".Settings", false); if (settingsType == null) { throw new Exception("Settings file " + inputFilePath + " doesn't define a \"Settings\" class"); } ReflectType(settingsType, settings, enumTypes, constants, ""); Type[] nestedTypes = settingsType.GetNestedTypes(); foreach (Type nestedType in nestedTypes) { string groupName = DisplayNameAttribute.GetDisplayName(nestedType); bool expandGroup = ExpandGroupAttribute.ExpandGroup(nestedType.GetTypeInfo()); groups.Add(new SettingGroup(groupName, expandGroup)); ReflectType(nestedType, settings, enumTypes, constants, groupName); } }