SIPSorcery.AppServer.DialPlan.DialPlanSettings.GetAllowedCountries C# (CSharp) 메소드

GetAllowedCountries() 공개 메소드

Gets a list of allowed country codes that the user has specified in their dialplan options.
public GetAllowedCountries ( ) : List
리턴 List
        public List<string> GetAllowedCountries()
        {
            if (Options != null && !Options.AllowedCountryCodes.IsNullOrBlank())
            {
                string[] allowedCodes = Regex.Split(Options.AllowedCountryCodes, @"\s+", RegexOptions.Multiline);
                return allowedCodes.Where(x => !x.Trim().IsNullOrBlank()).Select(x => x.Trim()).ToList();
            }

            return null;
        }

Usage Example

        public void ExtractAllowedCountriesTest()
        {
            SIPDialplanOption options = new SIPDialplanOption()
            {
                AllowedCountryCodes = "1 33 36 37[0-2] 380 39 41 420 44 49 61 7 86 883 886 90 972 998"
            };

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

            List<string> allowedCountriesList = settings.GetAllowedCountries();

            Assert.AreEqual(18, allowedCountriesList.Count, "The number of allowed countries extracted from the list was incorrect.");
            Assert.AreEqual("1", allowedCountriesList[0], "The allowed countries at index 0 was not extracted correctly.");
            Assert.AreEqual("37[0-2]", allowedCountriesList[3], "The allowed countries at index 3 was not extracted correctly.");
            Assert.AreEqual("998", allowedCountriesList[17], "The allowed countries at index 7 was not extracted correctly.");
        }