Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Programatically Executing a recipe while changing an input argument
 

Programatically Executing a recipe while changing an input argument

Hi,

I found several related topics but none with an answer to this problem.

I have a recipe adding an item to a project. The item's name is an input parameter getting its value from a wizard, easy enough.

Now I want to reuse this recipe from code, looping over an XML file, and for multiple names found execute the existing recipe while overriding the name argument.

Using reuse by xi:includes, I can create a new recipe that mirrors the original but without the wizard. An action from another recipe needs to execute this new recipe.

Now I know it is not possible to execute a recipe from within an action (unless it is in another package), so I find the recipe and try to execute its actions using the IActionExecutionService. Not trivial because it needs a dictionary with the fully evaluated arguments, but maybe it is ?

Other option would be to addthe action to this new recipe and have this execute theother actions. Now the dictionary I need is present, only how do I change one of its values before calling .Execute(action); ? It seems to be read-only.

Any help would be greatly appreciated, I'm on a tight schedule to have this working (15/10)...

Michel.

mliesmons  Wednesday, October 11, 2006 5:10 PM
I think you could use the IACtionExecutionService, and wrap the IDictionaryService that you can using GetService in a custom dictionary of yours that provides the ability to add/change existing values. It would basically be a fallback-like dictionary that would keep its own internal list of values, and when retrieved, if a key is not found in itself, would pass the call to the wrapped IDictionaryService. That way you would be able to provide changed values.
kzu  Thursday, October 12, 2006 12:15 PM
I think you could use the IACtionExecutionService, and wrap the IDictionaryService that you can using GetService in a custom dictionary of yours that provides the ability to add/change existing values. It would basically be a fallback-like dictionary that would keep its own internal list of values, and when retrieved, if a key is not found in itself, would pass the call to the wrapped IDictionaryService. That way you would be able to provide changed values.
kzu  Thursday, October 12, 2006 12:15 PM

Hi Daniel,

Thanks for your reply.

Wrapping will not really work in this case 'cause nobody asks for the argumentvalues by key.

If you use .Execute(actionName), the values from the IDictionaryService are used,

if you use .Execute(actionName, dictionary), obviously the ones from dictionary are used.

The whole problem was finding out what dictionary was supposed to contain. My first attempt was to copy only the input arguments needed for the action being called, but that was not enough. Now I simplly take a copy of the IDictionaryService-provided values, overwrite the values I want to change, and pass this dictionary to .Execute.

As IDictionaryService does not have an enumerator, I look up the values to copy by using thenames from IConfigurationService.CurrentRecipe.Arguments[].

kr,

Michel.

mliesmons  Thursday, October 12, 2006 2:56 PM

You can use google to search for other answers

Custom Search

More Threads

• Service Factory ( Data Access ) - Handling with transactions
• Set version for Guidance Package
• Access Denied Error while installing custom Guidance package
• Target solution assemblies get loaded on the guidance package on runtime
• Visual Studio 2008 Smart Client software Factory
• Workaround for the UnfoldTemplateAction and parameter replacements
• Unable to install GAX/GAT
• How to find a NULL in a dataset ?
• Question about Arguments
• Using Experimental Hive