/// <summary> /// Gets the filter to use for filtering the types. /// </summary> /// <returns>The filter to use for filtering the types.</returns> static Func <Type, bool> CreateTypeFilter() { var filterCreator = new TypeFilterCreator { IsClass = true, IsAbstract = false, Subclass = typeof(TextFilter), ConstructorParameters = Type.EmptyTypes, RequireConstructor = true }; return(filterCreator.GetFilter()); }
/// <summary> /// Initializes the <see cref="Map"/> class. /// </summary> static Map() { // Cache the _checkDynamicEntitiesForIServerSaveableOnly value var filterCreator = new TypeFilterCreator { IsClass = true, Subclass = typeof(Entity), Interfaces = new Type[] { typeof(IServerSaveable) }, CustomFilter = (x => !x.IsSubclassOf(typeof(DynamicEntity))) }; var filter = filterCreator.GetFilter(); _checkDynamicEntitiesForIServerSaveableOnly = TypeHelper.FindTypes(filter, null).IsEmpty(); }
static void AddAdvancedClassTypeConverters() { // Add the types we want to have use the AdvancedClassTypeConverter. This is purely just for // a better PropertyGrid-based editing experience. Since it doesn't really matter if we add too many // types (since it is only really for the PropertyGrid), we just add EVERY table from the DbObjs. var filterCreator = new TypeFilterCreator { IsClass = true, IsAbstract = false, CustomFilter = (x => x.Name.EndsWith("Table") && (x.Namespace ?? string.Empty).Contains("DbObjs")) }; var filter = filterCreator.GetFilter(); var typesToAdd = TypeHelper.FindTypes(filter, null); AdvancedClassTypeConverter.AddTypes(typesToAdd.ToArray()); // Also automatically add all the instantiable types that derive from some of our base classes var baseTypes = new Type[] { typeof(Entity), typeof(MapBase) }; filterCreator = new TypeFilterCreator { IsClass = true, IsAbstract = false, CustomFilter = (x => baseTypes.Any(x.IsSubclassOf)) }; filter = filterCreator.GetFilter(); typesToAdd = TypeHelper.FindTypes(filter, null); AdvancedClassTypeConverter.AddTypes(typesToAdd.ToArray()); // Manually add some other types we want to have use the AdvancedClassTypeConverter. Again, doesn't // really matter what you add here. In general, you should just add to this when you notice that // a PropertyGrid isn't using the AdvancedClassTypeConverter. AdvancedClassTypeConverter.AddTypes(typeof(MutablePair<ItemTemplateID, byte>), typeof(MutablePair<CharacterTemplateID, ushort>), typeof(EditorQuest), typeof(EditorAlliance), typeof(EditorShop), typeof(EditorCharacterTemplate)); // Set the properties we want to force being readonly in the PropertyGrid AdvancedClassTypeConverter.SetForceReadOnlyProperties(typeof(CharacterTemplateTable), "ID"); AdvancedClassTypeConverter.SetForceReadOnlyProperties(typeof(EditorCharacterTemplate), "ID"); AdvancedClassTypeConverter.SetForceReadOnlyProperties(typeof(ItemTemplateTable), "ID"); #if !TOPDOWN // Set the UITypeEditor for specific properties on classes instead of every property with a certain type AdvancedClassTypeConverter.SetForceEditor(typeof(ItemTemplateTable), new KeyValuePair<string, UITypeEditor>("EquippedBody", new BodyPaperDollTypeEditor())); #endif }