Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to AddProperty to a C# class at runtime
Message
From
31/07/2007 06:11:39
 
 
To
30/07/2007 21:21:29
General information
Forum:
ASP.NET
Category:
Web Services
Miscellaneous
Thread ID:
01243387
Message ID:
01244796
Views:
36
Hi Bernard

I have reviewed this thread and considered your comments. I think there may be some confusion on your part regarding "XML strings" and "Objects". In an earlier message, you said something along the lines that you could send XML from VFP if you wanted to but, you had to send an "Object" that is serializable, hence the need to do this from .NET and not VFP. Am I right so far?

If I am correct in my assumption, then I would point out that if you are providing a regular SOAP based XML web service for consumption by your client, then all that happens with your .NET object is that it is serialised to XML, so, if you can create XML dynamically, which you clearly can (because I have shown you how to in .NET), then you can effectively construct a .NET object in XML.

So, I guess the next question is, if I was to point my browser at your web service, will it generate a WSDL for me? If so, then we are talking about a regular SOAP web service. If this is the case, then you could still use the Dictionary based approach and simply process it into an XML string that is compliant with the published SOAP schema - in otherwords, create an XML SOAP message and pass it back via the Response object in your XML web service. So, you could do this dynamically in .NET, let alone VFP.

On saying that, I am not sure that creating the design time classes that support the various responses required by your consumer is that much of a big deal. If you know the required permutations, then you simply design the classes around the requirements, although you seem to not want to do this. This is probably a "hangover" from VFP where you can be less rigid with your class design and take short-cuts using things like AddProperty(). However, I suspect most .NET developers would think nothing of designing the classes "up-front". However, if there were multiple permutations that made the design time approach unwieldy, then I would probably do the following:-

Use a dictionary key naming conventions that group items in the dictionary into their associated classes eg., "MEMBER_Name", "Joe Bloggs"; "MEMBER_Phone", "0148 455 788", "CCInfo_CCName", "Andy Capp"; "CCInfo_CCType", "MasterCard".

In this way, if you iterate through the dictionary, you can group items into class-like associations. So, one dictionary containing multiple, identifiable class members. Then pass the dictionary to a class that will generate a well formed, valid SOAP message in XML which is just a string, and send that back via the Response object.

Does this make sense?

BTW, I used Foxpro/VFP for the longest time (along with the Codemine framework for VFP). I haven't used VFP for a few years now, just C#/.NET. When I was a boy (early 70's), I used to live in Perth WA with my parents. We emigrated to Oz in 1970 - the original £10 tourists. I had some of the happiest times I have known in WA. However, my Dad found regular and consistent work hard to come by and after three years, he brought the whole family back to the UK. Had we moved to the Eastern States, who knows, maybe I would still be there now. In the 30+ years since I came back to the UK, my Mam and Dad (now in their seventies) still have many friend in WA and have returned on many occasions every 2-4 years or so. In all that time, I have never been back since I was 11yrs old (the age I was when I left Oz back in late '72). So, it's nice to make an "Oz connection" :)

I have often thought of what life would be like in Oz as a developer. Me and my Wife would both like to live/work in a warmer climate. But, I reckon I am probably a bit too old to "up sticks" (I have a 17 year old daughter and a 10 year old son). Maybe I need to be considerably older to realise this ambition when the kids don't need/don't want us any more :)

I look forward to hearing from you.

Best,
-=Gary
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform