コード例 #1
0
        /// <summary>
        /// Answers the named resource from this ResourceBundle.
        /// </summary>
        ///
        /// <param name="key">the name of the resource</param>
        /// <returns>the resource object</returns>
        /// <exception cref="MissingResourceException">when the resource is not found</exception>
        public virtual Object GetObject(String key)
        {
            ResourceBundle last, theParent = this;

            do
            {
                Object result = theParent.HandleGetObject(key);
                if (result != null)
                {
                    return(result);
                }
                last      = theParent;
                theParent = theParent.parent;
            } while (theParent != null);
            throw new MissingManifestResourceException("KA029"); //$NON-NLS-1$
        }
コード例 #2
0
 /// <summary>
 /// Sets the parent resource bundle of this ResourceBundle. The parent is
 /// searched for resources which are not found in this resource bundle.
 /// </summary>
 ///
 /// <param name="bundle">the parent resource bundle</param>
 protected internal void SetParent(ResourceBundle bundle)
 {
     parent = bundle;
 }
コード例 #3
0
        private static ResourceBundle HandleGetBundle(String bs, String locale_0,
                                                      bool loadBase, Assembly loader_1)
        {
            ResourceBundle bundle     = null;
            String         bundleName = bs + locale_0;
            Object         cacheKey   = (loader_1 != null) ? (Object)loader_1 : (Object)"null"; //$NON-NLS-1$
            Dictionary <String, ResourceBundle> loaderCache;

            lock (cache)
            {
                loaderCache = ((System.Collections.Generic.Dictionary <System.String, ResourceBundle>)ILOG.J2CsMapping.Collections.Generics.Collections.Get(cache, cacheKey));
                if (loaderCache == null)
                {
                    loaderCache     = new Dictionary <String, ResourceBundle>();
                    cache[cacheKey] = loaderCache;
                    //ILOG.J2CsMapping.Collections.Generics.Collections.Put(cache, (System.Object)(cacheKey), (System.Collections.Generic.Dictionary<System.String, ResourceBundle>)(loaderCache));
                }
            }
            ResourceBundle result = (ResourceBundle)ILOG.J2CsMapping.Collections.Generics.Collections.Get(loaderCache, bundleName);

            if (result != null)
            {
                if (result == MISSINGBASE)
                {
                    return(null);
                }
                if (result == MISSING)
                {
                    if (!loadBase)
                    {
                        return(null);
                    }
                    String extension = Strip(locale_0);
                    if (extension == null)
                    {
                        return(null);
                    }
                    return(HandleGetBundle(bs, extension, loadBase, loader_1));
                }
                return(result);
            }

            try
            {
                Type bundleClass = ILOG.J2CsMapping.Reflect.Helper.GetNativeType(bundleName);

                if (typeof(ResourceBundle).IsAssignableFrom(bundleClass))
                {
                    bundle = (ResourceBundle)Activator.CreateInstance(bundleClass);
                }
            }
            catch (Exception e)
            {
            }

            if (bundle != null)
            {
                //bundle.SetLocale(locale_0);
            }
            else
            {
                String fileName_3 = bundleName.Replace('.', '/');
                Stream stream     = new Anonymous_C0(loader_1, fileName_3).Run();
                if (stream != null)
                {
                    try
                    {
                        try
                        {
                            //bundle = new PropertyResourceBundle(stream);
                        }
                        finally
                        {
                            stream.Close();
                        }
                        //bundle.SetLocale(locale_0);
                    }
                    catch (IOException e_4)
                    {
                    }
                }
            }

            String extension_5 = Strip(locale_0);

            if (bundle != null)
            {
                if (extension_5 != null)
                {
                    ResourceBundle parent_6 = HandleGetBundle(bs, extension_5, true,
                                                              loader_1);
                    if (parent_6 != null)
                    {
                        // bundle.SetParent(parent_6);
                    }
                }
                ILOG.J2CsMapping.Collections.Generics.Collections.Put(loaderCache, (System.String)(bundleName), (ResourceBundle)(bundle));
                return(bundle);
            }

            if (extension_5 != null && (loadBase || extension_5.Length > 0))
            {
                bundle = HandleGetBundle(bs, extension_5, loadBase, loader_1);
                if (bundle != null)
                {
                    ILOG.J2CsMapping.Collections.Generics.Collections.Put(loaderCache, (System.String)(bundleName), (ResourceBundle)(bundle));
                    return(bundle);
                }
            }
            ILOG.J2CsMapping.Collections.Generics.Collections.Put(loaderCache, (System.String)(bundleName), (ResourceBundle)((loadBase) ? MISSINGBASE : MISSING));
            return(null);
        }