private void CheckIfEntryIsValid(Entry newEntry)
        {
            EntryType getSelectedEntryType = newEntry.EntryType;
            string    addressToBlock       = newEntry.Url;
            string    addressRedirectTo    = newEntry.RedirectUrl;

            if (!AddressValidationRule.IsCorrectAddress(addressToBlock) &&
                (getSelectedEntryType != EntryType.RegexBlock && getSelectedEntryType != EntryType.RegexRedirect))
            {
                throw new NewEntryException("The address you entered to block is invalid.");
            }
            else if ((getSelectedEntryType == EntryType.RegexBlock || getSelectedEntryType == EntryType.RegexRedirect) &&
                     !AddressValidationRule.IsCorrectRegex(addressToBlock))
            {
                throw new NewEntryException("The regex you entered to match is invalid.");
            }
            else if (AddressValidationRule.IsAddressAlreadyUsed(addressToBlock))
            {
                throw new NewEntryException(
                          "The address you entered to block is already used in this or another profile.");
            }
            else if ((getSelectedEntryType == EntryType.Redirect || getSelectedEntryType == EntryType.RegexRedirect) &&
                     !AddressValidationRule.IsCorrectAddress(addressRedirectTo))
            {
                throw new NewEntryException("The address you entered for redirecting is invalid.");
            }
        }
        private void ValidateUpdatedEntry()
        {
            string addressToBlock                = EntryAddressTextBox.Text;
            string addressNameForRedirect        = EntryRedirectTextBox.Text;
            bool   entryIsEnabled                = EntryIsEnabledCheckbox.IsChecked.Value;
            bool   entrySystemBlockingIsEnabled  = EntryRunsOnSystemLevelCheckbox.IsChecked.Value;
            bool   entryProxyBlockingIsEnabled   = EntryRunsOnProxyLevelCheckbox.IsChecked.Value;
            var    listOfAllAlreadyUsedAddresses = AddressValidationRule.GetListOfAllAlreadyUsedAddresses();

            listOfAllAlreadyUsedAddresses.Remove(_currentEntry.Url);


            if (!AddressValidationRule.IsCorrectAddress(addressToBlock) &&
                (_currentEntry.EntryType != EntryType.RegexBlock && _currentEntry.EntryType != EntryType.RegexRedirect))
            {
                MakeInvalidValueAlert("New entered address name is invalid.");
            }
            else if (listOfAllAlreadyUsedAddresses.Contains(addressToBlock))
            {
                MakeInvalidValueAlert("New entered address is already used.");
            }
            else if ((_currentEntry.EntryType == EntryType.Redirect || _currentEntry.EntryType == EntryType.RegexRedirect) &&
                     !AddressValidationRule.IsCorrectAddress(addressNameForRedirect))
            {
                MakeInvalidValueAlert("Address for redirect is invalid.");
            }
            else if ((_currentEntry.EntryType == EntryType.RegexBlock || _currentEntry.EntryType == EntryType.RegexRedirect) &&
                     !AddressValidationRule.IsCorrectRegex(addressToBlock))
            {
                MakeInvalidValueAlert("Enterd regex is invalid.");
            }
            else
            {
                _currentEntry.Url         = addressToBlock;
                _currentEntry.RedirectUrl = (_currentEntry.EntryType == EntryType.Redirect || _currentEntry.EntryType == EntryType.RegexRedirect) ? addressNameForRedirect : "";
                _currentEntry.IsEnabled   = entryIsEnabled;
                _currentEntry.SystemLevelBlockingIsEnabled = entrySystemBlockingIsEnabled;
                _currentEntry.ProxyBlockingIsEnabled       = entryProxyBlockingIsEnabled;
                _window.Close();
            }
        }