Exemplo n.º 1
0
        public LocalizationService(string resourceName, CultureInfo culture)
        {
            Guard.IsNotNullOrEmpty(resourceName, "resourceName");
            Guard.IsNotNull(culture, "culture");

            resource = DetectResource("~/App_GlobalResources", resourceName, culture);
        }
Exemplo n.º 2
0
        private static ResourceBase DetectResource(string resourceLocation, string resourceName, CultureInfo culture)
        {
            string cacheKey = resourceName + ":" + culture;

            ResourceBase resource;

            using (syncLock.ReadAndWrite())
            {
                if (!cache.TryGetValue(cacheKey, out resource))
                {
                    using (syncLock.Write())
                    {
                        if (!cache.TryGetValue(cacheKey, out resource))
                        {
                            resource = CreateResource(resourceName, culture, resourceLocation);

                            cache.Add(cacheKey, resource);
                        }
                    }
                }
            }

            return resource;
        }