CodeDom: more than one Attribute for a CodeMemberMethod

K

Kai Huener

ello,

I try to make a function, adding automatically all functions to a new class
which are necessary because of implemented Interfaces or inherited, abstract
classes. In the last case, it is necessary to have two attributes in front
of the function, like protected override void Foo(){}. And now my question:

1.: I can't find the Attribute "protectd" in the enum
"System.CodeDom.MemberAttributes". Why? Is it the wrong place to look?

2.: Why isn't it possible to add more than one Attribute to a new Method? I
can set the Property "System.CodeDom.CodeMemberMethod.Attributes" only to
one Attribute. How can I declare a new method to "public static" or
"protected override?.

Every Hint can be helpful for me, even a possibility to solve my problem in
a different way, perhaps there is a better way to success?

Best Regards,
Kai Hüner
 
J

Jon Skeet [C# MVP]

Kai Huener said:
I try to make a function, adding automatically all functions to a new class
which are necessary because of implemented Interfaces or inherited, abstract
classes. In the last case, it is necessary to have two attributes in front
of the function, like protected override void Foo(){}. And now my question:

1.: I can't find the Attribute "protectd" in the enum
"System.CodeDom.MemberAttributes". Why? Is it the wrong place to look?

Nope, it's just that it's called Family as far as the framework is
concerned.
2.: Why isn't it possible to add more than one Attribute to a new Method? I
can set the Property "System.CodeDom.CodeMemberMethod.Attributes" only to
one Attribute. How can I declare a new method to "public static" or
"protected override?.

It's a bit flag - just set it to
MemberAttributes.Public | MemberAttributes.Static
or
MemberAttributes.Family | MemberAttributes.Override

(for example).
 
K

Kai Huener

Hi Jon,

Thank you for the fast help, your post solved both problems :)

Best Regards,
Kai
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top