473,790 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ 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 -
CodeMemberMetho d method = new CodeMemberMetho d();
method.Name = "TestMethod ";
method.Attribut es = MemberAttribute s.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttribute s !!!!

2. When set the attribute of the method to MemberAttribute s.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 9257

1) To create protected member , use enum

MemberAttribute s.Family

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

CodeFieldRefere nceExpression cfr = new CodeFieldRefere nceExpression(n ull,
blah);

3) To set multiple atrributes do this

method.Attribut es = MemberAttribute s.Static | method.Attribut es =
MemberAttribute s.Public;

--
Shak
(Houston)
"Tapas" <ta***********@ gmail.com> wrote in message
news:1b******** *************** ***@posting.goo gle.com...
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 -
CodeMemberMetho d method = new CodeMemberMetho d();
method.Name = "TestMethod ";
method.Attribut es = MemberAttribute s.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttribute s !!!!

2. When set the attribute of the method to MemberAttribute s.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.Attribut es = MemberAttribute s.Static | MemberAttribute s.Public;
--
Shak
(Houston)
"Tapas" <ta***********@ gmail.com> wrote in message
news:1b******** *************** ***@posting.goo gle.com...
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 -
CodeMemberMetho d method = new CodeMemberMetho d();
method.Name = "TestMethod ";
method.Attribut es = MemberAttribute s.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttribute s !!!!

2. When set the attribute of the method to MemberAttribute s.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.Attribut es = MemberAttribute s.Static | MemberAttribute s.Public;
--
Shak
(Houston)
"Shakir Hussain" <sh**@nodomain. com> wrote in message
news:uk******** ******@tk2msftn gp13.phx.gbl...

1) To create protected member , use enum

MemberAttribute s.Family

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

CodeFieldRefere nceExpression cfr = new CodeFieldRefere nceExpression(n ull,
blah);

3) To set multiple atrributes do this

method.Attribut es = MemberAttribute s.Static | method.Attribut es =
MemberAttribute s.Public;

--
Shak
(Houston)
"Tapas" <ta***********@ gmail.com> wrote in message
news:1b******** *************** ***@posting.goo gle.com...
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 -
CodeMemberMetho d method = new CodeMemberMetho d();
method.Name = "TestMethod ";
method.Attribut es = MemberAttribute s.Static;
How make Protected ? There is no attribute called 'Protected' in the
class MemberAttribute s !!!!

2. When set the attribute of the method to MemberAttribute s.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
4123
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 assigned to it. I would like to set the attributes protected AND override but I can only set one, if I set the other it cancels out the previous. Does anyone know how to do this? CodeMemberMethod newMethod = new CodeMemberMethod(); ...
0
1071
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 Method, Property, and Member code, but ONLY that code. It appears as though the only way to generate code is through the CodeGenerator/CodeProvider, which you have to attach a namespace then a class to the namespace then your members to that...
1
2987
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 = MemberAttributes.???????; Thanks in advance. Mark
1
6484
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 a program to execute. The command being executed was "c:\winnt\microsoft.net\framework\v1.0.3705\vbc.exe"
0
2862
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 sometimes i get the following error. Does anyone knows what i have to do to get rid of this error?
15
26517
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
2372
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
1729
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 file (already compiled as .exe)
6
5770
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
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10145
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
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 we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.