本文整理汇总了C#中System.ComponentModel.TypeDescriptor.GetProperties方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDescriptor.GetProperties方法的具体用法?C# TypeDescriptor.GetProperties怎么用?C# TypeDescriptor.GetProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了TypeDescriptor.GetProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
// Returns the properties of the specified component extended with
// a CategoryAttribute reflecting the name of the type of the property.
public override System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes)
{
PropertyDescriptorCollection props;
if( attributes == null )
props = TypeDescriptor.GetProperties(component);
else
props = TypeDescriptor.GetProperties(component, attributes);
PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count];
for(int i=0; i<props.Count; i++)
{
// Create a new PropertyDescriptor from the old one, with
// a CategoryAttribute matching the name of the type.
propArray[i] = TypeDescriptor.CreateProperty(props[i].ComponentType, props[i], new CategoryAttribute(props[i].PropertyType.Name));
}
return new PropertyDescriptorCollection( propArray );
}
public override System.ComponentModel.PropertyDescriptorCollection GetProperties(object component)
{
return this.GetProperties(component, null);
}
示例2: return
// This is the shadowed property on the designer.
// This value will be serialized instead of the
// value of the control's property.
public Color BackColor
{
get
{
return (Color)ShadowProperties["BackColor"];
}
set
{
if (this.changeService != null)
{
PropertyDescriptor backColorDesc =
TypeDescriptor.GetProperties(this.Control)["BackColor"];
this.changeService.OnComponentChanging(
this.Control,
backColorDesc);
this.ShadowProperties["BackColor"] = value;
this.changeService.OnComponentChanged(
this.Control,
backColorDesc,
null,
null);
}
}
}