Using CodeDom to create a method?

Codeless

Well-known member
Joined
Jan 24, 2003
Messages
59
Location
Great NW
I am trying to use the codedom to create an assembly that will simply return a number. The real method looks like this:

Code:
Public Class Class1
Public Function GetR ()
     Return 255
End Function
End Class

The CodeDom statments to create this would be something like this:

Code:
Dim Class1 As New CodeTypeDeclaration("Class1")
TheName.Types.Add(Class1)
Dim GetR As New CodeMemberMethod()
GetR.Name = "GetR"
GetR.ReturnType = New CodeTypeReference(GetType(Integer))
GetR.Statements.Add(New CodeMethodReturnStatement(New CodeMethodInvokeExpression()))

How would the last statement look? Seems like it should be easy but theirs not many good examples out there.
 
Actually maybe I would use a property instead of a method. Anyone know how to create that first class way up there with the CodeDom?
 
Back
Top