G
Guest
Dear all,
I'm having trouble trying to create a class with CodeDOM that must implement
the interface IDisposable.
First, I didn't manage to find the right way to tell my class that it must
implement an interface. I've tried the following code, but it's declaring an
inheritance:
Dim ctd As New CodeTypeDeclaration(sClassName)
ctd.IsClass = True
ctd.BaseTypes.Add(New CodeTypeReference(GetType(IDisposable)))
ctd.Attributes = MemberAttributes.Public
cns.Types.Add(ctd)
This code gives me:
Public Class MyTestClass
Inherits System.IDisposable
And I need:
Public Class MyTestClass
Implements System.IDisposable
Second, I managed to declare correctly a method that implements the
interface's method correctly, but I can't choose the name of the method
created:
Dim cmmDispose As New CodeMemberMethod
cmmDispose.Attributes = MemberAttributes.Public Or
MemberAttributes.Final
cmmDispose.PrivateImplementationType = New
CodeTypeReference(GetType(IDisposable))
cmmDispose.Name = "Dispose"
...
ctd.Members.Add(cmmDispose)
This code gives me:
Sub System_IDisposable_Dispose() Implements System.IDisposable.Dispose
That is correct, but I would like that name method name:
Sub Dispose() Implements System.IDisposable.Dispose
Thank you by advance for everybody that can help me with these two problems!
Sebastien
I'm having trouble trying to create a class with CodeDOM that must implement
the interface IDisposable.
First, I didn't manage to find the right way to tell my class that it must
implement an interface. I've tried the following code, but it's declaring an
inheritance:
Dim ctd As New CodeTypeDeclaration(sClassName)
ctd.IsClass = True
ctd.BaseTypes.Add(New CodeTypeReference(GetType(IDisposable)))
ctd.Attributes = MemberAttributes.Public
cns.Types.Add(ctd)
This code gives me:
Public Class MyTestClass
Inherits System.IDisposable
And I need:
Public Class MyTestClass
Implements System.IDisposable
Second, I managed to declare correctly a method that implements the
interface's method correctly, but I can't choose the name of the method
created:
Dim cmmDispose As New CodeMemberMethod
cmmDispose.Attributes = MemberAttributes.Public Or
MemberAttributes.Final
cmmDispose.PrivateImplementationType = New
CodeTypeReference(GetType(IDisposable))
cmmDispose.Name = "Dispose"
...
ctd.Members.Add(cmmDispose)
This code gives me:
Sub System_IDisposable_Dispose() Implements System.IDisposable.Dispose
That is correct, but I would like that name method name:
Sub Dispose() Implements System.IDisposable.Dispose
Thank you by advance for everybody that can help me with these two problems!
Sebastien