Skip to content

Commit 7a5da38

Browse files
committed
Add GenericPropertyConverter
1 parent 0b1197a commit 7a5da38

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
5+
namespace OpenEphys.Onix1
6+
{
7+
/// <summary>
8+
/// Generic property converter that expands to show all properties.
9+
/// </summary>
10+
internal class GenericPropertyConverter : ExpandableObjectConverter
11+
{
12+
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
13+
{
14+
var properties = (from property in base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>()
15+
where !property.IsReadOnly
16+
select property)
17+
.ToArray();
18+
return new PropertyDescriptorCollection(properties).Sort(properties.Select(p => p.Name).ToArray());
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)