Declaratively determining if an action runs, or a item template unfolds

Is it possible to declaratively determine if an action runs, or a template unfolds

< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

I would like to be able to use a boolean argument (populated from a wizard) to decide if a common action is run or not, without resorting to code.
Is this possible

 

Thanks



Answer this question

Declaratively determining if an action runs, or a item template unfolds

  • annag

    We don't have such an attribute on any action, but you could fairly easily create your own "ConditionalAction" base class with this capability. The steps would be:

    1 - Create an abstract IAction-implementing action, like "ConditionalAction".
    2 - Implemement IConfigurable interface
    3 - Receive and store an attribute of your choice with the condition, such as "Condition"
    4 - Implementations of Execute and Undo should: a) evaluate the condition, and if true, b) call an OnExecute or OnUndo abstract method, to be implemented by derived classes.
    5 - Evaluation of the condition can be achieved through a service implementation provided by the framework. The code would look like the following:

    private bool ShouldExecute(string expression)
    {
          ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
          IDictionaryService dictservice = (IDictionaryService)
                ServiceHelper.GetService(this, typeof(IDictionaryService));
          return (bool) evaluator.Evaluate(expression, new ServiceAdapterDictionary(dictservice));
    }

    The evaluation service is the same one used by the ExpressionEvaluatorValueProvider, which is similar to the syntax of MSBuild properties: $(ArgumentName.APropertyMaybeOfTheArgumentValue)

    If the argument is a boolean, the first segment of the expression is all you need: "$(BoolArgument)".

    HTH


  • Akhraden

    I couldn't resolve the interface IConfigurable to any library in the GAT/X, .NET, but would these two bases be an alternative

    • Microsoft.Practices.Common.IAttributesConfigurable

    • Microsoft.Practices.RecipeFramework.ConfigurableAction


  • John Hennesey

    Apols for not being clear.

    For example: I have a boolean argument. It is populated by a wizard with a UI label like 'Would you like a help page generated '.  I use common actions to generate the help page. Could i turn off my 'GenerateHelpPage' action without using code ie is there a 'RunThisAction' parameter that takes a boolean arguement

    Thanks

  • Roger Cheng - MSFT

    If you mean to declare what to do when an action fails, then the answer is No. GAX executes all actions in a sequence and if any of them fails, it tries reversing the ones already executed.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     

    I don't quite understand what you mean when you say "I would like to be able to use a boolean argument populated from a wizard". Can you describe the scenario in bit more detail  

    -- Wojtek  



  • Declaratively determining if an action runs, or a item template unfolds