System.Xml.XmlReader.ReadContentAsLong C# (CSharp) Method

ReadContentAsLong() public method

public ReadContentAsLong ( ) : long
return long
        public virtual long ReadContentAsLong()
        {
            if (!CanReadContentAs())
            {
                throw CreateReadContentAsException(nameof(ReadContentAsLong));
            }
            try
            {
                return XmlConvert.ToInt64(InternalReadContentAsString());
            }
            catch (FormatException e)
            {
                throw new XmlException(SR.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo);
            }
        }

Usage Example

        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");

            if (!reader.ReadToFollowing("photos"))
                throw new ResponseXmlException("Unable to find \"photos\" element in response.");

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "maxdisplaypx":
                        MaximumDisplayPixels = reader.ReadContentAsInt();
                        break;
                    case "maxupload":
                        MaximumPhotoUpload = reader.ReadContentAsLong();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            if (!reader.ReadToFollowing("videos"))
                throw new ResponseXmlException("Unable to find \"videos\" element in response.");

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "maxduration":
                        MaximumVideoDuration = reader.ReadContentAsInt();
                        break;
                    case "maxupload":
                        MaximumVideoUpload = reader.ReadContentAsLong();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
All Usage Examples Of System.Xml.XmlReader::ReadContentAsLong