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

Home Posts Topics Members FAQ

CodeDom and typeof

I have the need to generate the following code:

Type someVar = typeof(MyType);

I know how to declare the var and can intialize vars except in this
case.

I can't figure out how to get the codedom to generate a cll to typeof.
Any help would be appreciated.

Nov 16 '05 #1
1 2953

Try something like this:

CodeTypeReference typeRef = new CodeTypeReference("MyType");
CodeTypeOfExpression typeofValue = new CodeTypeOfExpression(typeRef);
Statements.Add( new CodeAssignStatement(
new CodeFieldReferenceExpression(new CodeThisReferenceExpression(),
someVar) ,
typeofValue) );

Lionel.
<Th********@gmail.com> a écrit dans le message de news:
11**********************@l41g2000cwc.googlegroups. com...
I have the need to generate the following code:

Type someVar = typeof(MyType);

I know how to declare the var and can intialize vars except in this
case.

I can't figure out how to get the codedom to generate a cll to typeof.
Any help would be appreciated.

Nov 16 '05 #2

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

Similar topics

0
1887
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?...
0
1110
by: Vitaly Gorbenko | last post by:
Hello, Does anybody know if there is any way to generate "TypeOf ... Is ..." statement using CodeDom? Here is a sample of what I need to get: If TypeOf oObject Is IMyInterface Then...
2
2347
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...
0
2949
by: Sherif ElMetainy | last post by:
Hello I am making an application that generates source code. I am facing some problems. 1- How can I generate code that uses the c# 'params' keyword to specify multiple arguments? I tried 2...
2
354
by: 2G | last post by:
Hello Can anyone tel me how to do this : System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); ...
1
2277
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...
3
4837
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?...
9
3965
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 |...
1
2657
by: Tim Haughton | last post by:
Hi, I'm writing some CodeDom stuff at the minute. It's great fun but I've hit a snag. A little bit of the code checks to see whether an event is null before I fire it. It looks like this... ...
0
7112
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,...
1
6852
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
7356
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...
0
5448
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
4878
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
4573
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
1389
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
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
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.