473,386 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,386 software developers and data experts.

CodeDom Protected AND Override, more then one Attribute, how?

Jax
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();

newMethod.Attributes=MemberAttributes.Override; // THIS IS THE PROBLEM

newMethod.Parameters.Add(new CodeParameterDeclarationExpression(Type.GetType("S ystem.Boolean"),"disposing"));
CodeStatement[] someExpressions = new CodeStatement[0];
CodeConditionStatement newIf = new CodeConditionStatement(new CodeSnippetExpression("disposing"), someExpressions);
someExpressions = new CodeStatement[0];
CodeConditionStatement secondIf = new CodeConditionStatement(new CodeSnippetExpression("components != null"), someExpressions);
secondIf.TrueStatements.Add(new CodeSnippetStatement("components.Dispose();"));
CodeSnippetStatement aStatement = new CodeSnippetStatement("base.Dispose(disposing);");
newIf.TrueStatements.Add(secondIf);
newMethod.Statements.Add(newIf);
newMethod.Statements.Add(aStatement);
newMethod.Name = "Dispose";
customClass.Members.Add(newMethod);
Nov 15 '05 #1
1 4093
Jax
I got it

newMethod.Attributes=MemberAttributes.Override|Mem berAttributes.Family
Nov 15 '05 #2

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

Similar topics

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...
4
by: Chuck Bowling | last post by:
I am using CodeDOM to generate source files. The classes being generated have a const string member. This member is referenced in an abstract base class but declared in the inheriting class. I...
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...
8
by: Keith Smith | last post by:
Could some one help me a little? I am trying to understand when/where you would ever want to use "protected override..." code such as this. How is this any different from creating a...
4
by: Raja | last post by:
Have both .Net framework 1.1 and Framework 2.0 installed in my machine But, am unable to find out system.codedom.dll in my machine, one which, my application needs. Am not finding this dll in...
9
by: lee.chappers | last post by:
How can I make the CodeDom generate the following C# method? protected sealed override void Test() { } I've tried using: domMethod.Attributes = MemberAttributes.Override |...
13
by: Clive Dixon | last post by:
I am refactoring some code to move some base classes into a separate assembly. One of these base classes has a member property which is 'protected internal'. However when I move these base classes...
5
by: =?Utf-8?B?V0o=?= | last post by:
If I have a class A that has a virtual public function DoSomething() Class A { public: virtual void DoSomething(); } then I override this function to protected is class B Class B: public...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.