Exemplo n.º 1
0
        protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            DatabaseResourceSet rs = null;

            if (culture == null || culture.Equals(CultureInfo.InvariantCulture))
            {
                return(null);
            }

            if (ResourceSets.Contains(culture.Name))
            {
                rs = ResourceSets[culture.Name] as DatabaseResourceSet;
            }
            else
            {
                lock (ResourceSets)
                {
                    if (ResourceSets.Contains(culture.Name))
                    {
                        rs = ResourceSets[culture.Name] as DatabaseResourceSet;
                    }
                    else
                    {
                        rs = new DatabaseResourceSet(dsn, culture, sp);
                        ResourceSets.Add(culture.Name, rs);
                    }
                }
            }

            return(rs);
        }
Exemplo n.º 2
0
        public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            DBResourceSet databaseResourceSet;

            while (true)
            {
                if (ResourceSets.Contains(culture.Name) && (DBResourceSet)ResourceSets[culture.Name] != null)
                {
                    databaseResourceSet = (DBResourceSet)ResourceSets[culture.Name];
                }
                else
                {
                    databaseResourceSet = new DBResourceSet(_fileName, culture);
                    ResourceSets.Add(culture.Name, databaseResourceSet);
                }

                if (databaseResourceSet.TableCount != 0 || culture.Equals(CultureInfo.InvariantCulture))
                {
                    break;
                }

                culture = culture.Parent;
            }

            if (DateTime.UtcNow > _updateDate.AddSeconds(2))
            {
                GetResource.UpdateDBRS(databaseResourceSet, _fileName, culture.Name, _updateDate);
                _updateDate = DateTime.UtcNow;
            }

            return(databaseResourceSet);
        }
Exemplo n.º 3
0
        protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            var lang = LanguageManager.GetLanguages(Sitecore.Context.Database)
                       .FirstOrDefault(x => x.CultureInfo.Equals(culture)) ?? LanguageManager.DefaultLanguage;

            var db   = Sitecore.Context.Database;
            var item = db.GetItem(_path, lang);

            ResourceSet rs = null;

            if (ResourceSets.Contains(culture.Name))
            {
                rs = ResourceSets[culture.Name] as ResourceSet;
            }
            else if (_dictionary)
            {
                rs = new DictionaryResourceSet(item);
                ResourceSets.Add(culture.Name, rs);
            }
            else
            {
                rs = new ItemResourceSet(item);
            }

            return(rs);
        }
        protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            DatabaseResourceSet rs = null;

            if (ResourceSets.Contains(culture.Name))
            {
                rs = ResourceSets[culture.Name] as DatabaseResourceSet;
            }
            else
            {
                lock (ResourceSets)
                {
                    // Check hash table once again after lock is set
                    if (ResourceSets.Contains(culture.Name))
                    {
                        rs = ResourceSets[culture.Name] as DatabaseResourceSet;
                    }
                    else
                    {
                        rs = new DatabaseResourceSet(dsn, culture, sp);
                        ResourceSets.Add(culture.Name, rs);
                    }
                }
            }

            return(rs);
        }
Exemplo n.º 5
0
        private bool TryFetchResourceSet(Hashtable localResourceSets, CultureInfo culture, out System.Resources.ResourceSet set)
        {
            lock (localResourceSets)
            {
                if (ResourceSets.Contains(culture))
                {
                    set = (System.Resources.ResourceSet)ResourceSets[culture];
                    return(true);
                }

                set = null;
                return(false);
            }
        }
Exemplo n.º 6
0
        protected override ResourceSet InternalGetResourceSet(
            CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            DatabaseResourceSet rs = null;

            if (ResourceSets.Contains(culture.Name))
            {
                Trace.WriteLine(String.Format("DatabaseResourceManager, resource set {0} already exists", culture.Name));
                rs = ResourceSets[culture.Name] as DatabaseResourceSet;
            }
            else
            {
                Trace.WriteLine(String.Format("DatabaseResourceManager, resource set {0} created", culture.Name));
                rs = new DatabaseResourceSet(dsn, culture);
                ResourceSets.Add(culture.Name, rs);
            }
            return(rs);
        }