开发者

How to get only user created properties using microsoft.cci Members?

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>())
{
    //...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜