C# Group Templates

Any template questions or comments or suggestions

C# Group Templates

Postby hchattaway on Wed Sep 07, 2005 2:27 am

Hello:

I am trying the group template approach to have 1 template gather the input and then specify it as a group template. I then specify the associated templates in the group dialog box.

I specify the input variables as being public, but they are not being recognized by the other group templates.

Can this approach be used with C# and if so, how? The examples are in JScript for this technique.

Thanks!
Harold
Harold Chattaway
Software Engineer
Speaker at DevConnections Nov 7-10th Las Vegas
hchattaway
Corporal
 
Posts: 21
Joined: Wed Aug 31, 2005 3:58 pm

Postby justin.greenwood on Wed Sep 07, 2005 2:41 am

I am not sure I quite understand your problem. When you aquire input, the input variables must go in the input collection. This happens automatically if you use the Gui controls. If you decide to use a custom windows form to gather your input, you will have to manually add them to the input object.

C#
Code: Select all
// C#
input[\"myInputValue\"] = TextBoxInput.Text;


With a template group, you can actually group templates of any language together. The ZeusContext object is passed to each template before they are executed. There are four primary intrinsic objects that available in templates that are all pulled off of the ZeusContext object: input, output, context, and MyMeta.

C#
Code: Select all
// these two lines do the same thing
input[\"myInputValue\"] = TextBoxInput.Text;
context.Input[\"myInputValue\"] = TextBoxInput.Text;

// these two lines do the same thing
output.write(\"Stuff\");
context.Output.write(\"Stuff\");

// these two lines do the same thing
foreach (ITable table in MyMeta.DefaultDatabase.Tables) {}
foreach (ITable table in ((dbRoot)context.Objects.[\"MyMeta\"]).DefaultDatabase.Tables) {}
User avatar
justin.greenwood
Site Admin
 
Posts: 441
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Postby hchattaway on Wed Sep 07, 2005 1:07 pm

Justin:

I got it working. I did not understand the use of the input collection properly. My \"input collection\" template has no template code now, just interface code. The other templates called have the reference to the input[] collection.

I have one template for generating the ascx file, one for the codebehind, etc. My templates are for DNN and will be pretty smart about generating code.

I'll share them soon!
Thanks
Harold
Harold Chattaway
Software Engineer
Speaker at DevConnections Nov 7-10th Las Vegas
hchattaway
Corporal
 
Posts: 21
Joined: Wed Aug 31, 2005 3:58 pm

Postby mike.griffin on Wed Sep 07, 2005 7:01 pm

hchattaway wrote:I have one template for generating the ascx file, one for the codebehind, etc. My templates are for DNN and will be pretty smart about generating code.

I'll share them soon!


It sounds like you're getting quite a template suite together. Ping us when you post them on the Template Library. You can create an Archive, upload your templates and add your templates to your Achive. Be sure to setup your namespace(s) the way you want them in each template as that is the the directory structure they will come down in when people use the "Globe" icon in the Template Browser dockable window in MyGeneration.
User avatar
mike.griffin
Site Admin
 
Posts: 3290
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN


Return to General Template Questions/Comments

Who is online

Users browsing this forum: No registered users and 2 guests

cron