예제 #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);
        }
        protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            ResourceSet rs = base.InternalGetResourceSet(culture, false, false);

            if (rs == null)
            {
                if (culture == CultureInfo.InvariantCulture)
                {
                    culture = delegateNeutralResourcesCulture(this);
                }

#pragma warning disable CS0618 // Type or member is obsolete
                rs = ResourceSets[culture.Name] as ResourceSet;
#pragma warning restore CS0618 // Type or member is obsolete

                if (rs == null && createIfNotExists)
                {
                    var provider = CreateResourceDataProvider();

                    if (provider != null)
                    {
                        rs = new ResourceProviderSet(provider, base.BaseName, culture);
#pragma warning disable CS0618 // Type or member is obsolete
                        ResourceSets.Add(culture.Name, rs);
#pragma warning restore CS0618 // Type or member is obsolete
                    }
                }
            }
            return(rs);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #6
0
        /// <summary>
        /// Release.
        /// </summary>
        public virtual void Release()
        {
            int?clientPort = ChannelUtil.GetClientPortFromChannel(Channel);

            if (clientIDHolderMap != null)
            {
                clientIDHolderMap = null;
            }

            if (ResourceSets != null)
            {
                ResourceSets.Clear();
            }
        }
예제 #7
0
        public BingResponse EnsureSuccessStatusCode()
        {
            switch (StatusCode)
            {
            case 200:
                if (ResourceSets.Any(set => set.EstimatedTotal == 0))
                {
                    throw new AddressNotFoundException(StatusDescription);
                }
                return(this);

            default: throw new ApiUnknownException(StatusDescription);
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
        }
예제 #10
0
 /// <summary>
 /// Gets a global resource for the specified resource set and key
 /// </summary>
 /// <param name="set">
 /// The resource set.
 /// </param>
 /// <param name="resourceKey">
 /// The resource key.
 /// </param>
 /// <returns>
 /// The resource string
 /// </returns>
 private static string GetGlobalResource(ResourceSets set, string resourceKey)
 {
     var resourceSetName = string.Format("WhoCanHelpMe.Web.ResourceFiles.{0}", set);
     return HttpContext.GetGlobalResourceObject(resourceSetName, resourceKey) as string;
 }
예제 #11
0
        /// <summary>
        /// Gets a global resource for the specified resource set and key
        /// </summary>
        /// <param name="set">
        /// The resource set.
        /// </param>
        /// <param name="resourceKey">
        /// The resource key.
        /// </param>
        /// <returns>
        /// The resource string
        /// </returns>
        private static string GetGlobalResource(ResourceSets set, string resourceKey)
        {
            var resourceSetName = string.Format("WhoCanHelpMe.Web.ResourceFiles.{0}", set);

            return(HttpContext.GetGlobalResourceObject(resourceSetName, resourceKey) as string);
        }
예제 #12
0
 /// <summary>
 /// Resolve resourceset by resource type
 /// </summary>
 /// <param name="resourceType">The resource type</param>
 /// <param name="method">The method</param>
 /// <returns>The resource type</returns>
 private ResourceSet ResolveResourceSet(ResourceType resourceType, MethodInfo method)
 {
     return(ResourceSets.SingleOrDefault(rs => rs.ResourceType == resourceType));
 }