internal static IValueDocumentItem ParseAsPath(Tokenizer.HeaderTokenMatch token) { switch (token.TokenType) { case Tokenizer.HeaderArgumentType.String: return(new ContentDocumentItem(token.Value) { ExpressionStart = token.TokenLocation }); case Tokenizer.HeaderArgumentType.Expression: if (token.Arguments.Any()) { var list = new List <Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> >(); foreach (var e in token.Arguments) { list.Add(new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem>(e, ParseAsPath(e))); } return(new CallFormatterDocumentItem(list .ToArray(), token.Value)); } else { return(new PathDocumentItem(token.Value, false)); } default: throw new ArgumentOutOfRangeException(); } }
internal static List <Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> > ReadListOfFormatString(XmlReader reader, string property) { AssertElement(reader, property); var formatString = new List <Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> >(); reader.ReadStartElement(); //Argument while (reader.NodeType != XmlNodeType.EndElement || !reader.Name.Equals(property)) { AssertElement(reader, "Argument"); var formatStr = new Tokenizer.HeaderTokenMatch(); formatStr.ArgumentName = reader.GetAttribute("Name"); reader.ReadStartElement(); //Content var child = DocumentExtenstions.CreateDocumentValueItemInstance(reader.Name); var childTree = reader.ReadSubtree(); childTree.Read(); child.ReadXml(childTree); reader.Skip(); reader.ReadEndElement(); //Argument formatString.Add(new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem>(formatStr, child)); } return(formatString); }
/// <inheritdoc /> protected override void DeSerializeXml(XmlReader reader) { base.DeSerializeXml(reader); if (reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals(nameof(Value))) { reader.ReadEndElement(); //end of value } if (reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals(GetType().Name)) { FormatString = new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> [0]; return; } AssertElement(reader, nameof(TargetFormatterName)); if (!reader.IsEmptyElement) { reader.ReadStartElement(); //start of TargetFormatterName TargetFormatterName = reader.ReadString(); reader.ReadEndElement(); //end of TargetFormatterName } else { TargetFormatterName = null; reader.ReadStartElement(); //end of TargetFormatterName } if (reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals(GetType().Name)) { FormatString = new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> [0]; return; } AssertElement(reader, nameof(FormatString)); var formatString = new List <Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem> >(); reader.ReadStartElement(); //Argument while (reader.NodeType != XmlNodeType.EndElement || !reader.Name.Equals(nameof(FormatString))) { AssertElement(reader, "Argument"); var formatStr = new Tokenizer.HeaderTokenMatch(); formatStr.ArgumentName = reader.GetAttribute("Name"); reader.ReadStartElement(); //Content var child = DocumentExtenstions.CreateDocumentValueItemInstance(reader.Name); var childTree = reader.ReadSubtree(); childTree.Read(); child.ReadXml(childTree); reader.Skip(); reader.ReadEndElement(); //Argument formatString.Add(new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem>(formatStr, child)); } FormatString = formatString.ToArray(); }
internal static IValueDocumentItem ParseAsPath(Tokenizer.HeaderTokenMatch token) { switch (token.TokenType) { case Tokenizer.HeaderArgumentType.String: return(new ContentDocumentItem(token.Value) { ExpressionStart = token.TokenLocation }); case Tokenizer.HeaderArgumentType.Expression: return(new CallFormatterDocumentItem(token .Arguments .Select(e => new Tuple <Tokenizer.HeaderTokenMatch, IValueDocumentItem>(e, ParseAsPath(e))) .ToArray(), token.Value)); default: throw new ArgumentOutOfRangeException(); } }