示例#1
0
        private static string GetLocaleIDFromResourceName(string resourceName)
        {
            if (InvariantResourceFileNames.Contains(ResourceUtil.ConvertResourceName(resourceName)))
            {
                return("root");
            }

            return(Path.GetFileNameWithoutExtension(resourceName));
        }
示例#2
0
        /// <summary>
        /// Should be called only from <see cref="ICUBinary.GetData(Assembly, string, string, bool)"/> or from convenience overloads here.
        /// </summary>
        internal static Stream GetStream(Assembly loader, string resourceName, bool required)
        {
            Stream i = null;

            i = loader.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));
            if (i == null && required)
            {
                throw new MissingManifestResourceException("could not locate data " + loader.ToString() + " Resource: " + resourceName);
            }
            CheckStreamForBinaryData(i, resourceName);
            return(i);
        }
示例#3
0
        private static Stream GetStream(Type root, string resourceName, bool required)
        {
            Stream i;

            i = root.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));
            if (i == null && required)
            {
#if FEATURE_TYPEEXTENSIONS_GETTYPEINFO
                Assembly assembly = root.GetTypeInfo().Assembly;
#else
                Assembly assembly = root.Assembly;
#endif
                throw new MissingManifestResourceException("could not locate data " + resourceName +
                                                           " Assembly: " + assembly.FullName + " Resource: " + resourceName);
            }
            CheckStreamForBinaryData(i, resourceName);
            return(i);
        }
示例#4
0
        /// <summary>
        /// Should be called only from <see cref="ICUBinary.GetData(Assembly, string, string, bool)"/> or from convenience overloads here.
        /// </summary>
        internal static Stream GetStream(Assembly loader, string resourceName, bool required)
        {
            var resourceLocationAttribute = loader.GetCustomAttribute <ResourceLocationAttribute>();

            if (resourceLocationAttribute != null && resourceLocationAttribute.Location == Resources.ResourceLocation.Satellite)
            {
                return(GetStream(loader, GetLocaleIDFromResourceName(resourceName), resourceName, required));
            }

            Stream i = loader.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));

            if (i == null && required)
            {
                throw new MissingManifestResourceException("could not locate data " + loader.ToString() + " Resource: " + resourceName);
            }
            CheckStreamForBinaryData(i, resourceName);
            return(i);
        }
示例#5
0
        /// <summary>
        /// Should be called only from <see cref="ICUBinary.GetData(Assembly, string, string, bool)"/> or from convenience overloads here.
        /// </summary>
        internal static Stream GetStream(Assembly loader, string localeID, string resourceName, bool required)
        {
            string cultureName = localeID == "root" || localeID == "any" ? string.Empty : localeID.Replace('_', '-');
            //var culture = string.IsNullOrWhiteSpace(cultureName) ? CultureInfo.InvariantCulture : new ResourceCultureInfo(cultureName);

            Stream   i = null;
            Assembly satelliteAssembly;

            // Skip the lookup if the wrong satellite assembly was loaded. In most cases, if the resource assembly doesn't exist,
            // we will have the neutral resource (invariant) assembly. So, we do a check to make sure we have the right one,
            // and fallback if we do not.
            if ((satelliteAssembly = GetSatelliteAssemblyOrDefault(loader, cultureName)) != null)
            {
                i = satelliteAssembly.GetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));
            }

            if (i == null && required)
            {
                throw new MissingManifestResourceException("could not locate data " + loader.ToString() + " Resource: " + resourceName);
            }
            CheckStreamForBinaryData(i, resourceName);
            return(i);
        }
示例#6
0
 public static bool Exists(string resourceName)
 {
     return(typeof(ICUData).FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName)) != null);
 }