示例#1
0
 private static void CheckHexStringOption(GroupCheck group, OptionType type, CheckBox checkBox, TextBox textBox)
 {
     if (checkBox.Checked)
     {
         String text = textBox.Text.Trim();
         if (String.IsNullOrEmpty(text))
         {
             group.Add(Checks.HasOption(type));
         }
         else
         {
             if (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
             {
                 Byte[] bytes = Utils.ToBytes(text);
                 if (bytes != null)
                 {
                     group.Add(Checks.OptionEqual(type, bytes));
                 }
             }
             else
             {
                 group.Add(Checks.OptionEqual(type, text));
             }
         }
     }
 }
示例#2
0
 private static void CheckStringOption(GroupCheck group, OptionType type, CheckBox checkBox, TextBox textBox)
 {
     if (checkBox.Checked)
     {
         String text = textBox.Text.Trim();
         if (String.IsNullOrEmpty(text))
         {
             group.Add(Checks.HasOption(type));
         }
         else
         {
             group.Add(Checks.OptionEqual(type, text));
         }
     }
 }
示例#3
0
        private static void CheckIntOption(GroupCheck group, OptionType type, CheckBox checkBox, TextBox textBox)
        {
            if (checkBox.Checked)
            {
                String text = textBox.Text.Trim();
                Int32  val  = 0;

                if (String.IsNullOrEmpty(text))
                {
                    group.Add(Checks.HasOption(type));
                }
                else if (Int32.TryParse(text, out val))
                {
                    group.Add(Checks.OptionEqual(type, val));
                }
                else
                {
                    group.Add(Checks.OptionEqual(type, text));
                }
            }
        }
示例#4
0
        private void Save()
        {
            GroupCheck group = Step.ResponseCheck as GroupCheck;

            if (group == null)
            {
                group = Checks.Group();
            }
            else
            {
                group.Clear();
            }

            if (cbxCode.SelectedIndex >= 0)
            {
                group.Add(Checks.CodeEqual((Int32)cbxCode.SelectedValue));
            }
            if (cbxType.SelectedIndex >= 0)
            {
                group.Add(Checks.MessageTypeEqual((MessageType)cbxType.SelectedValue));
            }
            if (checkMessageIdMatch.Checked)
            {
                group.Add(Checks.MessageIdMatch());
            }

            if (checkContentType.Checked)
            {
                if (cbxContentType.SelectedIndex > 0)
                {
                    group.Add(Checks.OptionEqual(OptionType.ContentType, (Int32)cbxContentType.SelectedValue));
                }
                else
                {
                    group.Add(Checks.HasOption(OptionType.ContentType));
                }
            }
            if (checkAccept.Checked)
            {
                if (cbAccept.SelectedIndex > 0)
                {
                    group.Add(Checks.OptionEqual(OptionType.Accept, (Int32)cbAccept.SelectedValue));
                }
                else
                {
                    group.Add(Checks.HasOption(OptionType.Accept));
                }
            }

            if (checkPayLoad.Checked)
            {
                string text = txtPayLoad.Text.Trim();
                if (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
                {
                    Byte[] bytes = Utils.ToBytes(text);
                    if (bytes != null)
                    {
                        group.Add(Checks.PayLoadByteEqual(bytes));
                    }
                }
                else if (text.Length > 0)
                {
                    text = text.Replace("\r\n", "\n");
                    group.Add(Checks.PayLoadStringEqual(text));
                }
                else
                {
                    group.Add(Checks.ExistCheckPayLoad());
                }
            }
            if (checkToken.Checked)
            {
                String token = txtToken.Text.Trim();
                if (token.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
                {
                    Byte[] bytes = Utils.ToBytes(token);
                    if (bytes != null)
                    {
                        group.Add(Checks.TokenByteEqual(bytes));
                    }
                }
                else if (token.Length > 0)
                {
                    //group.Add(Checks.TokenStringEqual(token));
                    group.Add(Checks.TokenByteEqual(Encoding.UTF8.GetBytes(token)));
                }
                else
                {
                    group.Add(Checks.ExistCheckToken());
                }
            }
            if (checkETag.Checked)
            {
                String eTag = txtETag.Text.Trim();
                if (eTag.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
                {
                    Byte[] bytes = Utils.ToBytes(eTag);
                    if (bytes != null)
                    {
                        //group.Add(Checks.ETagByteEqual(bytes));
                        group.Add(Checks.OptionEqual(OptionType.ETag, bytes));
                    }
                }
                else if (eTag.Length > 0)
                {
                    //group.Add(Checks.ETagByteEqual(Encoding.UTF8.GetBytes(eTag)));
                    group.Add(Checks.OptionEqual(OptionType.ETag, Encoding.UTF8.GetBytes(eTag)));
                }
                else
                {
                    group.Add(Checks.HasOption(OptionType.ETag));
                }
            }

            CheckStringOption(group, OptionType.LocationPath, checkLocationPath, tbxLocationPath);
            CheckStringOption(group, OptionType.LocationQuery, checkLocationQuery, tbxLocationQuery);
            CheckIntOption(group, OptionType.Observe, checkObserve, tbxObserve);
            //CheckHexStringOption(group, OptionType.Token, checkToken, txtToken);

            CheckStringOption(group, OptionType.UriQuery, checkUriQuery, txtUriQuery);
            CheckStringOption(group, OptionType.UriPath, checkUriPath, txtUriPath);

            CheckIntOption(group, OptionType.Block1, checkBlock1, txtBlock1);
            CheckIntOption(group, OptionType.Block2, checkBlock2, txtBlock2);

            CheckStringOption(group, OptionType.UriHost, checkUriHost, txtUriHost);

            CheckIntOption(group, OptionType.UriPort, checkUriPort, txtUriPort);

            CheckStringOption(group, OptionType.ProxyUri, checkProxyUri, txtProxyUri);

            CheckIntOption(group, OptionType.MaxAge, checkMaxAge, txtMaxAge);

            CheckStringOption(group, OptionType.IfMatch, checkIfMatch, txtIfMatch);
            //CheckStringOption(group, OptionType.ETag,checkETag, txtETag);



            Step.ResponseCheck = group;
        }