Exemple #1
0
        /// <summary>
        /// Parses the ProjectConfiguration.xml file.
        /// </summary>
        /// <param name="projectConfigurationFile"></param>
        public virtual void ParseProjectConfiguration(string projectConfigurationFile)
        {
            FireStageEvent(StageType.BeforeParseProjectConfiguration);

            var schema = _schemaCollection.GetSchemaByNamespace(CoreConstants.ProjectConfiguration_SchemaNamespace);

            using (var reader = System.IO.File.OpenText(projectConfigurationFile))
            {
                var dummyProject                = new Impl.Project.Project("init", "init", Path.GetDirectoryName(projectConfigurationFile));
                var dummyProjectFile            = new ProjectFile(dummyProject, Path.GetFileName(projectConfigurationFile));
                var projectConfigurationElement = _xmlElementParser.Parse(reader, schema, dummyProjectFile);

                _designModelParser.Parse(projectConfigurationElement, _context.DesignModels);

                var parsedDesignModel = _context.DesignModels.GetByType(CoreConstants.DesignModelType_ProjectConfiguration).FirstOrDefault();

                if (parsedDesignModel == null)
                {
                    throw new ConfigurationException("No project configuration design model found.");
                }

                var projectConfiguration = parsedDesignModel as IProjectConfiguration;

                _context.Configuration = projectConfiguration ?? throw new ConfigurationException("Project configuration object must implement interface IProjectConfiguration");
                _context.Projects      = projectConfiguration.Projects;
            }

            FireStageEvent(StageType.AfterParseProjectConfiguration);
            FireStageEvent(StageType.ValidateProjectConfiguration);
        }