void AddTypeDescriptors() { var dtd = DynamicTypeDescriptor.Install(typeof(OxyColor)); dtd.SetConverter(new OxyColorConverter()); TypeDescriptor.Refresh(typeof(OxyColor)); }
static SeriesTypeConverter() { // Find all the series types var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetExportedTypes() .Where(t => t.IsSubclassOf(typeof(Series)) && !t.IsAbstract)) .Where(t => t != typeof(FunctionSeries)) .ToArray(); // Hide all the properties we're not interested in foreach (var type in types) { var dtd = DynamicTypeDescriptor.Install(type); foreach (var prop in dtd.GetProperties()) { var dprop = (DynamicPropertyDescriptor)prop; if (dprop.IsReadOnly || dprop.PropertyType.IsSubclassOf(typeof(Delegate)) || dprop.PropertyType == typeof(object) || dprop.Name == "Parent" || dprop.Name.EndsWith("Field")) { dprop.SetIsBrowsable(false); } } } // Create the name mapping map = types.ToDictionary(ToString, t => (Series)Activator.CreateInstance(t)); names = types.Select(ToString).ToArray(); }