Exemplo n.º 1
0
        void AddTypeDescriptors()
        {
            var dtd = DynamicTypeDescriptor.Install(typeof(OxyColor));

            dtd.SetConverter(new OxyColorConverter());
            TypeDescriptor.Refresh(typeof(OxyColor));
        }
Exemplo n.º 2
0
            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();
            }
Exemplo n.º 3
0
            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
            {
                if (instance != null)
                {
                    ICustomTypeDescriptor perInstance;
                    perInstanceMap.TryGetValue(instance, out perInstance);
                    if (perInstance != null)
                    {
                        return(perInstance);
                    }
                }
                DynamicTypeDescriptor ret;

                if (!map.TryGetValue(objectType, out ret))
                {
                    map.Add(objectType, ret = new DynamicTypeDescriptor(objectType, parentProvider.GetTypeDescriptor(objectType)));
                }
                return(ret);
            }