Esempio n. 1
0
        public CreationResult CreateModelFrom(IBuildConfiguration buildConfiguration, string modelName)
        {
            try
            {
                var model = _objectBaseFactory.Create <IModel>().WithName(modelName);

                var creationResult = buildProcess(model, buildConfiguration,
                                                  //One function per process step
                                                  checkBuildConfiguration,
                                                  createModelStructure,
                                                  validateModelName,
                                                  createProcesses,
                                                  createObserversAndEvents,
                                                  setQuantitiesValues);

                if (creationResult.State == ValidationState.Invalid)
                {
                    return(creationResult);
                }

                //replace all keywords define in the model structure once all build processes have been executed
                _keywordReplacerTask.ReplaceIn(model.Root);

                creationResult.Add(validateModel(model, buildConfiguration));

                if (creationResult.State == ValidationState.Invalid)
                {
                    return(creationResult);
                }

                finalizeModel(model);

                return(creationResult);
            }
            finally
            {
                buildConfiguration.ClearCache();
            }
        }