Inheritance: IStringLocalizer
Exemple #1
0
        public IStringLocalizer Create(Type resourceSource)
        {
            var returnOnlyKeyIfNotFound = _options.Value.ReturnOnlyKeyIfNotFound;
            var createNewRecordWhenLocalisedStringDoesNotExist = _options.Value.CreateNewRecordWhenLocalisedStringDoesNotExist;
            SqlStringLocalizer sqlStringLocalizer;

            if (_options.Value.UseOnlyPropertyNames)
            {
                if (_resourceLocalizations.Keys.Contains(Global))
                {
                    return(_resourceLocalizations[Global]);
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(Global), _developmentSetup, Global, returnOnlyKeyIfNotFound, createNewRecordWhenLocalisedStringDoesNotExist);
                return(_resourceLocalizations.GetOrAdd(Global, sqlStringLocalizer));
            }
            else if (_options.Value.UseTypeFullNames)
            {
                if (_resourceLocalizations.Keys.Contains(resourceSource.FullName))
                {
                    return(_resourceLocalizations[resourceSource.FullName]);
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.FullName), _developmentSetup, resourceSource.FullName, returnOnlyKeyIfNotFound, createNewRecordWhenLocalisedStringDoesNotExist);
                return(_resourceLocalizations.GetOrAdd(resourceSource.FullName, sqlStringLocalizer));
            }

            if (_resourceLocalizations.Keys.Contains(resourceSource.Name))
            {
                return(_resourceLocalizations[resourceSource.Name]);
            }

            sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.Name), _developmentSetup, resourceSource.Name, returnOnlyKeyIfNotFound, createNewRecordWhenLocalisedStringDoesNotExist);
            return(_resourceLocalizations.GetOrAdd(resourceSource.Name, sqlStringLocalizer));
        }
        public IStringLocalizer Create(Type resourceSource)
        {
            var returnOnlyKeyIfNotFound = _options.Value.ReturnOnlyKeyIfNotFound;

            SqlStringLocalizer sqlStringLocalizer;

            if (_options.Value.UseOnlyPropertyNames)
            {
                if (_resourceLocalizations.Keys.Contains(Global))
                {
                    return(_resourceLocalizations[Global]);
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(Global), Global, returnOnlyKeyIfNotFound);
                return(_resourceLocalizations.GetOrAdd(Global, sqlStringLocalizer));
            }
            else if (_options.Value.UseTypeFullNames)
            {
                if (_resourceLocalizations.Keys.Contains(resourceSource.FullName))
                {
                    return(_resourceLocalizations[resourceSource.FullName]);
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.FullName), resourceSource.FullName, returnOnlyKeyIfNotFound);
                return(_resourceLocalizations.GetOrAdd(resourceSource.FullName, sqlStringLocalizer));
            }

            if (_resourceLocalizations.Keys.Contains(resourceSource.Name))
            {
                return(_resourceLocalizations[resourceSource.Name]);
            }

            sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.Name), resourceSource.Name, returnOnlyKeyIfNotFound);
            return(_resourceLocalizations.GetOrAdd(resourceSource.Name, sqlStringLocalizer));
        }
Exemple #3
0
        public IStringLocalizer Create(string baseName, string location)
        {
            if (_resourceLocalizations.Keys.Contains(baseName + location))
            {
                return(_resourceLocalizations[baseName + location]);
            }

            var sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(baseName + location), _developmentSetup, baseName + location, false, false);

            return(_resourceLocalizations.GetOrAdd(baseName + location, sqlStringLocalizer));
        }
        public IStringLocalizer Create(string baseName, string location)
        {
            var returnOnlyKeyIfNotFound = _options.Value.ReturnOnlyKeyIfNotFound;
            var createNewRecordWhenLocalisedStringDoesNotExist = _options.Value.CreateNewRecordWhenLocalisedStringDoesNotExist;

            if (_resourceLocalizations.Keys.Contains(baseName + location))
            {
                return(_resourceLocalizations[baseName + location]);
            }

            var sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(baseName + location), _developmentSetup, baseName + location, returnOnlyKeyIfNotFound, createNewRecordWhenLocalisedStringDoesNotExist);

            return(_resourceLocalizations.GetOrAdd(baseName + location, sqlStringLocalizer));
        }
Exemple #5
0
        public IStringLocalizer Create(string baseName, string location)
        {
            var returnOnlyKeyIfNotFound = _options.Value.ReturnOnlyKeyIfNotFound;
            var createNewRecordWhenLocalisedStringDoesNotExist = _options.Value.CreateNewRecordWhenLocalisedStringDoesNotExist;

            var resourceKey = baseName + location;

            if (_options.Value.UseOnlyPropertyNames)
            {
                resourceKey = Global;
            }

            if (_resourceLocalizations.Keys.Contains(resourceKey))
            {
                return(_resourceLocalizations[resourceKey]);
            }

            var sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceKey), _developmentSetup, resourceKey, returnOnlyKeyIfNotFound, createNewRecordWhenLocalisedStringDoesNotExist);

            return(_resourceLocalizations.GetOrAdd(resourceKey, sqlStringLocalizer));
        }
        public IStringLocalizer Create(Type resourceSource)
        {
            var returnOnlyKeyIfNotFound = _options.Value.ReturnOnlyKeyIfNotFound;

            SqlStringLocalizer sqlStringLocalizer;

            if (_options.Value.UseOnlyPropertyNames)
            {
                if (_resourceLocalizations.Keys.Contains(Global))
                {
                    return _resourceLocalizations[Global];
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(Global), Global, returnOnlyKeyIfNotFound);
                return _resourceLocalizations.GetOrAdd(Global, sqlStringLocalizer);

            }
            else if (_options.Value.UseTypeFullNames)
            {
                if (_resourceLocalizations.Keys.Contains(resourceSource.FullName))
                {
                    return _resourceLocalizations[resourceSource.FullName];
                }

                sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.FullName), resourceSource.FullName, returnOnlyKeyIfNotFound);
                return _resourceLocalizations.GetOrAdd(resourceSource.FullName, sqlStringLocalizer);
            }

            if (_resourceLocalizations.Keys.Contains(resourceSource.Name))
            {
                return _resourceLocalizations[resourceSource.Name];
            }

            sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(resourceSource.Name), resourceSource.Name, returnOnlyKeyIfNotFound);
            return _resourceLocalizations.GetOrAdd(resourceSource.Name, sqlStringLocalizer);
        }
        public IStringLocalizer Create(string baseName, string location)
        {
            if (_resourceLocalizations.Keys.Contains(baseName + location))
            {
                return _resourceLocalizations[baseName + location];
            }

            var sqlStringLocalizer = new SqlStringLocalizer(GetAllFromDatabaseForResource(baseName + location), baseName + location, false);
            return _resourceLocalizations.GetOrAdd(baseName + location, sqlStringLocalizer);
        }