Generics in CodeDom of .NET 2.0?

  • Thread starter Thread starter Mark
  • Start date Start date
Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.
 
Excellent. This inspired me to dig further, and I succeeded with the
following:

CodeTypeDeclaration newClass = new CodeTypeDeclaration("MyCollectionClass");
newClass.BaseTypes.Add( new CodeTypeReference("Collection",
new CodeTypeReference[] {
new
CodeTypeReference("MyBaseClass")
}));

// This results in code like:

public class MyCollectionClass : Collection<MyBaseClass>
{
//woo hoo!
}


Nicholas Paldino said:
Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Mark said:
I'm looking at the CodeDom namespace in .NET 2.0 class library online
(http://msdn2.microsoft.com/library/za6cc751.aspx). I'm not seeing any
class that would allow me to create Generics. Any suggestions?

Thanks in advance.

Mark
 
Excellent. This inspired me to dig further, and I succeeded with the
following:

CodeTypeDeclaration newClass = new CodeTypeDeclaration("MyCollectionClass");
newClass.BaseTypes.Add( new CodeTypeReference("Collection",
new CodeTypeReference[] {
new
CodeTypeReference("MyBaseClass")
}));

// This results in code like:

public class MyCollectionClass : Collection<MyBaseClass>
{
//woo hoo!
}


Nicholas Paldino said:
Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Mark said:
I'm looking at the CodeDom namespace in .NET 2.0 class library online
(http://msdn2.microsoft.com/library/za6cc751.aspx). I'm not seeing any
class that would allow me to create Generics. Any suggestions?

Thanks in advance.

Mark
 
Back
Top