Ejemplo n.º 1
0
        internal static List <IPostAction> ListFromModel(ILogger logger, IReadOnlyList <PostActionModel> modelList, IVariableCollection rootVariableCollection)
        {
            List <IPostAction> actionList = new List <IPostAction>();

            if (rootVariableCollection == null)
            {
                rootVariableCollection = new VariableCollection();
            }

            foreach (PostActionModel model in modelList)
            {
                model.EvaluateCondition(logger, rootVariableCollection);

                if (!model.ConditionResult)
                {
                    // Condition on the post action is blank, or not true. Don't include this post action.
                    continue;
                }

                string chosenInstruction = string.Empty;

                if (model.ManualInstructionInfo != null)
                {
                    foreach (ManualInstructionModel modelInstruction in model.ManualInstructionInfo)
                    {
                        if (string.IsNullOrEmpty(modelInstruction.Condition))
                        {
                            // no condition
                            if (string.IsNullOrEmpty(chosenInstruction))
                            {
                                // No condition, and no instruction previously chosen. Take this one.
                                // We don't want a default instruction to override a conditional one.
                                chosenInstruction = modelInstruction.Text;
                            }
                        }
                        else if (modelInstruction.EvaluateCondition(logger, rootVariableCollection))
                        {
                            // condition is not blank and true, take this one. This results in a last-in-wins behaviour for conditions that are true.
                            chosenInstruction = modelInstruction.Text;
                        }
                    }
                }

                IPostAction postAction = new PostAction(
                    model.Description,
                    chosenInstruction,
                    model.ActionId,
                    model.ContinueOnError,
                    model.Args);

                actionList.Add(postAction);
            }

            return(actionList);
        }
Ejemplo n.º 2
0
        public static List <IPostAction> ListFromModel(IEngineEnvironmentSettings environmentSettings, IReadOnlyList <IPostActionModel> modelList, IVariableCollection rootVariableCollection)
        {
            List <IPostAction> actionList = new List <IPostAction>();

            if (rootVariableCollection == null)
            {
                rootVariableCollection = new VariableCollection();
            }

            foreach (IPostActionModel model in modelList)
            {
                model.EvaluateCondition(environmentSettings, rootVariableCollection);

                if (!model.ConditionResult)
                {   // Condition on the post action is blank, or not true. Don't include this post action.
                    continue;
                }

                string chosenInstruction = string.Empty;

                if (model.ManualInstructionInfo != null)
                {
                    foreach (KeyValuePair <string, string> modelInstruction in model.ManualInstructionInfo)
                    {
                        if (string.IsNullOrEmpty(modelInstruction.Value))
                        {     // no condition
                            if (string.IsNullOrEmpty(chosenInstruction))
                            { // No condition, and no instruction previously chosen. Take this one.
                                // We don't want a default instruction to override a conditional one.
                                chosenInstruction = modelInstruction.Key;
                            }
                        }
                        else if (Cpp2StyleEvaluatorDefinition.EvaluateFromString(environmentSettings, modelInstruction.Value, rootVariableCollection))
                        {   // condition is not blank and true, take this one. This results in a last-in-wins behaviour for conditions that are true.
                            chosenInstruction = modelInstruction.Key;
                        }
                    }
                }

                IPostAction postAction = new PostAction()
                {
                    Description        = model.Description,
                    ActionId           = model.ActionId,
                    ContinueOnError    = model.ContinueOnError,
                    Args               = model.Args,
                    ManualInstructions = chosenInstruction,
                    ConfigFile         = model.ConfigFile,
                };

                actionList.Add(postAction);
            }

            return(actionList);
        }
Ejemplo n.º 3
0
 private static ICreationResult GetCreationResult(ILogger logger, IRunnableProjectConfig runnableProjectConfig, IVariableCollection variables)
 {
     return(new CreationResult(
                postActions: PostAction.ListFromModel(logger, runnableProjectConfig.PostActionModels, variables),
                primaryOutputs: CreationPath.ListFromModel(logger, runnableProjectConfig.PrimaryOutputs, variables)));
 }