ToInt64() public static méthode

public static ToInt64 ( string s ) : System.Int64
s string
Résultat System.Int64
Exemple #1
0
 public static long ToInt64(string value)
 {
     try
     {
         return(XmlConvert.ToInt64(value));
     }
     catch (ArgumentException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "Int64", exception));
     }
     catch (FormatException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "Int64", exception));
     }
     catch (OverflowException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "Int64", exception));
     }
 }
        public virtual long [] ReadInt64Array(string localName, string namespaceUri)
        {
            List <long> list = new List <long> ();

            while (true)
            {
                MoveToContent();
                if (NodeType != XmlNodeType.Element)
                {
                    break;
                }
                ReadStartElement(localName, namespaceUri);
                list.Add(XmlConvert.ToInt64(ReadContentAsString()));
                ReadEndElement();
                if (list.Count == Quotas.MaxArrayLength)
                {
                    // FIXME: check if raises an error or not
                    break;
                }
            }
            return(list.ToArray());
        }
Exemple #3
0
 public static long StringToInteger(string value)
 {
     return(XmlConvert.ToInt64(value));
 }
Exemple #4
0
        internal static object StringToObject(Type type, string value)
        {
            if (value == null || value == String.Empty)
            {
                return(DBNull.Value);
            }

            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Boolean:
                return(XmlConvert.ToBoolean(value));

            case TypeCode.Byte:
                return(XmlConvert.ToByte(value));

            case TypeCode.Char:
                return((char)XmlConvert.ToInt32(value));

#if NET_2_0
            case TypeCode.DateTime:
                return(XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Unspecified));
#else
            case TypeCode.DateTime:
                return(XmlConvert.ToDateTime(value));
#endif
            case TypeCode.Decimal:
                return(XmlConvert.ToDecimal(value));

            case TypeCode.Double:
                return(XmlConvert.ToDouble(value));

            case TypeCode.Int16:
                return(XmlConvert.ToInt16(value));

            case TypeCode.Int32:
                return(XmlConvert.ToInt32(value));

            case TypeCode.Int64:
                return(XmlConvert.ToInt64(value));

            case TypeCode.SByte:
                return(XmlConvert.ToSByte(value));

            case TypeCode.Single:
                return(XmlConvert.ToSingle(value));

            case TypeCode.UInt16:
                return(XmlConvert.ToUInt16(value));

            case TypeCode.UInt32:
                return(XmlConvert.ToUInt32(value));

            case TypeCode.UInt64:
                return(XmlConvert.ToUInt64(value));
            }

            if (type == typeof(TimeSpan))
            {
                return(XmlConvert.ToTimeSpan(value));
            }
            if (type == typeof(Guid))
            {
                return(XmlConvert.ToGuid(value));
            }
            if (type == typeof(byte[]))
            {
                return(Convert.FromBase64String(value));
            }

            return(Convert.ChangeType(value, type));
        }
Exemple #5
0
 public static long ItemToInteger(XPathItem value)
 {
     return(XmlConvert.ToInt64(value.Value));
 }