Ejemplo n.º 1
0
        internal static void MakeDeepCopies(List <ModelHelperInfo> modelHelperInfos, int cCopies, string directory)
        {
            int cModels = modelHelperInfos.Count;

            for (int iCopy = 0; iCopy < cCopies - 1; iCopy++)
            {
                for (int iModel = 0; iModel < cModels; iModel++)
                {
                    ModelHelperInfo modelHelperInfo     = modelHelperInfos[iModel];
                    ModelHelperInfo modelHelperInfoCopy = ModelHelperInfo.Create(directory);

                    foreach (DeploymentModelStepsStep step in modelHelperInfo.modelHelper.AllSteps)
                    {
                        List <string> commandParamStrings = new List <string>();
                        for (int iCommandParam = 0; iCommandParam < step.CommandParam.Length; iCommandParam++)
                        {
                            commandParamStrings.Add(step.CommandParam[iCommandParam].Name);
                            commandParamStrings.Add(step.CommandParam[iCommandParam].ParameterName);
                        }

                        modelHelperInfoCopy.modelHelper.AddStep(step.Type, step.Command, step.Message, commandParamStrings.ToArray());
                    }

                    IEnumerable <DeploymentModelParametersParameter> dmParams = modelHelperInfo.modelHelper.AllParameters;
                    foreach (DeploymentModelParametersParameter dmParam in dmParams)
                    {
                        modelHelperInfoCopy.modelHelper.AddParameter(dmParam.Name, dmParam.Value, dmParam.Required, dmParam.ValuePrefixRef, dmParam.ValueSuffix);
                    }

                    modelHelperInfos.Add(modelHelperInfoCopy);
                }
            }
        }
Ejemplo n.º 2
0
        private static List <ModelHelperInfo> GetModelsForStepSequence(string[] stepSequence)
        {
            List <ModelHelperInfo> modelHelperInfos = new List <ModelHelperInfo>();

            modelHelperInfos.Add(ModelHelperInfo.Create(_currentDirName)); // initialize with one model

            // add models for every variation of every step
            for (int iCommand = 0; iCommand < stepSequence.Length; iCommand++)
            {
                string commandString = stepSequence[iCommand];

                if (string.IsNullOrEmpty(commandString))
                {
                    continue;
                }

                IEnumerable <DeploymentModelStepsStep> steps = GetStepsForCommand(commandString);

                if ((steps == null) || (steps.Count() == 0))
                {
                    continue;
                }

                // make deep copies of existing models for each step in steps
                ModelHelperInfo.MakeDeepCopies(modelHelperInfos, steps.Count(), _currentDirName);

                // add each step to that many models
                int cModelsPerStep = modelHelperInfos.Count / steps.Count();
                for (int iStep = 0; iStep < steps.Count(); iStep++)
                {
                    for (int iModel = iStep * cModelsPerStep; iModel < ((iStep + 1) * cModelsPerStep); iModel++)
                    {
                        modelHelperInfos[iModel].modelHelper.AddStep(steps.ElementAt(iStep));
                    }
                }
            }

            // now add param values for every variation of param value for every commandParam
            List <ModelHelperInfo> modelHelperInfosNew = new List <ModelHelperInfo>();
            int cModels = modelHelperInfos.Count;

            for (int iModel = 0; iModel < cModels; iModel++)
            {
                modelHelperInfosNew.AddRange(GetModelParamPermutations(modelHelperInfos[iModel]));
            }

            return(modelHelperInfosNew);
        }