ResourceSet ResourceSet ResourceSet ResourceSet Constructors

定义

重载

ResourceSet() ResourceSet() ResourceSet()

使用默认属性初始化 ResourceSet 类的新实例。Initializes a new instance of the ResourceSet class with default properties.

ResourceSet(Stream) ResourceSet(Stream) ResourceSet(Stream)

使用从给定流中读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that reads resources from the given stream.

ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader)

使用指定的资源阅读器创建 ResourceSet 类的新实例。Creates a new instance of the ResourceSet class using the specified resource reader.

ResourceSet(String) ResourceSet(String) ResourceSet(String) ResourceSet(String)

使用从给定文件打开并读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.

ResourceSet() ResourceSet() ResourceSet()

使用默认属性初始化 ResourceSet 类的新实例。Initializes a new instance of the ResourceSet class with default properties.

protected:
 ResourceSet();
protected ResourceSet ();
Protected Sub New ()

ResourceSet(Stream) ResourceSet(Stream) ResourceSet(Stream)

使用从给定流中读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that reads resources from the given stream.

public:
 ResourceSet(System::IO::Stream ^ stream);
[System.Security.SecurityCritical]
public ResourceSet (System.IO.Stream stream);
new System.Resources.ResourceSet : System.IO.Stream -> System.Resources.ResourceSet

参数

stream
Stream Stream Stream Stream

要读取的资源的 StreamThe Stream of resources to be read. 流应引用现有的资源文件。The stream should refer to an existing resources file.

异常

stream 不可读。The stream is not readable.

stream 参数为 nullThe stream parameter is null.

安全性

SecurityPermission
用于提供序列化服务。for providing serialization services. 关联的枚举: SerializationFormatter 安全操作: LinkDemandAssociated enumeration: SerializationFormatter Security action: LinkDemand

SecurityCriticalAttribute
直接调用方需要完全信任。requires full trust for the immediate caller. 不能由部分受信任的或透明的代码使用此成员。This member cannot be used by partially trusted or transparent code.

ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader)

使用指定的资源阅读器创建 ResourceSet 类的新实例。Creates a new instance of the ResourceSet class using the specified resource reader.

public:
 ResourceSet(System::Resources::IResourceReader ^ reader);
public ResourceSet (System.Resources.IResourceReader reader);
new System.Resources.ResourceSet : System.Resources.IResourceReader -> System.Resources.ResourceSet
Public Sub New (reader As IResourceReader)

参数

reader
IResourceReader IResourceReader IResourceReader IResourceReader

将使用的读取器。The reader that will be used.

异常

reader 参数为 nullThe reader parameter is null.

注解

可以使用此构造函数来支持使用用户提供的自定义的资源格式IResourceReaderYou can use this constructor to support custom resource formats using a user-provided IResourceReader.

ResourceSet(String) ResourceSet(String) ResourceSet(String) ResourceSet(String)

使用从给定文件打开并读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.

public:
 ResourceSet(System::String ^ fileName);
public ResourceSet (string fileName);
new System.Resources.ResourceSet : string -> System.Resources.ResourceSet
Public Sub New (fileName As String)

参数

fileName
String String String String

要读取的资源文件。Resource file to read.

异常

fileName 参数为 nullThe fileName parameter is null.

示例

下面的代码示例定义的新实例ResourceSet特定文件类循环访问该文件中,使用的资源并将其内容显示到控制台。The following code example defines a new instance of the ResourceSet class for a specific file, iterates through the resources used by that file, and displays their contents to the console.

using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
   
   // Create a ResourceSet for the file items.resources.
   ResourceSet^ rs = gcnew ResourceSet( "items.resources" );
   
   // Create an IDictionaryEnumerator* to read the data in the ResourceSet.
   IDictionaryEnumerator^ id = rs->GetEnumerator();
   
   // Iterate through the ResourceSet and display the contents to the console.
   while ( id->MoveNext() )
      Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );

   rs->Close();
}

using System;
using System.Resources;
using System.Collections;

class EnumerateResources 
{
    public static void Main() 
    {
        // Create a ResourceSet for the file items.resources.
        ResourceSet rs = new ResourceSet("items.resources"); 

        
        // Create an IDictionaryEnumerator to read the data in the ResourceSet.
        IDictionaryEnumerator id = rs.GetEnumerator(); 

        // Iterate through the ResourceSet and display the contents to the console. 
        while(id.MoveNext())
          Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value); 

        rs.Close();
 
    }
}
Imports System
Imports System.Resources
Imports System.Collections
Imports Microsoft.VisualBasic

Class EnumerateResources
   
   Public Shared Sub Main()
      ' Create a ResourceSet for the file items.resources.
      Dim rs As New ResourceSet("items.resources")      
      
      ' Create an IDictionaryEnumerator to read the data in the ResourceSet.
      Dim id As IDictionaryEnumerator = rs.GetEnumerator()
      
      ' Iterate through the ResourceSet and display the contents to the console. 
      While id.MoveNext()
         Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value)
      End While 

      rs.Close()

   End Sub

End Class

适用于