473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CodeDom: more than one Attribute for a CodeMemberMethod

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
Nov 16 '05 #1
3 5065
Kai Huener <ma**@kaihuener.de> wrote:
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).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Jon,

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

Best Regards,
Kai

"Jon Skeet [C# MVP]" <sk***@pobox.com> schrieb im Newsbeitrag
news:MP************************@msnews.microsoft.c om...
Kai Huener <ma**@kaihuener.de> wrote:
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).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
Hi Jon,

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

Best Regards,
Kai

"Jon Skeet [C# MVP]" <sk***@pobox.com> schrieb im Newsbeitrag
news:MP************************@msnews.microsoft.c om...
Kai Huener <ma**@kaihuener.de> wrote:
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).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Avi Fomberg | last post by:
This is what i m trying to do: //Create class CodeTypeDeclaration cls = new CodeTypeDeclaration("MyClass"); //Create method CodeMemberMethod method = new CodeMemberMethod(); method.Name =...
1
by: Jax | last post by:
Here is the CodeDom code for the standard Dispose method of a windows form application. The problem I have is with the Attributes property, it isn't a collection so only one attribute can be...
3
by: Tapas | last post by:
Hi, Generating a .cs file using CodeDom. It generates the class fine. But i have few queries about class generation. 1. How to create a protected member? By default it generates a private...
1
by: Tapas | last post by:
Hi, I need to generate an Attribute and associate it with a method in CodeDom. // Code snippet CodeMemberMethod setUp = new CodeMemberMethod(); setUp.CustomAttributes.Add(new...
1
by: Kai Huener | last post by:
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...
5
by: Mark | last post by:
I'm using the CodeDom namespace to generate code. How do you specify that the method of a class should be static? I'm assuming I use the CodeMemberMethod class to define the method, but I'm not...
1
by: mark | last post by:
Using the CodeDom namespace, how do you create a blank line in a method primarily for formatting? Without it, autogenerated code is challenging to read. I tried something like: //Assume method...
1
by: Mark | last post by:
Using the CodeDom namespace, how to do you specify that a generated method should be virtual? CodeMemberMethod method = new CodeMemberMethod(); method.Name = "MyMethod"; method.Attributes =...
2
by: Microsoft Newsgroups | last post by:
Hi All, I'm looking for some simple examples of using the CodeDom. While the ones that I have found have been very helpful, I can't seem to find the following: How to add a control to a...
2
by: Venkat | last post by:
Hi, Can anyone let me know how to declare a local const in a method using CodeDOM? I am trying to get an output that looks like this: public void SomeMethod() { const int MyInteger = 56; } ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.