Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to AddProperty to a C# class at runtime
Message
 
 
To
25/07/2007 02:59:52
General information
Forum:
ASP.NET
Category:
Web Services
Miscellaneous
Thread ID:
01243387
Message ID:
01243528
Views:
24
>HI
>
>After much reading of rick Strahl's articles, I settled on a method to pass objects fron VFP to a C# Web Service, by exposing all my classes to COM and creating similar classes on the NET side as described in the article. I have the Web service running and passing objects back and forth happily. It was a long exhausting journey of 2 steps forward one step back.
>
>I now have a couple of questions about C#
>
>1. In VFP If I have a class:
>
>
>Define Class RequestObject As Session
>    SessionID = ""
>    MemberID = ""
>    LoginName = ""
>Enddefine
>Define Class MemberCC As Session
>    CCName = ""
>    CCNumber = ""
>    CCExpiry = ""
>    CCType = ""
>EndDefine
>
>
>At runtime I can do this:
>
>
>AddProperty(RequestObject,"oCreditCard")
>This.oCreditCard = Createobject("MemberCC")
>
>
>to get a Complex Class:
>
>RequestObject
>    SessionID = ""
>    MemberID = ""
>    LoginName
>    oCreditCard
>        CCName
>        CCNumber
>        CCExpiry
>        CCType
>
>
>This is very easy to do at the VFP end.
>
>If I have a similar class in C# and want to add a single property say - "newEmail" at runtime
>What is the command to add it to the class below?
>
>
>[Serializable]
>public class RequestObject
>    {
>        public string SessionID = "";
>        public string MemberID = "";
>        public string LoginName = "";
>    }
>
>2. If I have the above class and another class as below :
>
>[Serializable]
>    public class csBankDetails
>    {
>        public string csAcctname = "";
>	    public string csBankacct = "";
>	    public string csBankName = "";
>	    public string csBanksid  = "";
>	    public string csBranchName = "";
>    }
>
>and at runtime I instantiate the RequestObject class and want to add the csBankDetails class to it to create a complex object like below, how can I do that in C# at runtime to get a complex class as below?
>
>
>SessionID
>MemberID
>LoginName
>csBankDetails
>    csAcctname
>    csBankacct
>    csBankName
>    csBanksid
>    csBranchName
>
>The complete logic for my application is in VFP and it would take too long and too much maintenance to convert the logic to C#.
>
>I need to return from the Web Service the RequestObject, except that for some calls I need to add on the CreditCard details and/or Address Details and/or Bank Details. The combinations vary:
>
>Return ResponseObject
>Return ResponseObject wiich will include Customer details like name, DOB, emai, phone etc
>Return ResponseObject + CC Details+ Bank Details
>etc. and combinations of the above and more.
>
>Is this even possible in C#?

Check Re: Dynamically Add a Property...? Thread #1078195 Message #1078249
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform