|
|
code and logic generation from xml |
|
Author |
Message |
Ashtom

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hi,
Is it possible to generate a working code with a working logic in it from a xml file. If yes then how I have to build a class with methods and attributes from XML on some machine. So machine updates the code in run time and then receives objects from various sources and do some algorithm on them Any idea
Regards Ash
.NET Development12
|
|
|
|
 |
Sinan Ussakli - MSFT

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hi Ash,
System.Reflection might be your friend here.
Sinan
|
|
|
|
 |
Alexey Raga

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Yes, it is possible.
For instance, you can create something like:
< MyType> <Properties> <Property Type="System.String" /> <Property Type="System.Int32" /> </Properties>
<Methods> <Method Type="System.Double" Name="MyMethod">
<Parameters> <Parameter Type="System.Double" Name="firstValue" /> <Parameter Type="System.Double" Name="secondValue" /> </Parameters>
<Logic> You should invent some kind of schema to describe you task </Logic> </Method> </Methods> </MyType>
It can be really difficult to implement a <Logic></Logic> section, but it depends on your task...
You can use CodeDom or Reflection.Emit to build your types on-fly or you can create a tool to generate source code using these files... Depends on your tasks..
Please describe your problem a bit more and we will try to help you :)
|
|
|
|
 |
Dimitre_Novatchev - MSFT

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
The question is too-general, so the answer is of course, yes.
For example, I have a stylesheet, which accepts a definition of a LR language (its rules, sets of terminal and non-terminal symbols, action and goto tables) coded in an xml file and can produce the code (in any programming language) to parse a sentence of the LR language thus defined.
Cheers, Dimitre Novatchev.
|
|
|
|
 |
Ashtom

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hi Thanks for your reply. Here is the summary of what I am doing. I am building a touch screen console in which the gui changes on adhoc basis depending on what user wants(there is no fixed code) so it is a dynamic generation of gui on a remote machine. Which I have sucessfully done using XML and XSD but problem comes where I have to resolve the user inputs to generate some other responses. Where some calculations and other logic is needed by the application. I am looking into what you have said about system.reflection but it will be really helpful if you have some sample with you. Cheers and thanks for looking into it .
Running Against time
Ash
|
|
|
|
 |
Andrew Mayorov

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hi! I guess you want to serialize object to XML form - both data and methods, then transfer it to other machine and deserialize to working object. AFAIK, there are no ready to use mechanisms in the framework that provide such functionality. But it is quite possible. For example by the following scenario:- Write class and compile it to separate assembly.
- Load it to Sender (application that distributes object to other machines), initialize with data and serialize data into the XML format.
- Distribute both serialized data (XML) and compiled assembly (DLL) to all Receivers (computer which mush run this object).
- On Receiver load assembly to separate AppDomain, instantiate object and deserialize data to it. Run a desired object's method.
- Change class code and proceed to step 1.
Best, Andrew Mayorov // BYTE-force
|
|
|
|
 |
Alexey Raga

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hmmm... If it is related just to GUI... Why don't you want to take a look on WPF and XAML
XAML is just some kind of XML file which describes UI and some of this UI behavior. It will be really simple for you to generate XAML files and have a really cool GUI based on your rules, user input, templates, all of them :)
And it is a part of WPF and .NET Framework to manage this XAML, it is already done by Microsoft :)
|
|
|
|
 |
Ashtom

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Thanks for the reply. I am currently looking into it. Probably it is the best solution for a GUI. But to give you a better idea the machine I am talking about is a portable machine placed in a highly specialized and customized optical network. Hence it uses some sort of translation mechanism for messages to talk to other devices on this network. As the other devices on the network are not fixed hence I have to device a dynamic way of talking to each new device added on to the network and I am trying to use XML to scoop me out. Example of these dynamic devices is ipods (mp3 players), Bluetooth or zigbee headphone, speech based remote controls etc. There are quite a lot backend classes that takes care of this interaction.
I was thinking if I build some class on the remote machine using xml (I know how to generate code but building and making it work is still a hazy picture). So the real problem is building a dll from code supplied by xml on remote machine and getting it to work
|
|
|
|
 |
Ashtom

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Thanks for the reply. I am currently looking into it. But to give you a better idea the machine I am talking about is a portable machine placed in a highly specialized and customized optical network. Hence it uses some sort of translation mechanism for messages to talk to other devices on this network. As the other devices on the network are not fixed hence I have to device a dynamic way of talking to each new device added on to the network and I am trying to use XML to scoop me out. Example of these dynamic devices is ipods (mp3 players), Bluetooth or zigbee headphone, speech based remote controls etc. There are quite a lot backend classes that takes care of this interaction.
I was thinking if I build some class on the remote machine using xml (I know how to generate code but building and making it work is still a hazy picture). So the real problem is building a dll from code supplied by xml on remote machine and getting it to work
|
|
|
|
 |
Alexey Raga

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
Hm, if you know how to generate source code and you only have to compile it...
You can use command line (csc.exe) or code like this:
Microsoft.CSharp. CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider(); csProvider.CompileAssemblyFromFile(...);
Just specify some compiler options and a list of files you have generated and want to compile...
|
|
|
|
 |
Ashtom

|
Posted: ASMX Web Services and XML Serialization, code and logic generation from xml |
Top |
thanks for your reply mate I think I am well equiped now.
Cheers
Ash
|
|
|
|
 |
|
|