Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static AOption processOptionToken(ParsingContext context, IDocumentTemplate template, OptionToken optionToken)
- {
- if (context.CurrentSection == null)
- throw new FormatException($"Option \"{optionToken.Identifier}\" does not belong to any section");
- // TODO option requires separate value parsing
- // at first we try to get the type from teplate. If its not there, then we use string.
- var optionType = template.GetOptionTypeOrThrow(context.CurrentSection.Identifier, optionToken.Identifier);
- var option = parseOptionAccordingToType(optionToken, optionType);
- //context.AddOption(option);
- return option;
- }
- //test
- [TestMethod]
- public void ParseStringValues()
- {
- ITokenParser tokenParser = new TokenParser();
- var parserResult = tokenParser.TryParseOption("Options=this,is,string", 1, out OptionToken optionToken);
- var parsingContext = new ParsingContext(new WinIniDocument());
- ConfigLoader.Builders.Templates.DocumentTemplate.RelaxedDocumentTemplate doc = new ConfigLoader.Builders.Templates.DocumentTemplate.RelaxedDocumentTemplate();
- AOption aopt = OptionParser.processOptionToken(parsingContext, doc, optionToken);
- StringOption sa = (StringOption)aopt;
- Assert.AreEqual("Options", sa.Identifier);
- Assert.AreEqual("this", sa[0]);
- Assert.AreEqual("is", sa[1]);
- Assert.AreEqual("string", sa[2]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement