protected virtual void OnReadXml(XmlReader reader) { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } if (!reader.IsStartElement()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", SR.GetString(SR.FilterReaderNotStartElem)); } if (reader.IsEmptyElement) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", SR.GetString(SR.FilterInvalidInner, InnerElem)); } // Pull in the node quota string quotaString = null; //bool found = false; while (reader.MoveToNextAttribute()) { if (QueryDataModel.IsAttribute(reader.NamespaceURI)) { /* * if(found || reader.LocalName != NodeQuotaAttr || reader.NamespaceURI != string.Empty) * { * throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.FilterInvalidAttribute))); * } */ if (reader.LocalName == NodeQuotaAttr && reader.NamespaceURI.Length == 0) { quotaString = reader.Value; //found = true; break; } } } if (reader.NodeType == XmlNodeType.Attribute) { reader.MoveToElement(); } int quota = quotaString == null ? int.MaxValue : int.Parse(quotaString, NumberFormatInfo.InvariantInfo); reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName != InnerElem) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", SR.GetString(SR.FilterInvalidInner, InnerElem)); } ReadFrom(reader, new XPathMessageContext()); reader.MoveToContent(); reader.ReadEndElement(); this.NodeQuota = quota; }
// Assumes that the reader is current parked at the filter's start tag void ReadFrom(XmlReader reader, XmlNamespaceManager namespaces) { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } if (!reader.IsStartElement()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", SR.GetString(SR.FilterReaderNotStartElem)); } bool found = false; string dialect = null; while (reader.MoveToNextAttribute()) { if (QueryDataModel.IsAttribute(reader.NamespaceURI)) { if (found || reader.LocalName != DialectAttr || reader.NamespaceURI != WSEventingNamespace) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.FilterInvalidAttribute))); } dialect = reader.Value; found = true; } } if (reader.NodeType == XmlNodeType.Attribute) { reader.MoveToElement(); } if (dialect != null && dialect != XPathDialect) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.FilterInvalidDialect, XPathDialect))); } bool wasEmpty = reader.IsEmptyElement; reader.ReadStartElement(); if (wasEmpty) { this.Init(string.Empty, namespaces); } else { ReadXPath(reader, namespaces); reader.ReadEndElement(); } }
private void ReadFrom(XmlReader reader, XmlNamespaceManager namespaces) { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } if (!reader.IsStartElement()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", System.ServiceModel.SR.GetString("FilterReaderNotStartElem")); } bool flag = false; string str = null; while (reader.MoveToNextAttribute()) { if (QueryDataModel.IsAttribute(reader.NamespaceURI)) { if ((flag || (reader.LocalName != "Dialect")) || (reader.NamespaceURI != "http://schemas.xmlsoap.org/ws/2004/06/eventing")) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("FilterInvalidAttribute"))); } str = reader.Value; flag = true; } } if (reader.NodeType == XmlNodeType.Attribute) { reader.MoveToElement(); } if ((str != null) && (str != "http://www.w3.org/TR/1999/REC-xpath-19991116")) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("FilterInvalidDialect", new object[] { "http://www.w3.org/TR/1999/REC-xpath-19991116" }))); } bool isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement(); if (isEmptyElement) { this.Init(string.Empty, namespaces); } else { this.ReadXPath(reader, namespaces); reader.ReadEndElement(); } }
protected virtual void OnReadXml(XmlReader reader) { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } if (!reader.IsStartElement()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", System.ServiceModel.SR.GetString("FilterReaderNotStartElem")); } if (reader.IsEmptyElement) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", System.ServiceModel.SR.GetString("FilterInvalidInner", new object[] { "XPath" })); } string s = null; while (reader.MoveToNextAttribute()) { if ((QueryDataModel.IsAttribute(reader.NamespaceURI) && (reader.LocalName == "NodeQuota")) && (reader.NamespaceURI.Length == 0)) { s = reader.Value; break; } } if (reader.NodeType == XmlNodeType.Attribute) { reader.MoveToElement(); } int num = (s == null) ? 0x7fffffff : int.Parse(s, NumberFormatInfo.InvariantInfo); reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName != "XPath") { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("reader", System.ServiceModel.SR.GetString("FilterInvalidInner", new object[] { "XPath" })); } this.ReadFrom(reader, new XPathMessageContext()); reader.MoveToContent(); reader.ReadEndElement(); this.NodeQuota = num; }