Redigera

Dela via


ResXResourceReader Constructors

Definition

Initializes a new instance of the ResXResourceReader class.

Overloads

ResXResourceReader(Stream)

Initializes a new instance of the ResXResourceReader class for the specified stream.

ResXResourceReader(TextReader)

Initializes a new instance of the ResXResourceReader class for the specified TextReader.

ResXResourceReader(String)

Initializes a new instance of the ResXResourceReader class for the specified resource file.

ResXResourceReader(Stream, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using an input stream and a type resolution service.

ResXResourceReader(Stream, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using a stream and an array of assembly names.

ResXResourceReader(TextReader, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using a text stream reader and a type resolution service.

ResXResourceReader(TextReader, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using a TextReader object and an array of assembly names.

ResXResourceReader(String, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using a file name and a type resolution service.

ResXResourceReader(String, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using an XML resource file name and an array of assembly names.

ResXResourceReader(Stream)

Initializes a new instance of the ResXResourceReader class for the specified stream.

public:
 ResXResourceReader(System::IO::Stream ^ stream);
public ResXResourceReader (System.IO.Stream stream);
new System.Resources.ResXResourceReader : System.IO.Stream -> System.Resources.ResXResourceReader
Public Sub New (stream As Stream)

Parameters

stream
Stream

An input stream that contains resources.

Remarks

Note

The Dispose and Close methods do not close the stream you specify in this constructor.

Applies to

ResXResourceReader(TextReader)

Initializes a new instance of the ResXResourceReader class for the specified TextReader.

public:
 ResXResourceReader(System::IO::TextReader ^ reader);
public ResXResourceReader (System.IO.TextReader reader);
new System.Resources.ResXResourceReader : System.IO.TextReader -> System.Resources.ResXResourceReader
Public Sub New (reader As TextReader)

Parameters

reader
TextReader

A text input stream that contains resources.

Applies to

ResXResourceReader(String)

Initializes a new instance of the ResXResourceReader class for the specified resource file.

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

Parameters

fileName
String

The path of the resource file to read.

Examples

The following example creates a new instance of the ResXResourceReader class for the specified file, iterates through the resources of the file, and displays the contents to the console.

#using <system.windows.forms.dll>
#using <System.dll>

using namespace System;
using namespace System::Resources;
using namespace System::Collections;
void main()
{

   // Create a ResXResourceReader for the file items.resx.
   ResXResourceReader^ rsxr = gcnew ResXResourceReader( "items.resx" );


   // Iterate through the resources and display the contents to the console.
   IEnumerator^ myEnum = rsxr->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      DictionaryEntry^ d = safe_cast<DictionaryEntry^>(myEnum->Current);
      Console::WriteLine( "{0}:\t {1}", d->Key, d->Value );
   }


   //Close the reader.
   rsxr->Close();
}
using System;
using System.Resources;
using System.Collections;

class ReadResXResources
{
   public static void Main()
   {

      // Create a ResXResourceReader for the file items.resx.
      ResXResourceReader rsxr = new ResXResourceReader("items.resx");

      // Iterate through the resources and display the contents to the console.
      foreach (DictionaryEntry d in rsxr)
      {
    Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString());
      }

     //Close the reader.
     rsxr.Close();
   }
}
Imports System.Resources
Imports System.Collections

Class ReadResXResources
   
   Public Shared Sub Main()
      
      ' Create a ResXResourceReader for the file items.resx.
      Dim rsxr As ResXResourceReader
      rsxr = New ResXResourceReader("items.resx")

      ' Iterate through the resources and display the contents to the console.
      Dim d As DictionaryEntry
      For Each d In  rsxr
         Console.WriteLine(d.Key.ToString() + ":" + ControlChars.Tab + d.Value.ToString())
      Next d
      
      'Close the reader.
      rsxr.Close()

   End Sub

End Class

Applies to

ResXResourceReader(Stream, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using an input stream and a type resolution service.

public:
 ResXResourceReader(System::IO::Stream ^ stream, System::ComponentModel::Design::ITypeResolutionService ^ typeResolver);
public ResXResourceReader (System.IO.Stream stream, System.ComponentModel.Design.ITypeResolutionService typeResolver);
new System.Resources.ResXResourceReader : System.IO.Stream * System.ComponentModel.Design.ITypeResolutionService -> System.Resources.ResXResourceReader
Public Sub New (stream As Stream, typeResolver As ITypeResolutionService)

Parameters

stream
Stream

An input stream that contains resources.

typeResolver
ITypeResolutionService

An object that resolves type names specified in a resource.

Applies to

ResXResourceReader(Stream, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using a stream and an array of assembly names.

public:
 ResXResourceReader(System::IO::Stream ^ stream, cli::array <System::Reflection::AssemblyName ^> ^ assemblyNames);
public ResXResourceReader (System.IO.Stream stream, System.Reflection.AssemblyName[] assemblyNames);
new System.Resources.ResXResourceReader : System.IO.Stream * System.Reflection.AssemblyName[] -> System.Resources.ResXResourceReader
Public Sub New (stream As Stream, assemblyNames As AssemblyName())

Parameters

stream
Stream

An input stream that contains resources.

assemblyNames
AssemblyName[]

An array of AssemblyName objects that specifies one or more assemblies. The assemblies are used to resolve a type name in the resource to an actual type.

Applies to

ResXResourceReader(TextReader, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using a text stream reader and a type resolution service.

public:
 ResXResourceReader(System::IO::TextReader ^ reader, System::ComponentModel::Design::ITypeResolutionService ^ typeResolver);
public ResXResourceReader (System.IO.TextReader reader, System.ComponentModel.Design.ITypeResolutionService typeResolver);
new System.Resources.ResXResourceReader : System.IO.TextReader * System.ComponentModel.Design.ITypeResolutionService -> System.Resources.ResXResourceReader
Public Sub New (reader As TextReader, typeResolver As ITypeResolutionService)

Parameters

reader
TextReader

A text stream reader that contains resources.

typeResolver
ITypeResolutionService

An object that resolves type names specified in a resource.

Applies to

ResXResourceReader(TextReader, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using a TextReader object and an array of assembly names.

public:
 ResXResourceReader(System::IO::TextReader ^ reader, cli::array <System::Reflection::AssemblyName ^> ^ assemblyNames);
public ResXResourceReader (System.IO.TextReader reader, System.Reflection.AssemblyName[] assemblyNames);
new System.Resources.ResXResourceReader : System.IO.TextReader * System.Reflection.AssemblyName[] -> System.Resources.ResXResourceReader
Public Sub New (reader As TextReader, assemblyNames As AssemblyName())

Parameters

reader
TextReader

An object used to read resources from a stream of text.

assemblyNames
AssemblyName[]

An array of AssemblyName objects that specifies one or more assemblies. The assemblies are used to resolve a type name in the resource to an actual type.

Applies to

ResXResourceReader(String, ITypeResolutionService)

Initializes a new instance of the ResXResourceReader class using a file name and a type resolution service.

public:
 ResXResourceReader(System::String ^ fileName, System::ComponentModel::Design::ITypeResolutionService ^ typeResolver);
public ResXResourceReader (string fileName, System.ComponentModel.Design.ITypeResolutionService typeResolver);
public ResXResourceReader (string fileName, System.ComponentModel.Design.ITypeResolutionService? typeResolver);
new System.Resources.ResXResourceReader : string * System.ComponentModel.Design.ITypeResolutionService -> System.Resources.ResXResourceReader
Public Sub New (fileName As String, typeResolver As ITypeResolutionService)

Parameters

fileName
String

The name of an XML resource file that contains resources.

typeResolver
ITypeResolutionService

An object that resolves type names specified in a resource.

Applies to

ResXResourceReader(String, AssemblyName[])

Initializes a new instance of the ResXResourceReader class using an XML resource file name and an array of assembly names.

public:
 ResXResourceReader(System::String ^ fileName, cli::array <System::Reflection::AssemblyName ^> ^ assemblyNames);
public ResXResourceReader (string fileName, System.Reflection.AssemblyName[] assemblyNames);
new System.Resources.ResXResourceReader : string * System.Reflection.AssemblyName[] -> System.Resources.ResXResourceReader
Public Sub New (fileName As String, assemblyNames As AssemblyName())

Parameters

fileName
String

The name of an XML resource file that contains resources.

assemblyNames
AssemblyName[]

An array of AssemblyName objects that specifies one or more assemblies. The assemblies are used to resolve a type name in the resource to an actual type.

Applies to