本文整理汇总了C#中System.ComponentModel.PropertyDescriptorCollection类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptorCollection类的具体用法?C# PropertyDescriptorCollection怎么用?C# PropertyDescriptorCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDescriptorCollection类属于System.ComponentModel命名空间,在下文中一共展示了PropertyDescriptorCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection descriptorCollection = new PropertyDescriptorCollection((PropertyDescriptor[])null);
foreach (PropertyDescriptor parent in TypeDescriptor.GetProperties(this.component, attributes, false))
descriptorCollection.Add((PropertyDescriptor)new ReadOnlyPropertyDescriptor(parent));
return descriptorCollection;
}
示例2: AddProperty
public PropertyDescriptorCollection AddProperty(PropertyDescriptorCollection pdc, string propertyName, Type propertyType, TypeConverter converter,
Attribute[] attributes)
{
List<PropertyDescriptor> properties = new List<PropertyDescriptor>(pdc.Count);
for (int i = 0; i < pdc.Count; i++)
{
PropertyDescriptor pd = pdc[i];
if (pd.Name != propertyName)
{
properties.Add(pd);
}
}
InstanceSavePropertyDescriptor ppd = new InstanceSavePropertyDescriptor(
propertyName, propertyType, attributes);
ppd.TypeConverter = converter;
properties.Add(ppd);
//PropertyDescriptor propertyDescriptor;
return new PropertyDescriptorCollection(properties.ToArray());
}
示例3: ComponentExporter
private ComponentExporter(Type inputType, PropertyDescriptorCollection properties) :
base(inputType)
{
Debug.Assert(properties != null);
_properties = properties;
int index = 0;
int count = 0;
IObjectMemberExporter[] exporters = new IObjectMemberExporter[properties.Count];
foreach (PropertyDescriptor property in properties)
{
IServiceProvider sp = property as IServiceProvider;
if (sp == null)
continue;
IObjectMemberExporter exporter = (IObjectMemberExporter) sp.GetService(typeof(IObjectMemberExporter));
if (exporter == null)
continue;
exporters[index++] = exporter;
count++;
}
if (count > 0)
_exporters = exporters;
}
示例4: Half2Converter
/// <summary>
/// Initializes a new instance of the <see cref = "T:SiliconStudio.Core.TypeConverters.Half2Converter" /> class.
/// </summary>
public Half2Converter()
{
Type type = typeof (Half2);
PropertyDescriptor[] propArray = new PropertyDescriptor[]
{new FieldPropertyDescriptor(type.GetField("X")), new FieldPropertyDescriptor(type.GetField("Y"))};
properties = new PropertyDescriptorCollection(propArray);
}
示例5: GetProperties
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
var pdl = propertyDescriptorList.FindAll(pd => pd.Attributes.Contains(attributes));
PreProcess(pdl);
var pdcReturn = new PropertyDescriptorCollection(pdl.ToArray());
return pdcReturn;
}
示例6: GetProperties
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
//var cols = base.GetProperties();
var props = new PropertyDescriptorCollection(null);
foreach (FieldInfo fi in value.GetType().GetFields())
{
var prop = new WsdlFieldDescriptor(fi, attributes);
props.Add(prop);
if (fi.FieldType.BaseType.FullName == "System.Array")
{
TypeDescriptor.AddAttributes(fi.FieldType, new TypeConverterAttribute(typeof(ArrayConverter)));
Type elemType = fi.FieldType.GetElementType();
TypeDescriptorModifier.modifyType(elemType);
}
else if (fi.FieldType.BaseType.FullName == "System.Enum")
{
}
else
{
TypeDescriptorModifier.modifyType(fi.FieldType);
}
}
if (props.Count > 0)
return props;
return base.GetProperties(context, value, attributes);
}
示例7: ConfigurationTypeDescriptor
/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationTypeDescriptor"/> class.
/// </summary>
/// <param name="value">The value.</param>
public ConfigurationTypeDescriptor(object value)
{
this.value = value;
var descriptors = new List<PropertyDescriptor>();
if (value != null)
{
var type = this.value.GetType();
// Get all the fields
var fields = type.GetFields();
foreach (var field in fields)
{
var name = this.GetReflectionName(field);
if (name != null)
{
descriptors.Add(new FieldPropertyDescriptor(name, field, this.value));
}
}
// Get all the properties
var properties = type.GetProperties();
foreach (var property in properties)
{
var name = this.GetReflectionName(property);
if (name != null)
{
descriptors.Add(new PropertyPropertyDescriptor(name, property, this.value));
}
}
}
this.properties = new PropertyDescriptorCollection(descriptors.ToArray(), true);
}
示例8: Find
public void Find ()
{
PropertyDescriptor descA = new MockPropertyDescriptor ("hehe_\u0061\u030a", 2);
PropertyDescriptor descB = new MockPropertyDescriptor ("heh_\u00e5", 3);
PropertyDescriptor descC = new MockPropertyDescriptor ("Foo", 5);
PropertyDescriptor descD = new MockPropertyDescriptor ("FOo", 6);
PropertyDescriptor descE = new MockPropertyDescriptor ("Aim", 1);
PropertyDescriptor descF = new MockPropertyDescriptor ("Bar", 4);
PropertyDescriptorCollection col = new PropertyDescriptorCollection (
new PropertyDescriptor [] { descA, descB, descC, descD, descE, descF });
Assert.IsNull (col.Find ("heh_\u0061\u030a", false), "#1");
Assert.IsNull (col.Find ("hehe_\u00e5", false), "#2");
Assert.AreSame (descA, col.Find ("hehe_\u0061\u030a", false), "#3");
Assert.AreSame (descB, col.Find ("heh_\u00e5", false), "#4");
Assert.IsNull (col.Find ("foo", false), "#5");
Assert.AreSame (descC, col.Find ("foo", true), "#6");
Assert.AreSame (descD, col.Find ("FOo", false), "#7");
Assert.AreSame (descC, col.Find ("FOo", true), "#8");
Assert.IsNull (col.Find ("fOo", false), "#9");
Assert.AreSame (descC, col.Find ("fOo", true), "#10");
Assert.IsNull (col.Find ("AIm", false), "#11");
Assert.AreSame (descE, col.Find ("AIm", true), "#12");
Assert.IsNull (col.Find ("AiM", false), "#13");
Assert.AreSame (descE, col.Find ("AiM", true), "#14");
Assert.AreSame (descE, col.Find ("Aim", false), "#15");
Assert.AreSame (descE, col.Find ("Aim", true), "#16");
}
示例9: GetProperties
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
//var cols = base.GetProperties();
var props = new PropertyDescriptorCollection(null);
foreach (FieldInfo fi in value.GetType().GetFields())
{
var prop = new MyPropertyDesciptor(fi, attributes);
props.Add(prop);
if (fi.FieldType.Namespace == "System.Collections.Generic")
{
Type[] args = fi.FieldType.GetGenericArguments();
foreach (Type arg in args)
MyCustomTypeDescriptor.modifyNonSystemTypes(arg);
}
{
MyCustomTypeDescriptor.modifyNonSystemTypes(fi.FieldType);
}
}
if (props.Count > 0)
return props;
return base.GetProperties(context, value, attributes);
}
示例10: DescriptorBase
/// <summary>
/// Initializes a new instance of the <see cref="T:DescriptorBase"/> class.
/// </summary>
/// <param name="provider">The provider.</param>
/// <param name="parentdescriptor">The parentdescriptor.</param>
/// <param name="objectType">Type of the object.</param>
public DescriptorBase(ShapeProvider provider, ICustomTypeDescriptor parentdescriptor, Type objectType)
: base(parentdescriptor)
{
this.provider = provider;
this.type = objectType;
mProperties = new PropertyDescriptorCollection(null);
}
示例11: GetProperties
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection descriptorCollection = new PropertyDescriptorCollection((PropertyDescriptor[])null);
foreach (PropertyDescriptor parent in TypeDescriptor.GetProperties((object) this.provider.UserProvider, attributes, false))
descriptorCollection.Add((PropertyDescriptor)new FQProviderPropertyDescriptor(parent));
return descriptorCollection;
}
示例12: GetProperties
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection descriptorCollection = new PropertyDescriptorCollection((PropertyDescriptor[])null);
foreach (ScriptProperty property in this.settings.ScriptProperties.Values)
descriptorCollection.Add((PropertyDescriptor)new ScriptPropertyDescriptor(property));
return descriptorCollection;
}
示例13: DataRecordInternal
// copy all runtime data information
internal DataRecordInternal(object[] values, PropertyDescriptorCollection descriptors, FieldNameLookup fieldNameLookup)
{
Debug.Assert(null != values, "invalid attempt to instantiate DataRecordInternal with null value[]");
_values = values;
_propertyDescriptors = descriptors;
_fieldNameLookup = fieldNameLookup;
}
示例14: FFTypeDescriptor
public FFTypeDescriptor([NotNull]object targetObject)
{
_WrappedObject = targetObject;
Type type = targetObject.GetType();
PropertyDescriptorCollection pdc;
if (!__TypedDescriptorCollection.TryGetValue(type, out pdc))
{
pdc = new PropertyDescriptorCollection(null);
foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(type))
{
var desc = new MyPropDesc(pd);
desc.ValueChanging += Property_ValueChanging;
pdc.Add(desc);
}
foreach (BindPropertyAttribute a in type.GetCustomAttributes<BindPropertyAttribute>())
{
var childProp = a.GetSourcePropertyInfo(type);
var v = childProp.GetValue(targetObject, null);
var pdcs = TypeDescriptor.GetProperties(v, false);
var bpd = new BindPropertyDescriptor(pdcs[a.Property], childProp, a.DisplayName, a.Description, a.Category);
bpd.ValueChanging += Property_ValueChanging;
pdc.Add(bpd);
}
__TypedDescriptorCollection.Add(type, pdc);
}
_DescriptorCollection = pdc;
}
示例15: MatrixConverter
/// <summary>Initializes a new instance of the MatrixConverter class.</summary>
public MatrixConverter()
{
var componentType = typeof(Matrix);
var properties = TypeDescriptor.GetProperties(componentType);
var descriptors =
new PropertyDescriptorCollection(new PropertyDescriptor[]
{
properties.Find("Translation", true), new FieldPropertyDescriptor(componentType.GetField("M11")),
new FieldPropertyDescriptor(componentType.GetField("M12")),
new FieldPropertyDescriptor(componentType.GetField("M13")),
new FieldPropertyDescriptor(componentType.GetField("M14")),
new FieldPropertyDescriptor(componentType.GetField("M21")),
new FieldPropertyDescriptor(componentType.GetField("M22")),
new FieldPropertyDescriptor(componentType.GetField("M23")),
new FieldPropertyDescriptor(componentType.GetField("M24")),
new FieldPropertyDescriptor(componentType.GetField("M31")),
new FieldPropertyDescriptor(componentType.GetField("M32")),
new FieldPropertyDescriptor(componentType.GetField("M33")),
new FieldPropertyDescriptor(componentType.GetField("M34")),
new FieldPropertyDescriptor(componentType.GetField("M41")),
new FieldPropertyDescriptor(componentType.GetField("M42")),
new FieldPropertyDescriptor(componentType.GetField("M43")),
new FieldPropertyDescriptor(componentType.GetField("M44"))
});
propertyDescriptions = descriptors;
supportStringConvert = false;
}