I'm learning T4, and am successfully interrogating my custom class for its member.
What I need however, is to bring out only the properties that I created, like FirstName, Surname, and Postcode.
Here's an example of what I'm actually getting when I use :
foreach(Microsoft.Cci.Member member in class.Mem开发者_运维百科bers)
{
if( member.IsPublic )
{
Write( member.Name + ",\n");
}
}
get_FirstName,
set_FirstName,
get_Surname,
set_Surname,
FirstName,
Surname,
.ctor
Could anyone advise if its possible to just access the actual properties and their types?
Many thanks.
You'll need to extract the properties from Members. You can identify PropertyNode members by their NodeType, which will be NodeType.Property. e.g.:
foreach (PropertyNode property in type.Members
.Where(m => m.NodeType == NodeType.Property)
.Cast<PropertyNode>())
{
//...
}
精彩评论