Beispiel #1
0
        internal bool LoadDataOnWorkerThread()
        {
            bool flag = true;

            if (this._countries == null)
            {
                CountryBaseDetails[] countryDetails = Service.Instance.GetCountryDetails();
                SortedDictionary <string, AccountCountry> sortedDictionary = null;
                if (countryDetails != null && countryDetails.Length > 0)
                {
                    sortedDictionary = new SortedDictionary <string, AccountCountry>(CountryNameComparer.Instance);
                    foreach (CountryBaseDetails details in countryDetails)
                    {
                        sortedDictionary[details.Abbreviation] = AccountCountry.Create(details);
                    }
                }
                if (sortedDictionary == null || sortedDictionary.Count == 0)
                {
                    flag = false;
                }
                else
                {
                    this._countries = sortedDictionary;
                }
            }
            if (flag)
            {
                Application.DeferredInvoke(new DeferredInvokeHandler(this.NotifyLoaded), null);
            }
            return(flag);
        }
        private AccountCountry GetAccountCountry(object state)
        {
            AccountCountry accountCountry = null;

            if (state != null)
            {
                accountCountry = AccountCountryList.Instance.GetCountry(state as string);
            }
            return(accountCountry);
        }
Beispiel #3
0
        public AccountCountry GetCountry(string abbreviation)
        {
            AccountCountry accountCountry = null;

            if (this._countries != null && abbreviation != null && this._countries.ContainsKey(abbreviation))
            {
                accountCountry = this._countries[abbreviation];
            }
            return(accountCountry);
        }
        public override string ConvertToString(object value, object country)
        {
            string         str      = null;
            AccountCountry country1 = AccountCountryList.Instance.GetCountry(country as string);

            if (country1 != null)
            {
                str = country1.GetState(value as string);
            }
            return(str ?? value as string);
        }
        public override object ConvertFromString(string value, object country)
        {
            string         str      = null;
            AccountCountry country1 = AccountCountryList.Instance.GetCountry(country as string);

            if (country1 != null)
            {
                str = country1.GetStateAbbreviation(value);
            }
            return(str ?? (object)value);
        }
        public override bool IsRequiredInternal(object state)
        {
            AccountCountry accountCountry = this.GetAccountCountry(state);

            if (accountCountry != null)
            {
                CountryFieldValidator validator = accountCountry.GetValidator(this._fieldValidatorType);
                if (validator != null && !string.IsNullOrEmpty(validator.Regex))
                {
                    return(true);
                }
            }
            return(false);
        }
        internal override string GetLabelString(object state)
        {
            string         str            = string.Empty;
            AccountCountry accountCountry = this.GetAccountCountry(state);

            if (accountCountry != null)
            {
                CountryFieldValidator validator = accountCountry.GetValidator(this._fieldValidatorType);
                if (validator != null)
                {
                    str = Shell.LoadString(validator.NameStringId);
                }
            }
            return(str);
        }
        internal override string GetOverlayString(object state)
        {
            string         str            = string.Empty;
            AccountCountry accountCountry = this.GetAccountCountry(state);

            if (accountCountry != null)
            {
                CountryFieldValidator validator = accountCountry.GetValidator(this._fieldValidatorType);
                if (validator != null)
                {
                    str = validator.FriendlyFormat;
                }
            }
            return(str);
        }
        public override bool IsValidInternal(string value, object state)
        {
            string         pattern        = null;
            AccountCountry accountCountry = this.GetAccountCountry(state);

            if (accountCountry == null)
            {
                return(true);
            }
            if (accountCountry != null)
            {
                CountryFieldValidator validator = accountCountry.GetValidator(this._fieldValidatorType);
                if (validator != null && !string.IsNullOrEmpty(validator.Regex))
                {
                    pattern = validator.Regex;
                }
            }
            return(string.IsNullOrEmpty(pattern) || value != null && Regex.IsMatch(value, pattern));
        }
        public static AccountCountry Create(CountryBaseDetails details)
        {
            AccountCountry accountCountry = null;

            if (details != null)
            {
                string[] languageAbbreviations = details.LanguageAbbreviations;
                if (languageAbbreviations != null)
                {
                    Array.Sort(languageAbbreviations, LanguageNameComparer.Instance);
                }
                string localizedStates = null;
                if (details.Abbreviation.Equals("US", StringComparison.InvariantCultureIgnoreCase))
                {
                    localizedStates = Shell.LoadString(StringId.IDS_BILLING_USA_STATES);
                }
                else if (details.Abbreviation.Equals("CA", StringComparison.InvariantCultureIgnoreCase))
                {
                    localizedStates = Shell.LoadString(StringId.IDS_BILLING_CA_PROVINCES);
                }
                accountCountry = new AccountCountry(details.Abbreviation, details.LanguageAbbreviations, details.TeenagerAge, details.AdultAge, details.ShowNewsletterOptions, details.UsageCollection, details.Validators, localizedStates);
            }
            return(accountCountry);
        }