コード例 #1
0
 /// <summary>
 /// Converter uma string em Double
 /// </summary>
 /// <param colName="o"></param>
 /// <returns></returns>
 public static Double ToDouble(object stringValue)
 {
     if (IsValidText(stringValue))
     {
         try
         {
             stringValue = stringValue.ToString().Replace(".", ",");
             return(Convert.ToDouble(stringValue));
         }
         catch (OverflowException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
         catch (FormatException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
     }
     return(0.0d);
 }
コード例 #2
0
 /// <summary>
 /// Converter uma string em Float
 /// </summary>
 /// <param colName="o"></param>
 /// <returns></returns>
 public static Single ToFloat(object stringValue)
 {
     if (IsValidText(stringValue))
     {
         try
         {
             //stringValue = stringValue.ToString().Replace(".", ",");
             stringValue = prepareStringToConvertDecimal(stringValue);
             return(Convert.ToSingle(stringValue));
         }
         catch (OverflowException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
         catch (FormatException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
     }
     return(0.0f);
 }
コード例 #3
0
        /// <summary>
        /// Cria uma imagem a partir do arquivo informado.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static Image CreateImage(string file)
        {
            try
            {
                using (var ms = new MemoryStream())
                {
                    var imfFormart = System.Drawing.Imaging.ImageFormat.Jpeg;
                    var bmp        = new Bitmap(file);
                    return(bmp);
                }
            }

            //  The System.Drawing.Image this method creates.
            //T: System.OutOfMemoryException:
            //T: System.IO.FileNotFoundException:
            //T: System.ArgumentException:
            catch (Exception ex)
            {
                LoggerUtilIts.ShowExceptionLogs(ex);
                return(null);
            }
        }
コード例 #4
0
 /// <summary>
 /// Converter a string em número inteiro (long)
 /// </summary>
 /// <param colName="o"></param>
 /// <returns></returns>
 public static long ToLong(object stringValue)
 {
     if (IsValidText(stringValue))
     {
         try
         {
             return(Convert.ToInt64(stringValue));
         }
         catch (OverflowException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
         catch (FormatException ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
             return(-1);
         }
         catch (Exception ex)
         {
             LoggerUtilIts.ShowExceptionLogs(ex);
         }
     }
     return(0);
 }