SIPSorcery.AppServer.DialPlan.DialPlanSettings.GetExcludedPrefixes C# (CSharp) Method

GetExcludedPrefixes() public method

Gets a list of any excluded prefixes the user has specified in their dialplan options. The excluded prefix strings will be stored in the database as a CRLF separated list of strings. Spaces are used in excluded prefixes so they should not be trimmed.
public GetExcludedPrefixes ( ) : List
return List
        public List<string> GetExcludedPrefixes()
        {
            if (Options != null && !Options.ExcludedPrefixes.IsNullOrBlank())
            {
                string[] excludedPrefixes = Regex.Split(Options.ExcludedPrefixes, @"\r\n", RegexOptions.Multiline);
                return excludedPrefixes.Where(x => !x.Trim().IsNullOrBlank()).ToList();
            }

            return null;
        }

Usage Example

        public void ExtractExcludedPrefixesTest()
        {
            SIPDialplanOption options = new SIPDialplanOption()
            {
                excludedprefixes = " 1 (900 | 809)\r\n\r\n 1 \\d\\d\\d 555 1212\r\n\r\n44 (9 | 55 | 70 | 84 | 87)"
            };

            DialPlanSettings settings = new DialPlanSettings(null, null, null, options);

            List<string> excludedPrefixesList = settings.GetExcludedPrefixes();

            Assert.AreEqual(3, excludedPrefixesList.Count, "The number of excluded prefixes extracted from the list was incorrect.");
            Assert.AreEqual(" 1 (900 | 809)", excludedPrefixesList[0], "The excluded prefixes at index 0 was not extracted correctly.");
            Assert.AreEqual(" 1 \\d\\d\\d 555 1212", excludedPrefixesList[1], "The excluded prefixes at index 1 was not extracted correctly.");
            Assert.AreEqual("44 (9 | 55 | 70 | 84 | 87)", excludedPrefixesList[2], "The excluded prefixes at index 2 was not extracted correctly.");
        }