I have a custom utility that generates a Csharp Class file from a xsd which was used in my earlier applications as an AddIn.
I am planning to reuse that utility but through GAT for generating CSharp class files. Can someone help me understand how canI resue that utiltiy in GAT. I don;t want to reinvent the same thing again by writing it in GAT or using xsd.exe.
Solution to this shall be highly appreciated.
Thanks, |
| radenb Thursday, February 28, 2008 4:42 AM |
Hi!
what exactly means an Utility? It's a custom tool?
whatever, what you can do is just create a recipe, bind that recipe to the project for example, and execute your utility. I don't know if your utility is a console application, in that case you should use a Process, otherwise you will can call your utility programatically.
jose.
|
| Jose Escrich Thursday, February 28, 2008 10:56 AM |
Hi radenb,
GAX doesn't provide any built-in support for generating classes from xsd files. There are some factories out there (I believe one of them was early versions of Web Service SF) that included a wrapper around xsd.exe in forms of reusable GAX actions. You may want to look at them.
If you already have the code written to generate classes from xsd files then all you need is to call that code from your GAX Actions or -if it makes sense for your scenario which I don't know- to create a GAX action whose goal is to generate a class based on a xsd file.
There are other ways to generate classes like a T4 transformation (please lookup T4 docs for basic help on this) or CodeDOM. Which one to use depends on several factors.
HTH, -victor.
|
| vga Monday, March 03, 2008 4:20 AM |
re: 1) you can add any code on a custom GAX action you're writing, just add the proper code to use any types/methods from any class library you have also developed. If you want to call custom code from the existing GAX actions, you don't have source code of them, so you will need to inheritance or encapsulation when possible.
re: 2) You will need to create a new GAX action (by inheriting from ConfigurableAction or any other of the base classes for GAX actions, please take a look at the docs for these), most probably you will have two input arguments in your action: the name of the xsd file and the name of the class to be generated. Then you would add proper code in its Execute() method to call your custom code that generates a class based on a xsd file. And lastly, you would have one output argument containing the text of the generated class. Then you have GAX built-in actions that can take text and create a new file on a given project. You will chain this action just after the one you've written so it can use the text generated by your action.
|
| vga Thursday, March 06, 2008 3:25 AM |
Hi!
what exactly means an Utility? It's a custom tool?
whatever, what you can do is just create a recipe, bind that recipe to the project for example, and execute your utility. I don't know if your utility is a console application, in that case you should use a Process, otherwise you will can call your utility programatically.
jose.
|
| Jose Escrich Thursday, February 28, 2008 10:56 AM |
Jose
Custom utiity means a component / dll that generates a csharp file taking xsd as an input.
By the way is there any other better way of generating CSharp file from an xsd using GAT? |
| radenb Thursday, February 28, 2008 1:28 PM |
Hi radenb,
GAX doesn't provide any built-in support for generating classes from xsd files. There are some factories out there (I believe one of them was early versions of Web Service SF) that included a wrapper around xsd.exe in forms of reusable GAX actions. You may want to look at them.
If you already have the code written to generate classes from xsd files then all you need is to call that code from your GAX Actions or -if it makes sense for your scenario which I don't know- to create a GAX action whose goal is to generate a class based on a xsd file.
There are other ways to generate classes like a T4 transformation (please lookup T4 docs for basic help on this) or CodeDOM. Which one to use depends on several factors.
HTH, -victor.
|
| vga Monday, March 03, 2008 4:20 AM |
Thanks Vga.
Since there is lack of enough documentaiton can you give me some pointers on how can I
1) Call my custom code from your GAX Actions
2) Create a custom GAX action whose goal is to generate a class based on a xsd file
Any clues / pointers / references shall be highly appreciated. |
| radenb Monday, March 03, 2008 5:02 AM |
re: 1) you can add any code on a custom GAX action you're writing, just add the proper code to use any types/methods from any class library you have also developed. If you want to call custom code from the existing GAX actions, you don't have source code of them, so you will need to inheritance or encapsulation when possible.
re: 2) You will need to create a new GAX action (by inheriting from ConfigurableAction or any other of the base classes for GAX actions, please take a look at the docs for these), most probably you will have two input arguments in your action: the name of the xsd file and the name of the class to be generated. Then you would add proper code in its Execute() method to call your custom code that generates a class based on a xsd file. And lastly, you would have one output argument containing the text of the generated class. Then you have GAX built-in actions that can take text and create a new file on a given project. You will chain this action just after the one you've written so it can use the text generated by your action.
|
| vga Thursday, March 06, 2008 3:25 AM |
Thanks Vga.
Second options looks more convinent since I have control on the way I want the utility to work.
I will try it out.
Thanks for your pointers. |
| radenb Thursday, March 06, 2008 4:25 AM |