locked
Custom ResourceProviderFactory + Release (not debug) causing Issues RRS feed

  • Question

  • User-695594971 posted

    Hi all,

    I have a Custom ResourceProviderFactory that pulls from our SQL server database. It works great in Casini in development mode, however when I publish the site and have the web.config's debug=false all of a sudden none of the text is localized anymore and the defaults in the page's code is used.

        [DesignTimeResourceProviderFactoryAttribute(typeof(EvolutionDesignTimeResourceProvider))]
        public class EvolutionResourceProviderFactory : ResourceProviderFactory  {
    
            public override IResourceProvider CreateGlobalResourceProvider(string classKey) {
                return new EvolutionResourceProvider(classKey);
            }
    
            public override IResourceProvider CreateLocalResourceProvider(string virtualPath) {
                return new EvolutionResourceProvider(virtualPath);
            }
        }
    
    public class EvolutionResourceProvider : IResourceProvider {      
            private string _virtualPath;       
    
            public EvolutionResourceProvider(string virtualPath) {           
                _virtualPath = virtualPath;
            }
    
            private IDictionary GetResourceCache(Guid DivisionID, int RegionID) {               
                IDictionary _resourceCache;
                if (HttpContext.Current != null && HttpContext.Current.Cache["ResourceCache" + _virtualPath + DivisionID.ToString() + RegionID.ToString()] != null) {
                    _resourceCache = (ListDictionary)HttpContext.Current.Cache["ResourceCache" + _virtualPath + DivisionID.ToString() + RegionID.ToString()];
                } else {
                    _resourceCache = new ListDictionary();
                }
    
                IDictionary resourceDict;
                if (!_resourceCache.Contains(_virtualPath + DivisionID.ToString() + RegionID.ToString())) {
                    resourceDict = EvolutionResourceHelper.GetResources(_virtualPath, DivisionID, RegionID, null);
                    _resourceCache.Add(_virtualPath + DivisionID.ToString() + RegionID.ToString(), resourceDict);
                    if (HttpContext.Current != null)
                        HttpContext.Current.Cache.Insert("ResourceCache" + _virtualPath + DivisionID.ToString() + RegionID.ToString(), _resourceCache);
                } else {
                    resourceDict = _resourceCache[_virtualPath + DivisionID.ToString() + RegionID.ToString()] as IDictionary;
                }
    
                return resourceDict;
            }
            
            #region IResourceProvider Members
    
            public object GetObject(string resourceKey, System.Globalization.CultureInfo culture) {
                int RegionID = 0;
                if (culture != null) {
                    RegionID = culture.LCID;
                } else {
                    RegionID = CultureInfo.CurrentUICulture.LCID;
                }
    
                Guid DivisionID = Guid.Empty;
                if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session["DivisionID"] != null) {
                    DivisionID = (Guid)HttpContext.Current.Session["DivisionID"];
                } else if (Evolution.API.ApplicationSettings.WebSiteDefaultDivision != null) {
                    DivisionID = Evolution.API.ApplicationSettings.WebSiteDefaultDivision.ID;
                }
    
                return GetResourceCache(DivisionID, RegionID)[resourceKey];
            }
    
            public System.Resources.IResourceReader ResourceReader {
                get {
                    Guid DivisionID = Guid.Empty;
                    if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session["DivisionID"] != null) {
                        DivisionID = (Guid)HttpContext.Current.Session["DivisionID"];
                    } else if (Evolution.API.ApplicationSettings.WebSiteDefaultDivision != null) {
                        DivisionID = Evolution.API.ApplicationSettings.WebSiteDefaultDivision.ID;
                    }
    
                    return new EvolutionResourceReader(GetResourceCache(DivisionID, CultureInfo.CurrentUICulture.LCID));
                }
            }
            #endregion
        }
    
        public class EvolutionResourceReader : IResourceReader {
            private IDictionary _resources;
    
            public EvolutionResourceReader(IDictionary resources) {
                _resources = resources;
            }
            
            #region IResourceReader Members
    
            public void Close() {
                
            }
    
            public System.Collections.IDictionaryEnumerator GetEnumerator() {
                return _resources.GetEnumerator();
            }
    
            #endregion
    
            #region IEnumerable Members
    
            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
                return _resources.GetEnumerator();
            }
    
            #endregion
    
            #region IDisposable Members
    
            public void Dispose() {
                
            }
    
            #endregion
        }

      

    Of course at runtime with no debug on I can't step through the code to tell me what's going on, so I'm at a loss.

    Anyone have any ideas as to what I'm doing wrong?

     Thanks!

    Wednesday, February 7, 2007 9:23 AM

All replies

  • User391935617 posted

    Hi,

    I am working with Internationalization/Multilingual.I have a question for you.

    Can you please suggest if your code will populate the data from sql server based on the locale and culture info and display the data in the specific culture?

    If yes can you please send me your code sample so i can use it as reference?

     Thanks,

    Sreeram
     

    Wednesday, October 24, 2007 4:44 PM