Ejemplo n.º 1
0
        /// <summary>
        /// returns true if DBNull Or Empty String or nothing
        /// </summary>
        /// <param name="oItemValue"></param>
        /// <returns></returns>

        public static bool IsDBNullOrEmpty(object oItemValue)
        {
            bool bRet = false;

            if (oItemValue == null)
            {
                return(true);
            }

#if NET461
            if (System.Convert.IsDBNull(oItemValue))
            {
                return(true);
            }
            if (oItemValue.GetType() == typeof(System.DateTime))
            {
                if (ObjectType.ObjTst(oItemValue, null, false) == 0)
                {
                    bRet = true;
                }
                return(bRet);
            }
#else
            DebugOutputHelper.TracedLine("Convert.IsDBNull Supported only NETStandard 2.0+  ");
#endif // NET461
            if (String.IsNullOrEmpty(oItemValue.ToString()))
            {
                bRet = true;
            }
            return(bRet);
        }
Ejemplo n.º 2
0
        public static bool SetIfNotEmpty(ref object LValue, object Value)
        {
            DebugOutputHelper.TracedLine("not sure that it returns valid ref");
            bool bRet = false;

            if (!DataHelper.IsDBNullOrEmpty(Value))
            {
                LValue = Value;
                bRet   = true;
            }
            return(bRet);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <remarks>
        /// from  http://west-wind.com/weblog/posts/361.aspx
        /// use TextInfo.ToTitleCase(mText.ToLower());
        /// Alternative see From http://aspcode.net/propercase-function-in-c/
        ///	</remarks>
        public static string ToTitleCase(this string input)
        {
            if (input == null)
            {
                return(null);
            }
            input = input.ToLower();
#if !NETSTANDARD1_6
            return(Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(input));
#else //(used by identityServer)
            DebugOutputHelper.TracedLine("Supported only NETStandard 2.0+  ");
            return(input);
#endif // NETSTANDARD1_6
        }
Ejemplo n.º 4
0
        //		'TODO there are too many similar function 'review and re-factor them
        //'Generic method to set not NULL values, similar to SQL Coalesce
        //It is similar to SafeRef class, but also consider DBNull
        //USE ToString_EmptyIfNull if convert to String is required
        //For VBStrings see StringHelper.Coalesce
        public static object Nz(object oItemValue, object oDefault)
        {
            if (oItemValue == null)
            {
                return(oDefault);
            }
#if NET461
            if (Convert.IsDBNull(oItemValue))
            {
                return(oDefault);
            }
#else
            DebugOutputHelper.TracedLine("Convert.IsDBNull Supported only NETStandard 2.0+  ");
#endif // NET461
            //'TODO add DateTime = Nothing as in IsDBNullOrEmpty
            return(oItemValue);
        }