示例#1
0
        /// <summary>
        /// Function: 判断字符串中是否含有双字节字符
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsIncludeDoubleByteChar(this IVerifiableString value)
        {
            if (value.IsNullOrEmpty())
            {
                return(false);
            }
            var str = value.GetValue();

            return(Encoding.Default.GetByteCount(str) > str.Length);
        }
示例#2
0
 /// <summary>
 /// Function: 指示正则表达式使用 pattern 参数中指定的正则表达式是否在输入字符串中找到匹配项
 /// Author:   Leo Shao
 /// Date:     2015-02-26
 /// </summary>
 /// <param name="input">要搜索匹配项的字符串</param>
 /// <param name="pattern">要匹配的正则表达式模式</param>
 /// <param name="options">筛选条件</param>
 /// <exception cref="System.ArgumentNullException">input 为 null。 - 或 - pattern 为 null</exception>
 /// <returns>如果正则表达式找到匹配项,则为 true;否则,为 false</returns>
 public static bool IsMatch(this IVerifiableString input, string pattern, RegexOptions options = RegexOptions.IgnoreCase)
 {
     if (input == null)
     {
         return(false);
     }
     else
     {
         return(Regex.IsMatch(input.GetValue(), pattern, options));
     }
 }
示例#3
0
        /// <summary>
        /// Function: 验证是否为合法的RGB颜色字符串
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        /// <param name="value">RGB颜色,如:#00ccff | #039 | ffffcc</param>
        /// <returns></returns>
        public static bool IsRGBColor(this IVerifiableString value)
        {
            if (value.IsNullOrEmpty())
            {
                return(false);
            }

            Regex re = new Regex(RegexPatterns.RgbColor, RegexOptions.IgnoreCase);

            return(re.IsMatch(value.GetValue()));
        }
示例#4
0
        /// <summary>
        /// Function: 判断字符串是否为64位有符号整数
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsInt64(this IVerifiableString value)
        {
            Int64 i;

            return(Int64.TryParse(value.GetValue(), out i));
        }
示例#5
0
        /// <summary>
        /// Function: 判断字符串是否为32位有符号整数
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsInt(this IVerifiableString value)
        {
            int i;

            return(int.TryParse(value.GetValue(), out i));
        }
示例#6
0
 /// <summary>
 /// Function: 判断字符串是否为null或string.Empty
 /// Author:   Leo Shao
 /// Date:     2015-02-26
 /// </summary>
 /// <param name="value">一个 System.String 引用</param>
 /// <returns>如果 value 参数为 null 或空字符串 (""),则为 true;否则为 false</returns>
 public static bool IsNullOrEmpty(this IVerifiableString value)
 {
     return(string.IsNullOrEmpty(value.GetValue()));
 }
示例#7
0
        /// <summary>
        /// Function: 判断字符串是否为日期
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsDateTime(this IVerifiableString value)
        {
            DateTime i;

            return(DateTime.TryParse(value.GetValue(), out i));
        }
示例#8
0
        /// <summary>
        /// Function: 判断字符串是否为双精度浮点数
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsDouble(this IVerifiableString value)
        {
            double i;

            return(double.TryParse(value.GetValue(), out i));
        }
示例#9
0
        /// <summary>
        /// Function: 判断字符串是否为单精度浮点数
        /// Author:   Leo Shao
        /// Date:     2015-02-26
        /// </summary>
        public static bool IsFloat(this IVerifiableString value)
        {
            float i;

            return(float.TryParse(value.GetValue(), out i));
        }