Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Create Two Partial Classes From GAX
 

Create Two Partial Classes From GAX

I currently have a GAX project that creates a class from a database table and puts the new class in a selected folder. What I want to do is the following.

  1. User selects database table (Done)
  2. Create Class object (Done)
  3. Create CRUD sp (Need To Do)
  4. Create strongly typed dataset (Need To Do)

I have steps 1 and 2 done. I know how to do step 3 also.

The strongly typed dataset will have an xsd and its associated code behind needs to be created. My question is.

To create the class I use an AddItemFromString action.

To create the CRUD sp as part of the same recipe do I just create another AddItemFromString action?

For the strongly typed dataset since partial classes are involved, can I create each file separately using a T4 template with AddItemFromString and VS will join them together? Or do I need to do something special?

Thanks,

Gaurav

Gaurav76  Wednesday, July 11, 2007 4:40 PM

Hi Sonu,

You can add a nested file creating your own AddItemFromString action to add the second item.

Basically you can do the same what is doing the AddItemFromString action which is writing the content to a temporary file and then add the content to the project in the following way:

string tempfile = Path.GetTempFileName();

using (StreamWriter sw = new StreamWriter(tempfile, false))

{

sw.WriteLine(this.content);

}

project.ProjectItems.AddFromTemplate(tempfile, "foo.cs");

so, you have to change the project for projectItem which also have a collection of ProjectItems which in fact is the nested child collection.

you code should looks like this:

string tempfile = Path.GetTempFileName();

using (StreamWriter sw = new StreamWriter(tempfile, false))

{

sw.WriteLine(this.content);

}

projectItem.ProjectItems.AddFromTemplate(tempfile, "foo.cs");

where "foo.cs" will be the name of the new item.

You can get the projectItem from the first AddItemFromString action using the output argument ProjectItem.

hope it helps.

jose.

Jose Escrich  Monday, July 30, 2007 3:35 PM

Hi Sonu,

You can add a nested file creating your own AddItemFromString action to add the second item.

Basically you can do the same what is doing the AddItemFromString action which is writing the content to a temporary file and then add the content to the project in the following way:

string tempfile = Path.GetTempFileName();

using (StreamWriter sw = new StreamWriter(tempfile, false))

{

sw.WriteLine(this.content);

}

project.ProjectItems.AddFromTemplate(tempfile, "foo.cs");

so, you have to change the project for projectItem which also have a collection of ProjectItems which in fact is the nested child collection.

you code should looks like this:

string tempfile = Path.GetTempFileName();

using (StreamWriter sw = new StreamWriter(tempfile, false))

{

sw.WriteLine(this.content);

}

projectItem.ProjectItems.AddFromTemplate(tempfile, "foo.cs");

where "foo.cs" will be the name of the new item.

You can get the projectItem from the first AddItemFromString action using the output argument ProjectItem.

hope it helps.

jose.

Jose Escrich  Monday, July 30, 2007 3:35 PM

You can use google to search for other answers

Custom Search

More Threads

• DependentUpon
• How to do simple recipe alteration to solicit additional string for recipe substitution
• Create Typed Dataset with EnvDTE
• GAX not wanting to install
• Licensing issue of Software Factory's Pre-requesites - GAX, GAT etc..
• guidance package startup code
• same problem
• Replacing Project Name
• Error in running setup
• Command Bar to Bound recipe