Exemplo n.º 1
0
 public IdentificationHandler(
     IDeviceRepository deviceRepository,
     IUserRepository userRepository,
     IOptions <IdentificationOptions> options)
 {
     _deviceRepository = deviceRepository ?? throw new ArgumentNullException(nameof(deviceRepository));
     _userRepository   = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
     _options          = options.Value;
 }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            IdentificationOptions.IsHttpStatusCode = chbCode.Checked;
            IdentificationOptions.IsRegexPattern   = chbRegex.Checked;
            IdentificationOptions.IsPageCompare    = chbPage.Checked;
            IdentificationOptions.IsHtmlTags       = chbTag.Checked;

            if (IdentificationOptions.IsHttpStatusCode)
            {
                if (clbCode.CheckedItems.Count > 0)
                {
                    IdentificationOptions.HttpStatusCode = string.Empty;
                    CheckedListBox.CheckedItemCollection checkedItems = clbCode.CheckedItems;
                    foreach (object item in checkedItems)
                    {
                        IdentificationOptions.HttpStatusCode += $"{item.ToString().Split(' ')[1]}|";
                    }
                }
                else
                {
                    MessageBox.Show("Please select atleast one item", "Status Code Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (IdentificationOptions.IsHtmlTags)
            {
                if (clbTag.CheckedItems.Count > 0)
                {
                    IdentificationOptions.HtmlTags = string.Empty;
                    CheckedListBox.CheckedItemCollection checkedItems = clbTag.CheckedItems;
                    foreach (object item in checkedItems)
                    {
                        IdentificationOptions.HtmlTags += $"{item}|";
                    }
                }
                else
                {
                    MessageBox.Show("Please select atleast one item", "HTMLTags Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (IdentificationOptions.IsRegexPattern)
            {
                IdentificationOptions.RegexPattern = txtRegex.Text;
                if (!IdentificationOptions.IsValidRegex())
                {
                    IdentificationOptions.IsRegexPattern = false;
                    IdentificationOptions.RegexPattern   = string.Empty;
                    MessageBox.Show("Invalid Pattern!", "Regex Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (IdentificationOptions.IsPageCompare)
            {
                IdentificationOptions.IsPageCompare = true;
                IdentificationOptions.PageCompare   = System.Text.RegularExpressions.Regex.Replace(rtxPage.Text, @"\t|\n|\r", "");
            }

            IdentificationOptions.IsIdentificationOptions = true;
            Close();
        }