Beispiel #1
0
        internal PropertyInfo[] GetProperties(IServiceProvider serviceProvider)
        {
            ArrayList properties = new ArrayList(GetType().GetProperties());

            if (this.property != null)
            {
                properties.Add(new PropertySegmentPropertyInfo(this, this.property));
            }
            else if (this.propertyDescriptor != null)
            {
                properties.Add(new PropertySegmentPropertyInfo(this, this.propertyDescriptor));
            }
            else if (this.obj != null)
            {
                PropertyDescriptorCollection props = null;
                TypeConverter converter            = TypeDescriptor.GetConverter(this.obj);
                if (converter != null && converter.GetPropertiesSupported())
                {
                    DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(this.serviceProvider, GetComponent(this.obj, serviceProvider), null);
                    props = converter.GetProperties(dummyContext, this.obj, new Attribute[] { });
                }
                else
                {
                    props = TypeDescriptor.GetProperties(this.obj);
                }

                foreach (PropertyDescriptor propDesc in props)
                {
                    PropertyInfo propInfo = XomlComponentSerializationService.GetProperty(this.obj.GetType(), propDesc.Name, BindingFlags.Public | BindingFlags.Instance);
                    if (propInfo != null)
                    {
                        if (Helpers.GetSerializationVisibility(propInfo) == DesignerSerializationVisibility.Hidden)
                        {
                            continue;
                        }

                        properties.Add(new PropertySegmentPropertyInfo(this, propInfo));
                    }
                    else
                    {
                        properties.Add(new PropertySegmentPropertyInfo(this, propDesc));
                        if (propDesc.Converter != null)
                        {
                            DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(this.serviceProvider, GetComponent(this.obj, serviceProvider), propDesc);
                            if (propDesc.Converter.GetPropertiesSupported(dummyContext))
                            {
                                foreach (PropertyDescriptor childDesc in propDesc.Converter.GetProperties(dummyContext, this.obj, new Attribute[] { }))
                                {
                                    properties.Add(new PropertySegmentPropertyInfo(this, childDesc));
                                }
                            }
                        }
                    }
                }
            }

            return(properties.ToArray(typeof(PropertyInfo)) as PropertyInfo[]);
        }
Beispiel #2
0
        internal PropertyInfo[] GetProperties(IServiceProvider serviceProvider)
        {
            ArrayList list = new ArrayList(base.GetType().GetProperties());

            if (this.property != null)
            {
                list.Add(new PropertySegmentPropertyInfo(this, this.property));
            }
            else if (this.propertyDescriptor != null)
            {
                list.Add(new PropertySegmentPropertyInfo(this, this.propertyDescriptor));
            }
            else if (this.obj != null)
            {
                PropertyDescriptorCollection properties = null;
                TypeConverter converter = TypeDescriptor.GetConverter(this.obj);
                if ((converter != null) && converter.GetPropertiesSupported())
                {
                    DummyTypeDescriptorContext context = new DummyTypeDescriptorContext(this.serviceProvider, this.GetComponent(this.obj, serviceProvider), null);
                    properties = converter.GetProperties(context, this.obj, new Attribute[0]);
                }
                else
                {
                    properties = TypeDescriptor.GetProperties(this.obj);
                }
                foreach (System.ComponentModel.PropertyDescriptor descriptor in properties)
                {
                    PropertyInfo memberInfo = XomlComponentSerializationService.GetProperty(this.obj.GetType(), descriptor.Name, BindingFlags.Public | BindingFlags.Instance);
                    if (memberInfo != null)
                    {
                        if (Helpers.GetSerializationVisibility(memberInfo) != DesignerSerializationVisibility.Hidden)
                        {
                            list.Add(new PropertySegmentPropertyInfo(this, memberInfo));
                        }
                    }
                    else
                    {
                        list.Add(new PropertySegmentPropertyInfo(this, descriptor));
                        if (descriptor.Converter != null)
                        {
                            DummyTypeDescriptorContext context2 = new DummyTypeDescriptorContext(this.serviceProvider, this.GetComponent(this.obj, serviceProvider), descriptor);
                            if (descriptor.Converter.GetPropertiesSupported(context2))
                            {
                                foreach (System.ComponentModel.PropertyDescriptor descriptor2 in descriptor.Converter.GetProperties(context2, this.obj, new Attribute[0]))
                                {
                                    list.Add(new PropertySegmentPropertyInfo(this, descriptor2));
                                }
                            }
                        }
                    }
                }
            }
            return(list.ToArray(typeof(PropertyInfo)) as PropertyInfo[]);
        }