tags:

views:

13

answers:

1

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.Members)
{
    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.

A: 

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>())
{
    //...
}
Nicole Calinoiu
Thanks Nicole - I'll give this a go.
Paul