473,544 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CodeDom question for .net 2.0

I am using the CodeDom namespace for generating classes, and would
really like to be able to use the CodeRegionDirec tive class to generate
regions around code blocks.

The only problem is that is looks like i can generate regions around a
single method or a single statement (using StartDirective) property, is
there any way to out a code region around a collection of statements, or
methods ?

any help would be appreciated..

TIA
Dec 14 '05 #1
7 2658
Ashish,

From what I can tell, you need to place two CodeRegionDirec tives in your
code, one for the start, and one for the end. So, you find the method where
you want to place the region start, and add the CodeRegionDirec tive to the
StartDirectives collection.

You then go to the other element of code where you want to place the
region end, and then add the CodeRegionDirec tive to the EndDirectives
collection.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ashish" <as*****@thisis junk.com> wrote in message
news:OZ******** ******@TK2MSFTN GP14.phx.gbl...
I am using the CodeDom namespace for generating classes, and would really
like to be able to use the CodeRegionDirec tive class to generate regions
around code blocks.

The only problem is that is looks like i can generate regions around a
single method or a single statement (using StartDirective) property, is
there any way to out a code region around a collection of statements, or
methods ?

any help would be appreciated..

TIA

Dec 14 '05 #2
Nicholas,

Thanks for the answer,
here is the code fargment ...

CodeTypeDeclara tion ctd = new CodeTypeDeclara tion();

ctd.StartDirect ives.Add(new CodeRegionDirec tive(CodeRegion Mode.Start,
"members")) ;
ctd.Members.Add Range(this.GetM emberFields());
ctd.StartDirect ives.Add(new
CodeRegionDirec tive(CodeRegion Mode.End,string .Empty));
but code generated by GetMemberFields is not places in the output :(

Thanks



Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

From what I can tell, you need to place two CodeRegionDirec tives in your
code, one for the start, and one for the end. So, you find the method where
you want to place the region start, and add the CodeRegionDirec tive to the
StartDirectives collection.

You then go to the other element of code where you want to place the
region end, and then add the CodeRegionDirec tive to the EndDirectives
collection.

Hope this helps.

Dec 14 '05 #3
Ashish,

Add the last CodeRegionDirec tive to the EndDirectives.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ashish" <as*****@thisis junk.com> wrote in message
news:uY******** ******@TK2MSFTN GP11.phx.gbl...
Nicholas,

Thanks for the answer,
here is the code fargment ...

CodeTypeDeclara tion ctd = new CodeTypeDeclara tion();

ctd.StartDirect ives.Add(new CodeRegionDirec tive(CodeRegion Mode.Start,
"members")) ;
ctd.Members.Add Range(this.GetM emberFields());
ctd.StartDirect ives.Add(new
CodeRegionDirec tive(CodeRegion Mode.End,string .Empty));
but code generated by GetMemberFields is not places in the output :(

Thanks



Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

From what I can tell, you need to place two CodeRegionDirec tives in
your code, one for the start, and one for the end. So, you find the
method where you want to place the region start, and add the
CodeRegionDirec tive to the StartDirectives collection.

You then go to the other element of code where you want to place the
region end, and then add the CodeRegionDirec tive to the EndDirectives
collection.

Hope this helps.


Dec 14 '05 #4
Nicholas

thanks for pointing that out

i did that, but it adds the regions at the start of the whole class code
instead of just the members :(

for example the generated code looks like

#region members
public clas blah
{
// this is where i want it to start
private int mUId;
.......


}

#endregion

, any other clues ?

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

Add the last CodeRegionDirec tive to the EndDirectives.

Dec 14 '05 #5
Ashish,

The CodeMemberField class has StartDirectives and EndDirectives
properties which you can attach code directives to. Why not just attach
them to the one that corresponds to the mUId field?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ashish" <as*****@thisis junk.com> wrote in message
news:ul******** ******@TK2MSFTN GP15.phx.gbl...
Nicholas

thanks for pointing that out

i did that, but it adds the regions at the start of the whole class code
instead of just the members :(

for example the generated code looks like

#region members
public clas blah
{
// this is where i want it to start
private int mUId;
......


}

#endregion

, any other clues ?

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

Add the last CodeRegionDirec tive to the EndDirectives.


Dec 14 '05 #6
Nicholas,

well that would surround each member declaration with a region, and i
want to all the member declarations under one region, or there would be
too many regions to deal with .... , seems like this should be do able..

thanks

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

The CodeMemberField class has StartDirectives and EndDirectives
properties which you can attach code directives to. Why not just attach
them to the one that corresponds to the mUId field?

Dec 14 '05 #7
Ashish,

Right, so on the first member in the region, add the directive to the
StartDirectives . In the last member in the region, add the directive to the
EndDirectives.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ashish" <as*****@thisis junk.com> wrote in message
news:uX******** ******@TK2MSFTN GP14.phx.gbl...
Nicholas,

well that would surround each member declaration with a region, and i want
to all the member declarations under one region, or there would be too
many regions to deal with .... , seems like this should be do able..

thanks

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

The CodeMemberField class has StartDirectives and EndDirectives
properties which you can attach code directives to. Why not just attach
them to the one that corresponds to the mUId field?


Dec 15 '05 #8

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

Similar topics

0
1893
by: Ron Bullman | last post by:
Hi, I havent been able to find any documentation about @ in the CodeDom context. The problem is when generating C# code from CodeDom it will associate a @-tag with all C# specific types. Why? And how to configure the CodeDom to generate code without @-tags? Ron A short example follows whic produces following kind of output:
2
2352
by: Guillaume | last post by:
I don't think I'm the only one with this challenge so… I made code with the CodeDom classes and made code to create a new solution and a new project Now I want to get the codedom code in the new created IDE instance How can do that? Is there a way to paste the string (CodeDom output) into a class? Out is the a way to insert the created...
1
2283
by: John Livermore | last post by:
Hello, We have an application that uses CodeDom for dynamic in-memory compilation of code. The same code (library) is used by both an ASP.net web site and a Windows Service. The code runs fine in the web environment, but I get file IO errors related to temporary files when it is run in by the Service. I realize that CodeDom has to...
3
4843
by: Alexey Lavnikov | last post by:
I'm playing with CodeDOM and CSharpCodeProvider. I've found the following possibilities: CodeDOM -> Assembly C# Source code -> Assembly I miss the C# Source code -> CodeDOM only. Is it there? Or it's hidden under the hood?
9
3971
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 | MemberAttributes.Family | MemberAttributes.Final;
6
5745
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
2
2268
by: CodeMonkey775 | last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am trying to pass this list to an executable section of code which is compiled during run-time. The formulas are calculated in CodeDom and the result is...
1
4862
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I may have painted myself into a corner with GenerateInMemory=true. My app need a custom user step. Users want to code (sort of - they are not programmers) some refinements to a search procedure. They can concoct a moderately complex boolean expression, and that suffices. I will take their statements, add top and bottom text, and now I...
0
1176
by: thisismykindabyte | last post by:
Hello, I was wondering if anyone might know the easiest way to access static methods through a namespace(MyNamespace) from CodeDom generated code? Basically I have this in my MyNamespace.Form: //////// Most of this below is almost useless jargon just to give an idea of what values are set or not public...
1
2012
by: thisismykindabyte | last post by:
Hello, I was wondering if anyone could tell me how I can pass a reference of an object(lets pretend a MemoryStream) to CodeDom's generated code in memory? So basically I would like to create CodeDom code that gets a reference as a parameter to an object in Form1. Then I would like to call the CodeDom code with Reflection, and have CodeDom...
0
7362
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...
0
7764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7368
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...
0
7704
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5904
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...
1
5291
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...
0
3404
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1837
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
1
983
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.