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

G

Guest

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("System.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);
 

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