Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Inline expression for action inputs? Call receipe programmatically?
 

Inline expression for action inputs? Call receipe programmatically?

hi,

couple of questions:

(1)
i'm finding that i'm creating arguments for action inputs that are only used once. e.g. i have classname and maybe 10 actions each creating a file with a slightly different name, say, $(ClassName).Entity.cs, $(ClassName).Data.cs

is there any way to pass in an expression on the actual action input, e.g.

Code Snippet

<Input Name="TargetFileName" Expression="$(ClassName).Data.cs" />


(2)

i have a receipe, which takes a table and generates code in the form of various files over a 7 project solution. what i want to do is create a screen with a grid so i can select multiple tables, how do i call a receipe externally, surpressing the receipe wizard and passing the relevant arguments in. I want to be able to use the same receipe in 2 ways. is this possible???

Cheers!!!

mickdelaney  Thursday, July 12, 2007 9:33 AM
Hi Mick,

1) you can create an action which implements IAttributesConfigurable or inherit from ConfigurableAction in order to able set action input properties as attributes in the action element, like this:
<action name="foo" type="x" TargetFileName="$(ClassName).Data.cs"/>

so, you can evaluate the expression contained there using the ExpressionEvaluationService class using the following snippet...

string expression = "$(ClassName).Data.cs";
ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
IDictionaryService dictservice = GetService(typeof(IDictionaryService)) as IDictionaryService;
string result = evaluator.Evaluate(expression, new ServiceAdapterDictionary(dictservice));

2) regarding this point, there are no way to call a recipe suppressing the gathering service almost if it was already defined in the manifest.
Anyway if you want to execute a recipe manually you could use the RecipeManager class to get an instance of the GuidancePackage where the recipe is and then execute the recipe using the Execute method in the GuidancePackage class..

hth
jose.

Jose Escrich  Thursday, July 12, 2007 8:38 PM
Hi,

for your first question it seems do me it's impossible (schema allow only two attribute for input variable ; action output or recipe argument). You have to declare prior an argument for each of your generated files and take it in input of your action.

for you second question i think you can have a single receipe with a custom action that keep a List of your tables in input (selected with wizard) and in this custom action iteration to call TextTemplateAction and AddItem Action for each item of your list. It seems to me more simple than your approach.

Regards,
MephistoDark  Thursday, July 12, 2007 6:48 PM
Hi Mick,

1) you can create an action which implements IAttributesConfigurable or inherit from ConfigurableAction in order to able set action input properties as attributes in the action element, like this:
<action name="foo" type="x" TargetFileName="$(ClassName).Data.cs"/>

so, you can evaluate the expression contained there using the ExpressionEvaluationService class using the following snippet...

string expression = "$(ClassName).Data.cs";
ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
IDictionaryService dictservice = GetService(typeof(IDictionaryService)) as IDictionaryService;
string result = evaluator.Evaluate(expression, new ServiceAdapterDictionary(dictservice));

2) regarding this point, there are no way to call a recipe suppressing the gathering service almost if it was already defined in the manifest.
Anyway if you want to execute a recipe manually you could use the RecipeManager class to get an instance of the GuidancePackage where the recipe is and then execute the recipe using the Execute method in the GuidancePackage class..

hth
jose.

Jose Escrich  Thursday, July 12, 2007 8:38 PM
cheers jose. much appreciated.
mickdelaney  Friday, July 13, 2007 9:16 AM
Hi jose,

how you can get an instance of the GuidancePackage ?
If I use

RecipeManager rm = new RecipeManager();
GuidancePackage gp = rm.GetPackage("GATSteps09");

IDictionary args = new Hashtable();
args.Add("EntityClassName", dr[0].ToString());
// Replace with actual code
args.Add("HowMany", dr.Table.Columns.Count.ToString());

gp.Execute("AddEntityComplete", args);

GetPackage return null. The Package GATSteps09 is enabled. I've tried with GetInstalledPackages and GetEnabledPackage without any result. Using Reflector I've seen that GetPackage return Components["name"] as GuidancePackage but Components is a 0 lenght collection.

Thanks in advance


Roberto Brunetti
Roberto Brunetti  Tuesday, July 15, 2008 10:47 PM

You can use google to search for other answers

Custom Search

More Threads

• How to install Guidance packages?
• Add website As http://localhost/sitename
• Issue passing input parameters to actions
• How to change which window form get executed first ?
• GAX/GAT 2008 install problem
• I have facing a problem in wix , I have no idea about this
• Why does my SmartClientApplication can only be resized like a mac?
• wizard appearance
• Unable to update Guidance Automation Extensions to new version
• Problem with Package Building (2 projects included as .vstemplate, but references not being resolved)