CodeDom: How to create Editor() property attribute?

  • Thread starter Thread starter Justin.Feist
  • Start date Start date
J

Justin.Feist

I'm trying to use the CodeDom to generate the <Editor(...)> property
attribute as shown below. I have no problem generating the property
itself, and in fact I can generate a <Description("")> attribute. But
I cannot seem to be able to get a handle on how to generate the Editor
attribute. Can anyone post some code to get me on the right track?

<Editor(GetType(System.Windows.Forms.Design.FolderNameEditor),
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property MyProperty() As String
....
End Property
 
I'm trying to use the CodeDom to generate the <Editor(...)> property
attribute as shown below. I have no problem generating the property
itself, and in fact I can generate a <Description("")> attribute. But
I cannot seem to be able to get a handle on how to generate the Editor
attribute. Can anyone post some code to get me on the right track?

<Editor(GetType(System.Windows.Forms.Design.FolderNameEditor),
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property MyProperty() As String
...
End Property


Ok, after taking the weekend off I figured it out in case anyone else
wanders into this post. Below is some code to generate an Editor()
CodeAttributeDeclaration object that can be added to a property:


Dim oAttributeDec As CodeAttributeDeclaration
Dim oArg1 As CodeAttributeArgument
Dim oArg2 As CodeAttributeArgument
Dim oCodeTypeReference As CodeTypeReference

oCodeTypeReference = New CodeTypeReference( _
"System.Windows.Forms.Design.FolderNameEditor")

oArg1 = New CodeAttributeArgument( _
New CodeTypeOfExpression(oCodeTypeReference))

oCodeTypeReference = New CodeTypeReference( _
"System.Drawing.Design.UITypeEditor")

oArg2 = New CodeAttributeArgument( _
New CodeTypeOfExpression(oCodeTypeReference))

oAttributeDec = New CodeAttributeDeclaration("Editor", _
New CodeAttributeArgument() {oArg1, oArg2})
 
Back
Top