示例#1
0
            private void Load()
            {
                // RAS Modified: Read the full page path ie. /internationalization/test.aspx
                string ResourceSet = GetFullPagePath();

                // Load IDictionary data using the DataManager (same code as provider)
                DbResourceDataManager Manager = new DbResourceDataManager();

                this._reader = Manager.GetResourceSet("", ResourceSet);
            }
示例#2
0
        public ContentResult ResourceSummary(string view)
        {
            var cc = new CultureInfo(CurrentCulture);
            var cp = new CultureInfo(CurrentCulture).Parent;
            var ci = CultureInfo.InvariantCulture;
            var resourceCulture   = DbResourceDataManager.GetResourceSet(cc, view);
            var resourceNeutral   = DbResourceDataManager.GetResourceSet(cp, view);
            var resourceInvariant = DbResourceDataManager.GetResourceSet(ci, view);

            return(Content(String.Format(@"<ul><li>{3} = {0}</li><li>{4} = {1}</li><li>{5} = {2}</li>",
                                         resourceCulture.Count,
                                         resourceNeutral.Count,
                                         resourceInvariant.Count,
                                         cc.TwoLetterISOLanguageName,
                                         cp.TwoLetterISOLanguageName,
                                         "INV")));
        }
示例#3
0
        /// <summary>
        /// Manages caching of the Resource Sets. Once loaded the values are loaded from the
        /// cache only.
        /// </summary>
        /// <param name="cultureName"></param>
        /// <returns></returns>
        private IDictionary GetResourceCache(string cultureName)
        {
            if (cultureName == null)
            {
                cultureName = "";
            }

            if (_resourceCache == null)
            {
                _resourceCache = new ListDictionary();
            }

            IDictionary Resources = _resourceCache[cultureName] as IDictionary;

            if (Resources == null)
            {
                // DEPENDENCY HERE (#1): Using DbResourceDataManager to retrieve resources

                // Use datamanager to retrieve the resource keys from the database
                DbResourceDataManager Data = new DbResourceDataManager();

                lock (_SyncLock)
                {
                    if (Resources == null)
                    {
                        if (_resourceCache.Contains(cultureName))
                        {
                            Resources = _resourceCache[cultureName] as IDictionary;
                        }
                        else
                        {
                            Resources = Data.GetResourceSet(cultureName as string, _ResourceSetName);
                        }

                        _resourceCache[cultureName] = Resources;
                    }
                }
            }

            return(Resources);
        }
        /// <summary>
        /// This is the worker method responsible for actually retrieving resources from the resource
        /// store. This method goes out queries the database by asking for a specific ResourceSet and
        /// Culture and it returns a Hashtable (as IEnumerable) to use as a ResourceSet.
        ///
        /// The ResourceSet manages access to resources via IEnumerable access which is ultimately used
        /// to return resources to the front end.
        ///
        /// Resources are read once and cached into an internal Items field. A ResourceReader instance
        /// is specific to a ResourceSet and Culture combination so there should never be a need to
        /// reload this data, except when explicitly clearing the reader/resourceset (in which case
        /// Items can be set to null via ClearResources()).
        /// </summary>
        /// <returns>An IDictionaryEnumerator of the resources for this reader</returns>
        public IDictionaryEnumerator GetEnumerator()
        {
            if (Items != null)
            {
                return(Items.GetEnumerator());
            }

            lock (_SyncLock)
            {
                // Check again to ensure we still don't have items
                if (Items != null)
                {
                    return(Items.GetEnumerator());
                }

                // PLACEHOLDER:   DEPENDENCY HERE
                // Here's the only place we really access the database and return
                // a specific ResourceSet for a given ResourceSet Id and Culture
                DbResourceDataManager manager = DbResourceDataManager.CreateDbResourceDataManager(configuration: Configuration);
                Items = manager.GetResourceSet(cultureInfo.Name, resourceSetName);
                return(Items.GetEnumerator());
            }
        }
示例#5
0
        /// <summary>
        /// This is the worker method responsible for actually retrieving resources from the resource
        /// store. This method goes out queries the database by asking for a specific ResourceSet and
        /// Culture and it returns a Hashtable (as IEnumerable) to use as a ResourceSet.
        ///
        /// The ResourceSet manages access to resources via IEnumerable access which is ultimately used
        /// to return resources to the front end.
        ///
        /// Resources are read once and cached into an internal Items field. A ResourceReader instance
        /// is specific to a ResourceSet and Culture combination so there should never be a need to
        /// reload this data, except when explicitly clearing the reader/resourceset (in which case
        /// Items can be set to null via ClearResources()).
        /// </summary>
        /// <returns>An IDictionaryEnumerator of the resources for this reader</returns>
        public IDictionaryEnumerator GetEnumerator()
        {
            if (Items != null)
            {
                return(Items.GetEnumerator());
            }

            lock (_SyncLock)
            {
                // Check again to ensure we still don't have items
                if (Items != null)
                {
                    return(Items.GetEnumerator());
                }

                // DEPENDENCY HERE
                // Here's the only place we really access the database and return
                // a specific ResourceSet for a given ResourceSet Id and Culture
                DbResourceDataManager Manager = new DbResourceDataManager();
                Items = Manager.GetResourceSet(cultureInfo.Name, baseNameField);
                return(Items.GetEnumerator());
            }
        }