473,406 Members | 2,356 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,406 software developers and data experts.

Question about dynamic way to create a type

I have web service always return a string in Xml format, and I have the code
at client side translates this return string into correct value. For example:
my web service returns a <ret type=”System.int”>1</ret>.
So my client logic will translate this into integer value of one by using
Type.GetType() function. Likewise, if my web service returns a <ret
type=”System.String”>abc</ret>, my client again translates this into string
type. My problem is when I try to return a System.Data.DataTable in my return
Xml string, and Type.GetType()can not return a System.Data.DataTable type for
me due to System.Data is not in mscorlib. I like to know is there other way
to create a Type based on return string.

Nov 16 '05 #1
2 3994
da*******@opco.com wrote:
I have web service always return a string in Xml format, and I have the code
at client side translates this return string into correct value. For example:
my web service returns a <ret type=”System.int”>1</ret>.
So my client logic will translate this into integer value of one by using
Type.GetType() function. Likewise, if my web service returns a <ret
type=”System.String”>abc</ret>, my client again translates this into string
type. My problem is when I try to return a System.Data.DataTable in my return
Xml string, and Type.GetType()can not return a System.Data.DataTable type for
me due to System.Data is not in mscorlib. I like to know is there other way
to create a Type based on return string.


You also need the assembly of the type. I'm using the
following method for the type lookup. It simply assumes
that the assembly with the type is already loaded.

public static Type GetType(string typeName)
{
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
Type t = a.GetType(typeName);
if (t != null) return t;
}
return null;
}

bye
Rob
Nov 16 '05 #2
da*******@opco.com <da*************@discussions.microsoft.com> wrote:
I have web service always return a string in Xml format, and I have the code
at client side translates this return string into correct value. For example:
my web service returns a <ret type=?System.int?>1</ret>.
So my client logic will translate this into integer value of one by using
Type.GetType() function. Likewise, if my web service returns a <ret
type=?System.String?>abc</ret>, my client again translates this into string
type. My problem is when I try to return a System.Data.DataTable in my return
Xml string, and Type.GetType()can not return a System.Data.DataTable type for
me due to System.Data is not in mscorlib. I like to know is there other way
to create a Type based on return string.


Please see the responses to your post from September 30th.

If you're actually wanting to specify a value as well, it strikes me
you're likely to need a fixed set of types you support - in which case
you don't need to use reflection at all.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

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

Similar topics

0
by: John Wilson | last post by:
Hello, I have the following code which populates as table data from a SQL Server 2000 stored proc (RSByDemoID2). Below that is the view and stored procedure which takes @DemoID as input to match...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
4
by: Tom | last post by:
Hi .Net Professional : In recent , I starting to learn about dynamic call .net object in vb.net. Before, some IT people teach me use the following method and its work !! Dim asm As =...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
3
by: Henry | last post by:
I know it is possible to store dynamic propterties for applications in XML files. The app.config and the web.config files can be used to store AppSettings... I am just wondering how far one can...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
6
by: jason | last post by:
Hello, I have a question about what kind of datastructure to use. I'm reading collumn based data in the form of: 10\t12\t9\t11\n 24\t11\t4\t10\n ..... I now have a structure which allows me...
15
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works...
3
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row...
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: 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
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...
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,...
0
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...
0
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
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 projectplanning, coding, testing,...
0
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...

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.