示例#1
0
        public void Compile(string[] lines, Preprocessor preprocessor)
        {
            _settingAttributesParser.Parse(lines);

            HelpsTitle = _settingAttributesParser.GetSingleValue(AttributesTitle);

            var output_values = _settingAttributesParser.GetValues(AttributesOutput);

            ChmOutput  = output_values.Contains(OutputValueChm);
            HtmlOutput = output_values.Contains(OutputValueHtml);
            PdfOutput  = output_values.Contains(OutputValuePdf);

            DefaultTopic  = (ChmOutput || HtmlOutput) ? preprocessor.GetTopic(GetRequiredTopic(AttributesDefaultTopic)) : null;
            PdfCoverTopic = PdfOutput ? preprocessor.GetTopic(GetRequiredTopic(AttributesPdfCoverTopic)) : null;

            _definitions = new Dictionary <string, string>();

            // add the definitions in the settings file
            foreach (var kp in _settingAttributesParser.GetPairs())
            {
                if (_settingsAttributes.FirstOrDefault(x => (kp.Key == x.Name)) == null)
                {
                    _definitions.Add(kp.Key, kp.Value[0]);
                }
            }

            foreach (var definitionFilename in _settingAttributesParser.GetValues(AttributesDefinitionsFile))
            {
                _definitionAttributesParser.Parse(File.ReadAllLines(definitionFilename));

                foreach (var kp in _definitionAttributesParser.GetPairs())
                {
                    if (_definitions.ContainsKey(kp.Key))
                    {
                        throw new Exception($"The definition {kp.Key} cannot be specified in multiple files");
                    }

                    _definitions.Add(kp.Key, kp.Value[0]);
                }
            }

            // add the resource header IDs
            _resourceIdSet = new ResourceIdSet();

            foreach (var resourceFileProjectName in _settingAttributesParser.GetValues(AttributesResourceFile))
            {
                _resourceIdSet.AddProject(resourceFileProjectName);
            }
        }
示例#2
0
        public void Compile(string[] lines, Preprocessor preprocessor)
        {
            _settingAttributesParser.Parse(lines);

            HelpsTitle = _settingAttributesParser.GetSingleValue(AttributesTitle);

            var output_values = _settingAttributesParser.GetValues(AttributesOutput);

            ChmOutput  = output_values.Contains(OutputValueChm);
            HtmlOutput = output_values.Contains(OutputValueHtml);
            PdfOutput  = output_values.Contains(OutputValuePdf);

            DefaultTopic  = (ChmOutput || HtmlOutput) ? preprocessor.GetTopic(GetRequiredTopic(AttributesDefaultTopic)) : null;
            PdfCoverTopic = PdfOutput ? preprocessor.GetTopic(GetRequiredTopic(AttributesPdfCoverTopic)) : null;

            _definitions = new Dictionary <string, string>();

            // add the definitions in the settings file
            foreach (var kp in _settingAttributesParser.GetPairs())
            {
                if (_settingsAttributes.FirstOrDefault(x => (kp.Key == x.Name)) == null)
                {
                    _definitions.Add(kp.Key, kp.Value[0]);
                }
            }

            foreach (var definitionFilename in _settingAttributesParser.GetValues(AttributesDefinitionsFile))
            {
                _definitionAttributesParser.Parse(File.ReadAllLines(definitionFilename));

                foreach (var kp in _definitionAttributesParser.GetPairs())
                {
                    if (_definitions.ContainsKey(kp.Key))
                    {
                        throw new Exception($"The definition {kp.Key} cannot be specified in multiple files");
                    }

                    _definitions.Add(kp.Key, kp.Value[0]);
                }
            }

            _resourceFiles   = new List <string>();
            _resourceFileIds = new HashSet <string>();

            foreach (string resourceFilename in _settingAttributesParser.GetValues(AttributesResourceFile))
            {
                string evaluatedResourceFilename = EvaluateResourceFilename(resourceFilename);

                if (File.Exists(evaluatedResourceFilename))
                {
                    _resourceFiles.Add(evaluatedResourceFilename);
                    ProcessResourceFile(evaluatedResourceFilename);
                }

                else
                {
                    throw new Exception(String.Format("The resource file could not be located: {0}{1}", evaluatedResourceFilename,
                                                      (_resourceFileRootDirectory == null) ? ("\r\n\r\nPerhaps add a resource file root directory specification file with the name " + Colorizer.Constants.ResourceFileRootDirectoryFilename) : ""));
                }
            }
        }