예제 #1
0
        public LanguageSettings(string cultureName, string uiCultureName, bool addPunctuators = false)
        {
            Contracts.AssertNonEmpty(cultureName);

            _cultureName   = cultureName;
            _uiCultureName = uiCultureName;

            _locToInvariantFunctionMap   = new Dictionary <string, string>();
            _locToInvariantPunctuatorMap = new Dictionary <string, string>();
            _invariantToLocFunctionMap   = new Dictionary <string, string>();
            _invariantToLocPunctuatorMap = new Dictionary <string, string>();

            _cacheStamp = 0;
            _cachedInvariantSettings = null;

            if (addPunctuators)
            {
                string dec;
                string comma;
                string list;
                TexlLexer.ChoosePunctuators(this, out dec, out comma, out list);
                AddPunctuator(dec, TexlLexer.PunctuatorDecimalSeparatorInvariant);
                AddPunctuator(comma, TexlLexer.PunctuatorCommaInvariant);
                AddPunctuator(list, TexlLexer.PunctuatorSemicolonInvariant);
            }
        }
예제 #2
0
        public ILanguageSettings GetIdentitySettingsForInvariantLanguage()
        {
            if (_cachedInvariantSettings == null || NeedsRefresh(_cachedInvariantSettings))
            {
                _cachedInvariantSettings = new LanguageSettings("en-US", "en-US");

                _cachedInvariantSettings._cacheStamp = _cacheStamp;

                foreach (var kvp in _locToInvariantFunctionMap)
                {
                    _cachedInvariantSettings.AddFunction(kvp.Value, kvp.Value);
                }
                foreach (var kvp in _locToInvariantPunctuatorMap)
                {
                    _cachedInvariantSettings.AddPunctuator(kvp.Value, kvp.Value);
                }
            }

            return(_cachedInvariantSettings);
        }
예제 #3
0
        private bool NeedsRefresh(LanguageSettings cache)
        {
            Contracts.AssertValue(cache);

            return(cache._cacheStamp != _cacheStamp);
        }