Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > How to pass arguments to Action programatically?
 

How to pass arguments to Action programatically?

 

Hi,

 

I have a problem how to pass arguments by executing action from another action programatically.

Values passed by Execute() method of IActionExecutionService are ignored,

I can't override argument from XML file and pass it to action Inputs.

What I'm doing wrong?

I set name and type of item in dictionary correctly:

public override void Execute()

{

Dictionary<string, object> arguments = new Dictionary<string, object>();

arguments.Add("HelloMessage", (object)"someobject");

IActionExecutionService executor = GetService<IActionExecutionService>(true);

executor.Execute("HelloWorldAction", arguments);

 

 

I need this solution to iterate recipe argument of type ArrayList and execute action for each value.

Maybe someone has correct solution for that?

I read on this forum about thitdparty solution for such action, but I would like to implement it only using GAT.

Wojtek

 

 

Wojtek  Monday, January 15, 2007 11:27 PM
If you're using plain GAX without any extensions then you shouldn't need to deal with IActionExecutionService directly...

Take a look at the IRecipeManagerService interface, it is exposed as a VS service by GAX, so you need to ask for it and then use it to get to a package and then from that package call .Execute passing it the recipe name and its arguments.

-Victor.
vga  Tuesday, January 16, 2007 4:35 AM
If you're using plain GAX without any extensions then you shouldn't need to deal with IActionExecutionService directly...

Take a look at the IRecipeManagerService interface, it is exposed as a VS service by GAX, so you need to ask for it and then use it to get to a package and then from that package call .Execute passing it the recipe name and its arguments.

-Victor.
vga  Tuesday, January 16, 2007 4:35 AM

Hi,

what about making the parameters output properties of the first action and input properties of the second one? Wouldn't that be the "correct approach"?

  • Passing arguments in a proprietary way couples both actions tighly together, each depends on the other, none can be used alone. Why not write one action in the first place?
  • Using input/output properties is the existing way arguments are passed to and from actions. It decouples both actions, neither has to know where the information came from and where it is going, thus this approach improves reuse.

Just my 0,02â‚?

Regards,
Alexander

AlexanderJ  Tuesday, January 16, 2007 8:20 AM

Thank you for answer,

I can't find information about this IRecipeManagerService interface in GAT documentation.

I solve already my problem by implementing IActionCoordinationServiceexactly for my specific recipe :)

I gather arguments in for of ArrayList in custom wizard.

Then I implement IActionCoordinationService.

1) Readmy attributearrayList from recipe usings

DictionaryService dictService = (IDictionaryService)GetService(typeof(IDictionaryService));

ArrayList classes = ((ArrayList)dictService.GetValue(CLASS_NAMES_ATT_NAME));

2) Instantiate my actions:

Action generateClassAction;

declaredActions.TryGetValue(GENERATE_CLASS_ACTION_NAME, out generateClassAction);

3) For each value in ArrayList I update argument for my actions using

foreach (XmlAttribute att in generateClassAction.AnyAttr)

{

att.Value = "soem new value"

}

4) Execute my action with specified arguments

exec.Execute(generateClassAction,Name

Wojtek  Tuesday, January 16, 2007 1:27 PM

Hi Alexander,

Thank you but your solution can't help me.

I must execute action to generate file from template many times based on data gathered in wizard

I solved already my problem.

Wojtek

Wojtek  Tuesday, January 16, 2007 1:30 PM
Hi

I have a similar problem.. I'm also using IActionCoordinationService becausei need to repeat my actions many times. But now I need to reload an argument that is allready loaded before I'm using IActionCoordinationService. My question is it possible to reload an argument during an execution of a recipe or action? I have custom classes where I can maybe trigger this event but how to do it?

any help would be verry welcome.. thx

Greets
Agostin
Agostin  Wednesday, May 20, 2009 7:48 AM

You can use google to search for other answers

Custom Search

More Threads

• Get Full Path for Project Item...
• Reality Check?
• Registering guidance with the experimental hive
• Localization on Recipe Captions?
• Error unfolding project template
• Linking the Smart Client Software Factory with GuidanceAutomationExtensions
• Is GAT dead?
• FolderAdd
• How to incorporate data access package into custom package
• Bullet points for building a guidance automation package from scratch.