Exemplo n.º 1
0
 public static string ObjectToString(object source, string defValue = "", bool IsRidNullstring = false, string IFvalueToDefault = null)
 {
     if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || (IsRidNullstring && source.ToString().Trim().ToLower() == "null" || IFvalueToDefault == source.ToString().Trim()))
     {
         return(defValue);
     }
     return(source.ToString().Trim());
 }
Exemplo n.º 2
0
        public static DateTime ObjectToDateTime(object source, DateTime defValue)
        {
            DateTime result;

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !DateTime.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 3
0
        public static bool ObjectToBool(object source, bool defValue = false)
        {
            bool result = false;

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !bool.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 4
0
        public static float ObjectToFloat(object source, float defValue = 0.0f)
        {
            float result = 0.0f;

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !float.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 5
0
        public static int ObjectToInt(object source, int defValue = 0)
        {
            int result = 0;

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !int.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 6
0
        public static long ObjectToInt64(object source, long defValue = 0L)
        {
            long result = 0L;

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !long.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 7
0
        public static Decimal ObjectTodecimal(object source, Decimal defValue = 0M)
        {
            Decimal result = new Decimal(0);

            if (TypesHelper.ObjectIsNullOrWhiteSpace(source) || !Decimal.TryParse(source.ToString(), out result))
            {
                return(defValue);
            }
            return(result);
        }
Exemplo n.º 8
0
 public static bool e_IsNullValue(this object source)
 {
     return(TypesHelper.ObjectIsNullOrWhiteSpace(source));
 }