System.Xml.XmlDictionaryReader.ReadString C# (CSharp) Méthode

ReadString() protected méthode

protected ReadString ( int maxStringContentLength ) : string
maxStringContentLength int
Résultat string
        protected string ReadString(int maxStringContentLength)
        {
            if (this.ReadState != ReadState.Interactive)
                return string.Empty;
            if (this.NodeType != XmlNodeType.Element)
                MoveToElement();
            if (this.NodeType == XmlNodeType.Element)
            {
                if (this.IsEmptyElement)
                    return string.Empty;
                if (!Read())
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidOperation)));
                if (this.NodeType == XmlNodeType.EndElement)
                    return string.Empty;
            }
            StringBuilder sb = null;
            string result = string.Empty;
            while (IsTextNode(this.NodeType))
            {
                string value = this.Value;
                if (result.Length == 0)
                {
                    result = value;
                }
                else
                {
                    if (sb == null)
                        sb = new StringBuilder(result);
                    if (sb.Length > maxStringContentLength - value.Length)
                        XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(this, maxStringContentLength);
                    sb.Append(value);
                }
                if (!Read())
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidOperation)));
            }
            if (sb != null)
                result = sb.ToString();
            if (result.Length > maxStringContentLength)
                XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(this, maxStringContentLength);
            return result;
        }

Same methods

XmlDictionaryReader::ReadString ( ) : string

Usage Example

 public static TotalItemsCountEstimate ReadFrom(XmlDictionaryReader reader)
 {
    reader.ReadStartElement(ElementName, ManagementNamespaces.Namespace);
    int value = XmlConvert.ToInt32(reader.ReadString());
    TotalItemsCountEstimate result = new TotalItemsCountEstimate(value);
    reader.ReadEndElement();
    return result;
 }
All Usage Examples Of System.Xml.XmlDictionaryReader::ReadString