SIPSorcery.SimpleWizardInRuleControl.SetRuleToMatchFields C# (CSharp) Method

SetRuleToMatchFields() private method

Sets the To header match portions of the simple wizard rule based on the UI values.
private SetRuleToMatchFields ( SimpleWizardRule rule ) : string
rule SIPSorcery.Entities.SimpleWizardRule
return string
        private string SetRuleToMatchFields(SimpleWizardRule rule)
        {
            if (m_toMatchType.SelectedValue == null)
            {
                return "A To matching choice must be specified.";
            }
            else
            {
                rule.ToMatchType = ((TextBlock)m_toMatchType.SelectedValue).Text;
            }

            if (rule.SimpleWizardToMatchType == SimpleWizardToMatchTypes.ToSIPAccount)
            {
                rule.ToMatchParameter = m_ruleToAccount.SelectedValue as string;
                if (rule.ToMatchParameter == null || rule.ToMatchParameter == PLEASE_CHOOSE_OPTION)
                {
                    return "A SIP account must be selected for the ToSIPAccount matching choice.";
                }
            }
            else if (rule.SimpleWizardToMatchType == SimpleWizardToMatchTypes.ToSIPProvider)
            {
                rule.ToMatchParameter = m_ruleToProvider.SelectedValue as string;
                if (rule.ToMatchParameter == null || rule.ToMatchParameter == PLEASE_CHOOSE_OPTION)
                {
                    return "A provider must be selected for the ToSIPProvider matching choice.";
                }
            }
            else if (rule.SimpleWizardToMatchType == SimpleWizardToMatchTypes.Regex)
            {
                rule.ToMatchParameter = m_ruleToRegexText.Text;
                if (rule.ToMatchParameter.IsNullOrBlank())
                {
                    return "A regular expression must be entered for the Regex matching choice.";
                }
            }
            else if (rule.SimpleWizardToMatchType == SimpleWizardToMatchTypes.Any)
            {
                rule.ToMatchParameter = null;
            }

            return null;
        }