-
Notifications
You must be signed in to change notification settings - Fork 451
/
CustomTypeDescriptor.cs
100 lines (82 loc) · 2.63 KB
/
CustomTypeDescriptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
***************************************************************************/
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Samples.VisualStudio.IDE.ToolWindow
{
/// <summary>
/// This base class forwards all the ICustomTypeDescriptor calls
/// to the default TypeDescriptor, except for GetComponentName.
/// This allows for a class to specify the name that will be
/// displayed in the combo box of the Properties window.
/// </summary>
internal abstract class CustomTypeDescriptor : ICustomTypeDescriptor
{
/// <summary>
/// Name of the component.
/// When this class is used to expose property in the Properties
/// window, this should be the name associated with this instance.
/// </summary>
protected abstract string ComponentName
{
get;
}
#region ICustomTypeDescriptor Members
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
return TypeDescriptor.GetAttributes(GetType());
}
string ICustomTypeDescriptor.GetClassName()
{
return TypeDescriptor.GetClassName(GetType());
}
string ICustomTypeDescriptor.GetComponentName()
{
return ComponentName;
}
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return TypeDescriptor.GetConverter(GetType());
}
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return TypeDescriptor.GetDefaultEvent(GetType());
}
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
{
return TypeDescriptor.GetDefaultProperty(GetType());
}
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
{
return TypeDescriptor.GetEditor(GetType(), editorBaseType);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return TypeDescriptor.GetEvents(GetType(), attributes);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return TypeDescriptor.GetEvents(GetType());
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
return TypeDescriptor.GetProperties(GetType(), attributes);
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
{
return TypeDescriptor.GetProperties(GetType());
}
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
{
return this;
}
#endregion
}
}