Get Xml value as Integer 64 : Base64 « Development Class « C# / C Sharp






Get Xml value as Integer 64

 
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Linq;

public static class XmlUtility
{

    public static long? GetValueAsInt64(this XAttribute attribute)
    {
        long result;

        return (attribute != null) &&
            long.TryParse(attribute.Value, out result) ?
            result : (long?)null;
    }

    public static long? GetValueAsInt64(
        this XAttribute attribute,
        IFormatProvider formatProvider)
    {
        Debug.Assert(formatProvider != null, "formatProvider is null.");

        long result;

        return (attribute != null) &&
            long.TryParse(attribute.Value,
                NumberStyles.Integer,
                formatProvider,
                out result) ?
            result : (long?)null;
    }

    public static long? GetValueAsInt64(this XElement element)
    {
        long result;

        return (element != null) &&
            long.TryParse(element.Value, out result) ?
            result : (long?)null;
    }

    public static long? GetValueAsInt64(
        this XElement element,
        IFormatProvider formatProvider)
    {
        Debug.Assert(formatProvider != null, "formatProvider is null.");

        long result;

        return (element != null) &&
            long.TryParse(
                element.Value,
                NumberStyles.Integer,
                formatProvider,
                out result) ?
            result : (long?)null;
    }
}

   
  








Related examples in the same category

1.Double To Int 64 Bits, Int 64 Bits To Double
2.Base 64 encode
3.Base64 Encoder
4.Url Encode Base 64
5.The Base64 utility class performs base64 encoding and decoding.
6.The Base64 utility class performs base64 encoding and decoding. The resulting binary data is returned as an array of bytes.
7.Decodes all or part of the input base64 encoded StringBuffer
8.Encode To 64
9.Encrypt Key and Decrypt Key with Convert.ToBase64String and Convert.FromBase64String
10.Base64 Serializer
11.Serializes and deserializes an entity to a base 64 string
12.Base64 from http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#Java
13.Convert To Base 64 String
14.Create a hex string from an Int64 value