本文整理汇总了C#中System.ComponentModel.PropertyDescriptorCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptorCollection.OfType方法的具体用法?C# PropertyDescriptorCollection.OfType怎么用?C# PropertyDescriptorCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.PropertyDescriptorCollection
的用法示例。
在下文中一共展示了PropertyDescriptorCollection.OfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
public override PropertyDescriptorCollection GetProperties()
{
if (_properties == null) {
// Get properties from our parent
var originalCollection = base.GetProperties();
// Set _properties to avoid a stack overflow when CreateProjectionProperties
// ends up recursively calling TypeDescriptor.GetProperties on a type.
_properties = originalCollection;
var customDescriptorsCreated = false;
var tempPropertyDescriptors = new List<PropertyDescriptor>();
// for every property exposed by our parent, see if we have additional metadata to add,
// and if we do we need to add a wrapper PropertyDescriptor to add the new attributes
foreach (var propDescriptor in _properties.OfType<PropertyDescriptor>()) {
var newMetadata = GetAdditionalAttributes(propDescriptor);
if (newMetadata.Length > 0) {
tempPropertyDescriptors.Add(new DataControllerPropertyDescriptor(propDescriptor, newMetadata));
customDescriptorsCreated = true;
}
else
tempPropertyDescriptors.Add(propDescriptor);
}
if (customDescriptorsCreated)
_properties = new PropertyDescriptorCollection(tempPropertyDescriptors.ToArray(), true);
}
return _properties;
}
示例2: FilterProperties
private PropertyDescriptorCollection FilterProperties(PropertyDescriptorCollection originalCollection)
{
// Create an enumerator containing only the properties that are not in the provided list of property names
// and fill an array with those selected properties
IEnumerable<PropertyDescriptor> selectedProperties = originalCollection.OfType<PropertyDescriptor>().Where(p => !_excludeBrowsableProperties.Contains(p.Name));
PropertyDescriptor[] descriptors = selectedProperties.ToArray();
// Return a PropertyDescriptorCollection containing only the filtered descriptors
PropertyDescriptorCollection newCollection = new PropertyDescriptorCollection(descriptors);
return newCollection;
}
示例3: InitializeColumns
private void InitializeColumns(PropertyDescriptorCollection columnDescriptors) {
_columns = columnDescriptors.OfType<PropertyDescriptor>().Select(p => new SimpleColumnProvider(this, p)).OfType<ColumnProvider>().ToList();
}