473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to create a protected method, using CodeDom

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 method. To make it static say, I do
something like this -
CodeMemberMethod method = new CodeMemberMethod();
method.Name = "TestMethod";
method.Attributes = MemberAttributes.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttributes !!!!

2. When set the attribute of the method to MemberAttributes.Public
....it generates a method "public virtual". I don't want a virtual in
there. How do I do it?

3. How do I set multiple attrubutes to a method like "public static" ?

Regards
Tapas
Nov 16 '05 #1
3 9229

1) To create protected member , use enum

MemberAttributes.Family

2) If you dont want virtual keyword after public, pass first parameter as
null in the CodeFieldReferenceExpression

CodeFieldReferenceExpression cfr = new CodeFieldReferenceExpression(null,
blah);

3) To set multiple atrributes do this

method.Attributes = MemberAttributes.Static | method.Attributes =
MemberAttributes.Public;

--
Shak
(Houston)
"Tapas" <ta***********@gmail.com> wrote in message
news:1b**************************@posting.google.c om...
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 method. To make it static say, I do
something like this -
CodeMemberMethod method = new CodeMemberMethod();
method.Name = "TestMethod";
method.Attributes = MemberAttributes.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttributes !!!!

2. When set the attribute of the method to MemberAttributes.Public
...it generates a method "public virtual". I don't want a virtual in
there. How do I do it?

3. How do I set multiple attrubutes to a method like "public static" ?

Regards
Tapas

Nov 16 '05 #2

sorry messed up 3rd answer

3) To set multiple atrributes do this

method.Attributes = MemberAttributes.Static | MemberAttributes.Public;
--
Shak
(Houston)
"Tapas" <ta***********@gmail.com> wrote in message
news:1b**************************@posting.google.c om...
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 method. To make it static say, I do
something like this -
CodeMemberMethod method = new CodeMemberMethod();
method.Name = "TestMethod";
method.Attributes = MemberAttributes.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttributes !!!!

2. When set the attribute of the method to MemberAttributes.Public
...it generates a method "public virtual". I don't want a virtual in
there. How do I do it?

3. How do I set multiple attrubutes to a method like "public static" ?

Regards
Tapas

Nov 16 '05 #3
sorry messed up 3rd answer

3) To set multiple atrributes do this

method.Attributes = MemberAttributes.Static | MemberAttributes.Public;
--
Shak
(Houston)
"Shakir Hussain" <sh**@nodomain.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...

1) To create protected member , use enum

MemberAttributes.Family

2) If you dont want virtual keyword after public, pass first parameter as
null in the CodeFieldReferenceExpression

CodeFieldReferenceExpression cfr = new CodeFieldReferenceExpression(null,
blah);

3) To set multiple atrributes do this

method.Attributes = MemberAttributes.Static | method.Attributes =
MemberAttributes.Public;

--
Shak
(Houston)
"Tapas" <ta***********@gmail.com> wrote in message
news:1b**************************@posting.google.c om...
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 method. To make it static say, I do
something like this -
CodeMemberMethod method = new CodeMemberMethod();
method.Name = "TestMethod";
method.Attributes = MemberAttributes.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttributes !!!!

2. When set the attribute of the method to MemberAttributes.Public
...it generates a method "public virtual". I don't want a virtual in
there. How do I do it?

3. How do I set multiple attrubutes to a method like "public static" ?

Regards
Tapas


Nov 16 '05 #4

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

Similar topics

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...
0
by: Shawn A. Hall | last post by:
First, I apologize if this isn't the right group to post this question, but I didn't see a newsgroup specific to CodeDom so here I am. On to my question: I am trying to use CodeDom to generate...
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 =...
1
by: Pardhasaradhy | last post by:
Hi, Please see the following error and revert back as early as possible. I am getting this once I request for the asp.net page. Server Error in '/tanishq' Application. Timed out waiting for...
0
by: Marco Viana | last post by:
Hi, I'm developing an ASP.NET application with Visual Studio .NET 2003 in a Win XP Professional, .NET Framework 1.1 and IIS 5.1 computer with all the lattest patches. When testing a page...
15
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
14
by: J.S. | last post by:
In a Windows Form application, which is the better method to concatenate large blocks of code? 1. Reading the text from text files. 2. Adding the text to the VB file itself? Thanks! J.S. ...
7
by: =?Utf-8?B?YW5kZXJzY2g=?= | last post by:
Hi It is possible to create an .exe file at runtime with .NET 2.0? I would like to create a .exe that should include: - an encrypted file - a simple winform to decrypt the included encrypted...
6
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.