示例#1
0
        static Options ParseOptions(Options options, string optionString)
        {
            try
            {
                var builder = new DbConnectionStringBuilder();
                builder.ConnectionString = optionString;

                foreach (DictionaryEntry it in (IDictionary)builder)
                {
                    var value = it.Value.ToString();
                    switch (it.Key.ToString())
                    {
                        case "centerheading": options.CenterHeading = bool.Parse(value); break;
                        case "indentcode": options.IndentCode = int.Parse(value); break;
                        case "indentlist": options.IndentList = int.Parse(value); break;
                        case "indentpara": options.IndentPara = int.Parse(value); break;
                        case "indentquote": options.IndentQuote = int.Parse(value); break;
                        case "language": options.Language = value; break;
                        case "margin": options.Margin = int.Parse(value); break;
                        case "plaincode": options.PlainCode = bool.Parse(value); break;
                        case "plainheading": options.PlainHeading = bool.Parse(value); break;
                        case "plugincontents": options.PluginContents = value; break;
                        default: throw new ArgumentException("Unknown option: " + it.Key);
                    }
                }
            }
            catch (Exception e)
            {
                throw new FormatException("Error on parsing HLF options: " + e.Message, e);
            }

            return options;
        }
示例#2
0
        void Comment()
        {
            var match = _reOptions.Match(Reader.Value);
            if (!match.Success)
                return;

            var text = match.Groups[1].Value.TrimEnd();
            if (text.Length == 0)
            {
                // reset to the global
                _options = _globalOptions;
            }
            else if (_topics.Count > 0)
            {
                // update the current
                _options = ParseOptions(_options, text);
            }
            else
            {
                // make the global and current the same
                _globalOptions = ParseOptions(_globalOptions, text);
                _options = _globalOptions;
            }

            // apply
            ProcessOptions();
        }
示例#3
0
        public void Run()
        {
            if (Reader == null || Writer == null) throw new InvalidOperationException();

            // options
            _globalOptions = Options.New();
            _options = _globalOptions;
            ProcessOptions();

            // parse
            while (Reader.Read())
                Node();

            // validate links
            foreach (var link in _links)
            {
                if (!_topics.Contains(link))
                    throw new InvalidDataException(string.Format(ErrMissingTarget, link));
            }
        }