/// <summary> /// Loads and returns a satellite assembly for a given culture.. /// </summary> // This is like Assembly.GetSatelliteAssembly, but uses resourceName // instead of assembly.GetName().Name, and works around a bug in // mono-0.28. private static Assembly GetSatelliteAssembly(Assembly assembly, String resourceName, CultureInfo culture, PathResolver pathResolver) { string satelliteExpectedLocation = pathResolver.Resolve(Path.GetDirectoryName(assembly.Location), resourceName, culture); if (File.Exists(satelliteExpectedLocation)) { return(Assembly.LoadFrom(satelliteExpectedLocation)); } // Try to load embedded assembly string embeddedResourceId = String.Format("{0}.{1}.{2}", assembly.GetName().Name, culture.Name, GetEmbededSatelliteAssemblyName(resourceName)); using (Stream satAssemblyStream = assembly.GetManifestResourceStream(embeddedResourceId)) { if (satAssemblyStream == null) { return(null); } Byte[] assemblyData = new Byte[satAssemblyStream.Length]; satAssemblyStream.Read(assemblyData, 0, assemblyData.Length); return(Assembly.Load(assemblyData)); } }
// ======================== Public Constructors ======================== /// <summary> /// Default constructor use assembly name + ".Messages" as base name to locate satellite assemblies. /// </summary> public GettextResourceManager(PathResolver pathResolver) : this(Assembly.GetCallingAssembly(), pathResolver) { }
/// <summary> /// Constructor. /// </summary> /// <param name="baseName">the resource name, also the assembly base /// name</param> public GettextResourceManager(String baseName, PathResolver pathResolver) : base(baseName, Assembly.GetCallingAssembly(), typeof(GettextResourceSet)) { _pathResolver = pathResolver; }
/// <summary> /// Constructor. /// </summary> /// <param name="baseName">the resource name, also the assembly base /// name</param> public GettextResourceManager(String baseName, Assembly assembly, PathResolver pathResolver) : base(baseName, assembly, typeof(GettextResourceSet)) { _pathResolver = pathResolver; }
/// <summary> /// Loads and returns a satellite assembly for a given culture.. /// </summary> // This is like Assembly.GetSatelliteAssembly, but uses resourceName // instead of assembly.GetName().Name, and works around a bug in // mono-0.28. private static Assembly GetSatelliteAssembly(Assembly assembly, String resourceName, CultureInfo culture, PathResolver pathResolver) { string satelliteExpectedLocation = pathResolver.Resolve(Path.GetDirectoryName(assembly.Location), resourceName, culture); if (File.Exists(satelliteExpectedLocation)) { return Assembly.LoadFrom(satelliteExpectedLocation); } // Try to load embedded assembly string embeddedResourceId = String.Format("{0}.{1}.{2}", assembly.GetName().Name, culture.Name, GetEmbededSatelliteAssemblyName(resourceName)); using (Stream satAssemblyStream = assembly.GetManifestResourceStream(embeddedResourceId)) { if (satAssemblyStream == null) return null; Byte[] assemblyData = new Byte[satAssemblyStream.Length]; satAssemblyStream.Read(assemblyData, 0, assemblyData.Length); return Assembly.Load(assemblyData); } }
/// <summary> /// Same as default constructor but can be called from assembly other than calling one. /// </summary> /// <param name='assembly'> /// Assembly for locate satellites. /// </param> public GettextResourceManager(Assembly assembly, PathResolver pathResolver) : base(assembly.GetName().Name, assembly, typeof(GettextResourceSet)) { _pathResolver = pathResolver; }