ResourceManager 构造函数
定义
初始化 ResourceManager 类的新实例。Initializes a new instance of the ResourceManager class.
重载
| ResourceManager() |
使用默认值初始化 ResourceManager 类的新实例。Initializes a new instance of the ResourceManager class with default values. |
| ResourceManager(Type) |
它根据指定的对象中的信息在附属程序集内查找资源来初始化 ResourceManager 类的新实例。Initializes a new instance of the ResourceManager class that looks up resources in satellite assemblies based on information from the specified type object. |
| ResourceManager(String, Assembly) |
初始化 ResourceManager 类的新实例,该实例在给定的程序集中查找从指定根名称导出的文件中包含的资源。Initializes a new instance of the ResourceManager class that looks up resources contained in files with the specified root name in the given assembly. |
| ResourceManager(String, Assembly, Type) |
初始化使用指定 ResourceSet 的 ResourceManager 类的新实例,该实例在给定的程序集中的指定根名称类的文件中查找资源。Initializes a new instance of the ResourceManager class that uses a specified ResourceSet class to look up resources contained in files with the specified root name in the given assembly. |
ResourceManager()
使用默认值初始化 ResourceManager 类的新实例。Initializes a new instance of the ResourceManager class with default values.
protected:
ResourceManager();
protected ResourceManager ();
Protected Sub New ()
注解
仅当您编写自己的派生自类的类时,此构造函数才有用 ResourceManager 。This constructor is useful only if you write your own class that derives from the ResourceManager class.
适用于
ResourceManager(Type)
它根据指定的对象中的信息在附属程序集内查找资源来初始化 ResourceManager 类的新实例。Initializes a new instance of the ResourceManager class that looks up resources in satellite assemblies based on information from the specified type object.
public:
ResourceManager(Type ^ resourceSource);
public ResourceManager (Type resourceSource);
new System.Resources.ResourceManager : Type -> System.Resources.ResourceManager
Public Sub New (resourceSource As Type)
参数
- resourceSource
- Type
一个类型,从资源管理器中派生所有用于查找 .resources 文件的信息。A type from which the resource manager derives all information for finding .resources files.
例外
resourceSource 参数为 null。The resourceSource parameter is null.
示例
下面的示例使用 ResourceManager(Type) 构造函数实例化 ResourceManager 对象。The following example uses the ResourceManager(Type) constructor to instantiate a ResourceManager object. 它包含从 .txt 文件中编译的资源,这些资源是英语 (en) 、法语 (法国) (fr-fr) 和俄语 (俄罗斯) (区域性。It consists of resources compiled from .txt files for the English (en), French (France) (fr-FR), and Russian (Russia) (ru-RU) cultures. 该示例将当前区域性和当前 UI 区域性更改为英语 (美国) 、法语 (法国) 、俄语 (俄罗斯) 和瑞典语 (瑞典) 。The example changes the current culture and current UI culture to English (United States), French (France), Russian (Russia), and Swedish (Sweden). 然后,它会调用 GetString(String) 方法来检索已本地化的字符串,该字符串将显示依赖于当天的时间的问候语。It then calls the GetString(String) method to retrieve the localized string, which displays a greeting that depends on the time of day.
该示例需要三个基于文本的资源文件,如下表所示。The example requires three text-based resource files, as listed in the following table. 每个文件都包含名为、和的字符串资源 Morning Afternoon Evening 。Each file includes string resources named Morning, Afternoon, and Evening.
| 环境Culture | 文件名File name | 资源名称Resource name | 资源值Resource value |
|---|---|---|---|
| zh-CNen-US | GreetingResources.txtGreetingResources.txt | Morning |
早上好Good morning |
| zh-CNen-US | GreetingResources.txtGreetingResources.txt | Afternoon |
下午好Good afternoon |
| zh-CNen-US | GreetingResources.txtGreetingResources.txt | Evening |
晚上好Good evening |
| fr-FRfr-FR | GreetingResources.fr-FR.txtGreetingResources.fr-FR.txt | Morning |
BonjourBonjour |
| fr-FRfr-FR | GreetingResources.fr-FR.txtGreetingResources.fr-FR.txt | Afternoon |
BonjourBonjour |
| fr-FRfr-FR | GreetingResources.fr-FR.txtGreetingResources.fr-FR.txt | Evening |
BonsoirBonsoir |
| ru-RUru-RU | GreetingResources.ru-RU.txtGreetingResources.ru-RU.txt | Morning |
Доброе утроДоброе утро |
| ru-RUru-RU | GreetingResources.ru-RU.txtGreetingResources.ru-RU.txt | Afternoon |
Добрый деньДобрый день |
| ru-RUru-RU | GreetingResources.ru-RU.txtGreetingResources.ru-RU.txt | Evening |
Добрый вечерДобрый вечер |
您可以使用以下批处理文件编译 Visual Basic 示例并创建一个名为 Greet.exe 的可执行文件。You can use the following batch file to compile the Visual Basic example and create an executable named Greet.exe. 若要用 c # 进行编译,请将编译器的名称从更改 vbc 为, csc 并将文件扩展名从更改 .vb 为 .cs 。To compile with C#, change the compiler name from vbc to csc and the file extension from .vb to .cs.
resgen GreetingResources.txt
vbc Greet.vb /resource: GreetingResources.resources
md fr-FR
resgen GreetingResources.fr-FR.txt
al /out:fr-FR\Greet.resources.dll /culture:fr-FR /embed: GreetingResources.fr-FR.resources
md ru-RU
resgen GreetingResources.ru-RU.txt
al /out:ru-RU\Greet.resources.dll /culture:ru-RU /embed: GreetingResources.ru-RU.resources
下面是 Visual Basic 版本的示例 (ShowDate 的源代码,或 c # 版本) 的 ShowDate 版本的代码。Here's the source code for the example (ShowDate.vb for the Visual Basic version or ShowDate.cs for the C# version of the code).
using System;
using System.Resources;
using System.Globalization;
using System.Threading;
[assembly:NeutralResourcesLanguage("en")]
public class Example
{
public static void Main()
{
string[] cultureNames = {"en-US", "fr-FR", "ru-RU", "sv-SE" };
DateTime noon = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
DateTime.Now.Day, 12,0,0);
DateTime evening = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
DateTime.Now.Day, 18, 0, 0);
ResourceManager rm = new ResourceManager(typeof(GreetingResources));
foreach (var cultureName in cultureNames) {
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultureName);
Console.WriteLine("The current UI culture is {0}",
CultureInfo.CurrentUICulture.Name);
if (DateTime.Now < noon)
Console.WriteLine("{0}!", rm.GetString("Morning"));
else if (DateTime.Now < evening)
Console.WriteLine("{0}!", rm.GetString("Afternoon"));
else
Console.WriteLine("{0}!", rm.GetString("Evening"));
Console.WriteLine();
}
}
internal class GreetingResources
{
}
}
// The example displays output like the following:
// The current UI culture is en-US
// Good afternoon!
//
// The current UI culture is fr-FR
// Bonjour!
//
// The current UI culture is ru-RU
// Добрый день!
//
// The current UI culture is sv-SE
// Good afternoon!
Imports System.Resources
Imports System.Globalization
Imports System.Threading
<Assembly:NeutralResourcesLanguage("en")>
Module Example
Public Sub Main()
Dim cultureNames() As String = {"en-US", "fr-FR", "ru-RU", "sv-SE" }
Dim noon As New Date(Date.Now.Year, Date.Now.Month,
Date.Now.Day, 12,0,0)
Dim evening As New Date(Date.Now.Year, Date.Now.Month,
Date.Now.Day, 18, 0, 0)
Dim rm As New ResourceManager(GetType(GreetingResources))
For Each cultureName In cultureNames
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultureName)
Console.WriteLine("The current UI culture is {0}",
CultureInfo.CurrentUICulture.Name)
If Date.Now < noon Then
Console.WriteLine("{0}!", rm.GetString("Morning"))
ElseIf Date.Now < evening Then
Console.WriteLine("{0}!", rm.GetString("Afternoon"))
Else
Console.WriteLine("{0}!", rm.GetString("Evening"))
End If
Console.WriteLine()
Next
End Sub
End Module
Friend Class GreetingResources
End Class
' The example displays output like the following:
' The current UI culture is en-US
' Good afternoon!
'
' The current UI culture is fr-FR
' Bonjour!
'
' The current UI culture is ru-RU
' Добрый день!
'
' The current UI culture is sv-SE
' Good afternoon!
除了定义名为的应用类之外 Example ,源代码还定义了一个内部类,其名称与 GreetingResources 资源文件的基名称相同。In addition to defining an app class named Example, the source code defines an internal class whose name, GreetingResources, is the same as the base name of the resource files. 这样就可以 ResourceManager 通过调用构造函数来成功地实例化对象 ResourceManager(Type) 。This makes it possible to successfully instantiate a ResourceManager object by calling the ResourceManager(Type) constructor.
请注意,输出将显示适当的本地化字符串,除非当前 UI 区域性为瑞典语 (瑞典) ,在这种情况下,它使用英语资源。Notice that the output displays the appropriate localized string except when the current UI culture is Swedish (Sweden), in which case it uses English language resources. 由于瑞典语的资源不可用,因此应用程序将使用由特性定义的默认区域性的资源 NeutralResourcesLanguageAttribute 。Because Swedish language resources are unavailable, the app uses the resources of the default culture, as defined by the NeutralResourcesLanguageAttribute attribute, instead.
注解
桌面应用Desktop Apps
在桌面应用中,资源管理器使用 resourceSource 参数加载特定的资源文件,如下所示:In desktop apps, the resource manager uses the resourceSource parameter to load a particular resource file as follows:
如果 NeutralResourcesLanguageAttribute 未使用特性指示默认区域性的资源位于附属程序集中,则资源管理器假定在与参数指定的类型相同的程序集中找到默认区域性的资源文件
resourceSource。If the NeutralResourcesLanguageAttribute attribute is not used to indicate that the resources of the default culture reside in a satellite assembly, the resource manager assumes that the resource file for the default culture is found in the same assembly as the type specified by theresourceSourceparameter.资源管理器假定默认资源文件的基名称与参数指定的类型相同
resourceSource。The resource manager assumes that the default resource file has the same base name as the type specified by theresourceSourceparameter.资源管理器使用默认 ResourceSet 类处理资源文件。The resource manager uses the default ResourceSet class to manipulate the resource file.
例如,假设有一个名为 MyCompany. MyProduct 的类型,则资源管理器会在定义 MyProduct 的程序集内查找名为 MyCompany. MyType. MyType..。For example, given a type named MyCompany.MyProduct.MyType, the resource manager looks for a .resources file named MyCompany.MyProduct.MyType.resources in the assembly that defines MyType.
在 Visual Studio 中,资源设计器会自动生成代码,该代码在 internal c # 中定义一个 () 或 Friend (Visual Basic) 类中的名称与默认区域性的 .resources 文件的基名称相同。In Visual Studio, the Resource Designer automatically generates code that defines an internal (in C#) or Friend (in Visual Basic) class whose name is the same as the base name of the .resources file for the default culture. 这样一来,就可以 ResourceManager 通过获取名称与资源名称对应的类型对象来实例化对象并将其与一组特定的资源结合使用,因为只要类对编译器可见,资源也必须相同。This makes it possible to instantiate a ResourceManager object and couple it with a particular set of resources by getting a type object whose name corresponds to the name of the resource, because as long as the class is visible to the compiler, the resources must be as well. 例如,如果 .resources 文件命名为 Resource1.resx,则以下语句将实例化一个 ResourceManager 对象来管理名为 resource1.resx 的 .resources 文件:For example, if a .resources file is named Resource1, the following statement instantiates a ResourceManager object to manage the .resources file named Resource1:
ResourceManager rm = new ResourceManager(typeof(Resource1));
如果未使用 Visual Studio,则可以创建一个类,其中没有命名空间和名称与默认 .resources 文件相同的成员。If you're not using Visual Studio, you can create a class with no members whose namespace and name are the same as that of the default .resources file. 说明如示例所示。The example provides an illustration.
Windows 8.x 应用商店应用Windows 8.x Store Apps
重要
尽管此 ResourceManager 类在 Windows 8.x 应用商店应用中受支持,但我们不建议使用它。Although the ResourceManager class is supported in Windows 8.x Store apps, we do not recommend its use. 仅当开发可用于 Windows 8.x 应用商店应用程序的可移植类库项目时,才使用此类。Use this class only when you develop Portable Class Library projects that can be used with Windows 8.x Store apps. 若要从 Windows 8.x 应用商店应用中检索资源,请改用 windows.applicationmodel.resources.core. windows.applicationmodel.resources.resourceloader 类。To retrieve resources from Windows 8.x Store apps, use the Windows.ApplicationModel.Resources.ResourceLoader class instead.
在 Windows 8.x 应用商店应用中, ResourceManager 使用 resourceSource 参数来推断程序集、基名称和命名空间,其中的资源项可位于应用的包资源索引 (PRI) 文件中。In Windows 8.x Store apps, ResourceManager uses the resourceSource parameter to infer the assembly, base name, and the namespace where the resource items can be located within the app's package resource index (PRI) file. 例如,如果在中定义了一个名为 MyCompany. MyProduct. MyType 的类型 MyAssembly ,则资源管理器将查找名为 MyAssembly 的资源集标识符,并在该资源集内查找作用域 MyCompany. MyProduct。For example, given a type named MyCompany.MyProduct.MyType that is defined in MyAssembly, the resource manager looks for a resource set identifier named MyAssembly and looks for a scope MyCompany.MyProduct.MyType within that resource set. 资源管理器将在默认上下文中搜索资源项, (当前的区域性、当前高对比度设置等) 此范围内的。The resource manager searches for resource items under the default context (current culture, current high contrast setting, and so on) within this scope.
适用于
ResourceManager(String, Assembly)
初始化 ResourceManager 类的新实例,该实例在给定的程序集中查找从指定根名称导出的文件中包含的资源。Initializes a new instance of the ResourceManager class that looks up resources contained in files with the specified root name in the given assembly.
public:
ResourceManager(System::String ^ baseName, System::Reflection::Assembly ^ assembly);
public ResourceManager (string baseName, System.Reflection.Assembly assembly);
new System.Resources.ResourceManager : string * System.Reflection.Assembly -> System.Resources.ResourceManager
Public Sub New (baseName As String, assembly As Assembly)
参数
- baseName
- String
资源文件的根名称,没有其扩展名但是包含所有完全限定的命名空间名称。The root name of the resource file without its extension but including any fully qualified namespace name. 例如,名为 MyApplication.MyResource.en-US.resources 的资源文件的根名称为 MyApplication.MyResource。For example, the root name for the resource file named MyApplication.MyResource.en-US.resources is MyApplication.MyResource.
- assembly
- Assembly
资源的主程序集。The main assembly for the resources.
例外
baseName 或 assembly 参数为 null。The baseName or assembly parameter is null.
示例
下面的示例使用简单的非本地化 "Hello World" 应用程序来说明 ResourceManager(String, Assembly) 构造函数。The following example uses a simple non-localized "Hello World" app to illustrate the ResourceManager(String, Assembly) constructor. 下面显示了一个名为 ExampleResources.txt 的文本文件的内容。The following shows the contents of a text file named ExampleResources.txt. 在编译应用程序时,会将资源嵌入主应用程序集中。When the app is compiled, the resource is embedded in the main app assembly.
Greeting=Hello
在命令提示符下,可以使用 资源文件生成器 (ResGen.exe) 将文本文件转换为二进制资源文件,如下所示:The text file can be converted to a binary resource file by using the Resource File Generator (ResGen.exe) at the command prompt as follows:
resgen ExampleResources.txt
下面的示例提供了实例化对象的可执行代码 ResourceManager ,并提示用户输入名称并显示问候语。The following example provides the executable code that instantiates a ResourceManager object, prompts the user to enter a name, and displays a greeting.
using System;
using System.Reflection;
using System.Resources;
public class Example
{
public static void Main()
{
// Retrieve the resource.
ResourceManager rm = new ResourceManager("ExampleResources" ,
typeof(Example).Assembly);
string greeting = rm.GetString("Greeting");
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.WriteLine("{0} {1}!", greeting, name);
}
}
// The example produces output similar to the following:
// Enter your name: John
// Hello John!
Imports System.Globalization
Imports System.Reflection
Imports System.Resources
Module Example
Public Sub Main()
' Retrieve the resource.
Dim rm As New ResourceManager("ExampleResources",
GetType(Example).Assembly)
Dim greeting As String = rm.GetString("Greeting")
Console.Write("Enter your name: ")
Dim name As String = Console.ReadLine()
Console.WriteLine("{0} {1}!", greeting, name)
End Sub
End Module
' The example produces output similar to the following:
' Enter your name: John
' Hello John!
可以在 Visual Basic 中使用以下命令编译该方法:It can be compiled by using the following command in Visual Basic:
vbc Example.vb /resource:ExampleResources.resources
或者,在 c # 中使用以下命令:or by using the following command in C#:
csc Example.cs /resource:ExampleResources.resources
请注意,该示例通过将该程序集中定义的类型传递给 c) Visual Basic () # 中的函数 (,将该程序集中定义的类型传递给 typeof 函数, GetType 并检索其属性的值,从而检索对包含该资源文件的程序集的引用 Type.Assembly 。Note that the example retrieves a reference to the assembly that contains the resource file by passing a type defined in that assembly to the typeof function (in C#) or the GetType function (in Visual Basic) and retrieving the value of its Type.Assembly property.
注解
桌面应用Desktop Apps
在桌面应用中,每个特定于区域性的资源文件应包含在附属程序集中,并且默认区域性的资源文件应包含在主程序集中。In desktop apps, the individual culture-specific resource files should be contained in satellite assemblies, and the default culture's resource file should be contained in the main assembly. 假设附属程序集包含该程序集清单中指定的单个区域性的资源,并在必要时进行加载。A satellite assembly is assumed to contain resources for a single culture specified in that assembly's manifest, and is loaded as necessary.
备注
若要直接从 .resources 文件检索资源而不是从程序集检索资源,则必须 CreateFileBasedResourceManager 改为调用方法来实例化 ResourceManager 对象。To retrieve resources from .resources files directly instead of retrieving them from assemblies, you must call the CreateFileBasedResourceManager method instead to instantiate a ResourceManager object.
如果 baseName 在中找不到标识的资源文件 assembly ,则该方法将实例化 ResourceManager 对象,但检索特定资源的尝试通常会引发异常 MissingManifestResourceException 。If the resource file identified by baseName cannot be found in assembly, the method instantiates a ResourceManager object, but the attempt to retrieve a specific resource throws an exception, typically MissingManifestResourceException. 有关诊断引发异常的原因的信息,请参阅类主题中的 "处理 MissingManifestResourceException 异常" 一节 ResourceManager 。For information about diagnosing the cause of the exception, see the "Handling the MissingManifestResourceException Exception" section of the ResourceManager class topic.
Windows 8.x 应用商店应用Windows 8.x Store Apps
重要
尽管此 ResourceManager 类在 Windows 8.x 应用商店应用中受支持,但我们不建议使用它。Although the ResourceManager class is supported in Windows 8.x Store apps, we do not recommend its use. 仅当开发可用于 Windows 8.x 应用商店应用程序的可移植类库项目时,才使用此类。Use this class only when you develop Portable Class Library projects that can be used with Windows 8.x Store apps. 若要从 Windows 8.x 应用商店应用中检索资源,请改用 windows.applicationmodel.resources.core. windows.applicationmodel.resources.resourceloader 类。To retrieve resources from Windows 8.x Store apps, use the Windows.ApplicationModel.Resources.ResourceLoader class instead.
在 Windows 8.x 应用商店应用中,资源管理器使用参数的简单名称在 assembly 应用的包资源索引 (PRI) 文件中查找匹配的资源集。In Windows 8.x Store apps, the resource manager uses the simple name of the assembly parameter to look up a matching resource set in the app's package resource index (PRI) file. baseName参数用于查找资源集内的资源项。The baseName parameter is used to look up a resource item within the resource set. 例如,PortableLibrary1.Resource1.de 的根名称为 PortableLibrary1. Resource1.resx。For example, the root name for PortableLibrary1.Resource1.de-DE.resources is PortableLibrary1.Resource1.
继承者说明
此构造函数使用系统提供的 ResourceSet 实现。This constructor uses the system-provided ResourceSet implementation. 若要使用自定义资源文件格式,应从类派生 ResourceSet ,重写 GetDefaultReader() 和 GetDefaultWriter() 方法,然后将该类型传递给 ResourceManager(String, Assembly, Type) 构造函数。To use a custom resource file format, you should derive from the ResourceSet class, override the GetDefaultReader() and GetDefaultWriter() methods, and pass that type to the ResourceManager(String, Assembly, Type) constructor. 使用自定义 ResourceSet 对于控制资源缓存策略或支持您自己的资源文件格式非常有用,但通常不是必需的。Using a custom ResourceSet can be useful for controlling resource caching policy or supporting your own resource file format, but is generally not necessary.
适用于
ResourceManager(String, Assembly, Type)
初始化使用指定 ResourceSet 的 ResourceManager 类的新实例,该实例在给定的程序集中的指定根名称类的文件中查找资源。Initializes a new instance of the ResourceManager class that uses a specified ResourceSet class to look up resources contained in files with the specified root name in the given assembly.
public:
ResourceManager(System::String ^ baseName, System::Reflection::Assembly ^ assembly, Type ^ usingResourceSet);
public ResourceManager (string baseName, System.Reflection.Assembly assembly, Type? usingResourceSet);
public ResourceManager (string baseName, System.Reflection.Assembly assembly, Type usingResourceSet);
new System.Resources.ResourceManager : string * System.Reflection.Assembly * Type -> System.Resources.ResourceManager
Public Sub New (baseName As String, assembly As Assembly, usingResourceSet As Type)
参数
- baseName
- String
资源文件的根名称,没有其扩展名但是包含所有完全限定的命名空间名称。The root name of the resource file without its extension but including any fully qualified namespace name. 例如,名为 MyApplication.MyResource.en-US.resources 的资源文件的根名称为 MyApplication.MyResource。For example, the root name for the resource file named MyApplication.MyResource.en-US.resources is MyApplication.MyResource.
- assembly
- Assembly
资源的主程序集。The main assembly for the resources.
- usingResourceSet
- Type
要使用的自定义 ResourceSet 的类型。The type of the custom ResourceSet to use. 如果为 null,则使用默认的运行时 ResourceSet 对象。If null, the default runtime ResourceSet object is used.
例外
usingResourceset 不是 ResourceSet 的派生类。usingResourceset is not a derived class of ResourceSet.
baseName 或 assembly 参数为 null。The baseName or assembly parameter is null.
注解
单个区域性特定的资源文件应包含在附属程序集中,并且默认区域性的资源文件应包含在主程序集中。The individual culture-specific resource files should be contained in satellite assemblies, and the default culture's resource file should be contained in the main assembly. 假设附属程序集包含该程序集清单中指定的单个区域性的资源,并在必要时进行加载。A satellite assembly is assumed to contain resources for a single culture specified in that assembly's manifest, and is loaded as necessary.
备注
若要直接从 .resources 文件检索资源而不是从程序集检索资源,则必须 CreateFileBasedResourceManager 改为调用方法来实例化 ResourceManager 对象。To retrieve resources from .resources files directly instead of retrieving them from assemblies, you must call the CreateFileBasedResourceManager method instead to instantiate a ResourceManager object.
如果 baseName 在中找不到标识的资源文件 assembly ,则该方法将实例化 ResourceManager 对象,但检索特定资源的尝试通常会引发异常 MissingManifestResourceException 。If the resource file identified by baseName cannot be found in assembly, the method instantiates a ResourceManager object, but the attempt to retrieve a specific resource throws an exception, typically MissingManifestResourceException. 有关诊断引发异常的原因的信息,请参阅类主题中的 "处理 MissingManifestResourceException 异常" 一节 ResourceManager 。For information about diagnosing the cause of the exception, see the "Handling the MissingManifestResourceException Exception" section of the ResourceManager class topic.
备注
usingResourceSet参数用于支持您自己的资源格式,通常为 null 。The usingResourceSet parameter is used to support your own resource format, and will commonly be null. 这不同于只采用的构造函数 Type 。This is different from the constructor that takes a Type only.
调用方说明
此构造函数允许指定 ResourceSet 实现。This constructor lets you specify a ResourceSet implementation. 如果你不想使用特定的 ResourceSet 实现,但想要使用自定义资源文件格式,则应该从类派生 ResourceSet ,重写 GetDefaultReader() 和 GetDefaultWriter() 方法,然后将该类型传递给此构造函数。If you do not want a specific ResourceSet implementation but would like to use a custom resource file format, you should derive from the ResourceSet class, override the GetDefaultReader() and GetDefaultWriter() methods, and pass that type to this constructor.