コード例 #1
0
        /// <summary>
        /// 判断输入的字符串是否是合法的IPV6 地址
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool IsIPV6(string input)
        {
            string pattern = "";
            string temp    = input;

            string[] strs = temp.Split(new char[] { ':' });
            if (strs.Length > 8)
            {
                return(false);
            }
            int count = RegexDao.GetStringCount(input, "::");

            if (count > 1)
            {
                return(false);
            }
            else if (count == 0)
            {
                pattern = @"^([\da-f]{1,4}:){7}[\da-f]{1,4}$";
                return(IsMatch(pattern, input));
            }
            else
            {
                pattern = @"^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$";
                return(IsMatch(pattern, input));
            }
        }
コード例 #2
0
 private void txt_PauseTime_Validating(object sender, CancelEventArgs e)
 {
     //如果是越野时间验证
     if (MatchConfigID == 7)
     {
         string  pattern = @"^\d{1,2}'\d{2}''$";
         TextBox tb      = (TextBox)sender;
         if (tb.Text.ToString().Length != 0 &&
             !RegexDao.IsMatch(pattern, tb.Text.ToString()))
         {
             e.Cancel = true;
         }
     }
     //如果是场地障碍时间验证
     else
     {
         string  pattern = @"^\d{1,3}\.?\d{0,3}$";
         TextBox tb      = (TextBox)sender;
         if (tb.Text.ToString().Length != 0 &&
             !RegexDao.IsMatch(pattern, tb.Text.ToString()))
         {
             e.Cancel = true;
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 静态实例化单体模式
 /// 保证应用程序操作某一全局对象,让其保持一致而产生的对象
 /// </summary>
 /// <returns></returns>
 public static RegexDao GetInstance()
 {
     if (RegexDao.instance == null)
     {
         RegexDao.instance = new RegexDao();
     }
     return(RegexDao.instance);
 }
コード例 #4
0
        private void dgvMatchConfig_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_RiderInterval" &&
                e.FormattedValue != null)
            {//DateTime
                DateTime dtOut;
                if (e.FormattedValue.ToString().Length != 0 &&
                    !DateTime.TryParse(e.FormattedValue.ToString(), out dtOut))
                {
                    e.Cancel = true;
                }
            }
            else if (dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_Judge" &&
                     e.FormattedValue != null)
            {//E,H,C,M,B
            }
            else if (dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_Type" &&
                     e.FormattedValue != null)
            {//text
            }
            else if (dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_Penalties" &&
                     e.FormattedValue != null)
            {//float
                float fOut = 0;
                if (e.FormattedValue.ToString().Length != 0 &&
                    !float.TryParse(e.FormattedValue.ToString(), out fOut))
                {
                    e.Cancel = true;
                }
            }
            //else if ((dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_AddResult"
            //    || dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_AddResultTeam")
            //     && e.FormattedValue != null)
            //{//只包含数字,且数字间使用","隔开的字符串
            //    string pattern = @"^([1-9]\d*,)*[1-9]\d*$";
            //    if (e.FormattedValue.ToString().Length != 0 &&
            //        !RegexDao.IsMatch(pattern, e.FormattedValue.ToString()))
            //        e.Cancel = true;

            //}
            else if (dgvMatchConfig.Columns[e.ColumnIndex].Name == "F_TimeAllowed" &&
                     e.FormattedValue != null &&
                     m_iMatchConfigID == 7)
            {
                string pattern = @"^\d{1,2}'\d{2}''$";
                if (e.FormattedValue.ToString().Length != 0 &&
                    !RegexDao.IsMatch(pattern, e.FormattedValue.ToString()))
                {
                    e.Cancel = true;
                }
            }
            else
            {//int
                int nOut;
                if (e.FormattedValue.ToString().Length != 0 &&
                    !int.TryParse(e.FormattedValue.ToString(), out nOut))
                {
                    e.Cancel = true;
                }
            }
        }