internal static void ExpectNode( IPropertyTreeNavigator reader, PropertyNodeType expect) { if (reader.NodeType != expect) { throw PropertyTreesFailure.ReaderWrongPosition(expect, reader.NodeType); } }
public void throw_before_moved() { PropertyTreeReader pt = LoadContent("beta.xml"); // TODO pt.ReadState Assert.Throws(typeof(PropertyTreeException), () => { PropertyNodeType p = pt.NodeType; }); }
private object ParseExpressions(PropertyNodeType nodeType, string value) { if (nodeType != PropertyNodeType.Property) { return(value); } RuntimeExpression expr; if (ExpressionUtility.TryParse(value, out expr)) { return(expr); } return(value); }
// Return true if an elision was detected private bool PushState(PropertyNodeType nodeType, PropertyNodeType nodeTypeIfAnElision = PropertyNodeType.PropertyTree) { var names = reader.LocalName.Split('-'); var last = _elisionPosition == names.Length - 1; NodeData result = new NodeData(); result._nodeType = last ? nodeType : nodeTypeIfAnElision; result._value = last ? ParseExpressions(nodeType, reader.Value) : null; result._name = names[_elisionPosition]; result._namespace = reader.NamespaceURI; result._express = reader.Prefix.Length > 0; result.LineNumber = readerLineInfoCache.LineNumber; result.LinePosition = readerLineInfoCache.LinePosition; result._baseUri = string.IsNullOrEmpty(reader.BaseURI) ? _baseUri : Utility.NewUri(reader.BaseURI); int position = 0; if (data.Count > 0) { NodeData current = this.data.Peek(); // Replacing a sibling if (current.IsProperty) { this.data.Pop(); position = current._position + 1; } else if (current.IsEndTree) { this.data.Pop(); position = current._position; } // TODO Xmlns could be explicitly reset (xmlns="") (uncommon) if (string.IsNullOrEmpty(result._namespace) && this.data.Count > 0) { result._namespace = this.data.Peek()._namespace; } } result._depth = data.Count; result._position = position; this.data.Push(result); // TODO Merge metadata nodes; handle pt:property return(_elisionPosition < names.Length - 1); }
public override bool MoveToChild(PropertyNodeType nodeType) { return Navigator.MoveToChild(nodeType); }
internal static void ExpectNode( IPropertyTreeNavigator reader, PropertyNodeType expect) { if (reader.NodeType != expect) throw PropertyTreesFailure.ReaderWrongPosition(expect, reader.NodeType); }
public static PropertyTreeException ReaderWrongPosition(PropertyNodeType expect, PropertyNodeType actual) { return Failure.Prepare(new PropertyTreeException(SR.ReaderWrongPosition(expect, actual))); }
public abstract bool MoveToChild(PropertyNodeType nodeType);
public override bool MoveToChild(PropertyNodeType nodeType) { return MoveToChild(node => node.NodeType == nodeType); }
public static PropertyTreeException ReaderWrongPosition(PropertyNodeType expect, PropertyNodeType actual) { return(Failure.Prepare(new PropertyTreeException(SR.ReaderWrongPosition(expect, actual)))); }
void PushState(PropertyNodeType nodeType) { NodeData result = new NodeData(); result._nodeType = nodeType; result._value = reader.Value; result._name = reader.LocalName; result._namespace = reader.NamespaceURI; result._express = reader.Prefix.Length > 0; result.LineNumber = readerLineInfoCache.LineNumber; result.LinePosition = readerLineInfoCache.LinePosition; result._baseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute); int position = 0; if (data.Count > 0) { NodeData current = this.data.Peek(); // Replacing a sibling if (current.IsProperty) { this.data.Pop(); position = current._position + 1; } else if (current.IsEndTree) { this.data.Pop(); position = current._position; } // TODO Xmlns could be explicitly reset (xmlns="") (uncommon) if (string.IsNullOrEmpty(result._namespace) && this.data.Count > 0) result._namespace = this.data.Peek()._namespace; } result._depth = data.Count; result._position = position; this.data.Push(result); // TODO Merge metadata nodes; handle pt:property }