ResXResourceSet 클래스

정의

XML 리소스(.resx) 파일에 모든 리소스를 표현합니다.

public ref class ResXResourceSet : System::Resources::ResourceSet
public class ResXResourceSet : System.Resources.ResourceSet
type ResXResourceSet = class
    inherit ResourceSet
Public Class ResXResourceSet
Inherits ResourceSet
상속
ResXResourceSet

예제

다음 예제에서는 ResXResourceSet 개체 및 해당 리소스를 열거 하 고 이름으로 개별 리소스를 검색 하는 방법을 보여 줍니다. 열거 하는 각 리소스에 대 한 예제는 다음과 같이 사용 됩니다. 합니다 IDictionaryEnumerator.Key 속성에 대 한 호출에는 GetString 또는 GetObject 리소스의 값을 문자열 또는 개체 인지에 따라 메서드.

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

public class Example
{
   public static void Main()
   {
      CreateResXFile();
      
      ResXResourceSet resSet = new ResXResourceSet(@".\StoreResources.resx");
      IDictionaryEnumerator dict = resSet.GetEnumerator();
      while (dict.MoveNext()) {
         string key = (string) dict.Key;
         // Retrieve resource by name.
         if (dict.Value is string)
            Console.WriteLine("{0}: {1}", key, resSet.GetString(key));
         else
            Console.WriteLine("{0}: {1}", key, resSet.GetObject(key));   
      }
   }

   private static void CreateResXFile()
   {
      Bitmap logo = new Bitmap(@".\Logo.bmp");
      ResXDataNode node;
      
      ResXResourceWriter rw = new ResXResourceWriter(@".\StoreResources.resx");
      node = new ResXDataNode("Logo", logo);
      node.Comment = "The corporate logo.";
      rw.AddResource(node); 
      rw.AddResource("AppTitle", "Store Locations");
      node = new ResXDataNode("nColumns", 5);
      node.Comment = "The number of columns in the Store Location table";
      rw.AddResource(node);
      rw.AddResource("City", "City");
      rw.AddResource("State", "State");
      rw.AddResource("Code", "Zip Code");
      rw.AddResource("Telephone", "Phone");
      rw.Generate();
      rw.Close();
   }
}
// The example displays the following output:
//       Telephone: Phone
//       Code: Zip Code
//       State: State
//       City: City
//       nColumns: 5
//       AppTitle: Store Locations
//       Logo: System.Drawing.Bitmap
Imports System.Collections
Imports System.Drawing
Imports System.Resources

Module Example
   Public Sub Main()
      CreateResXFile()
      
      Dim resSet As New ResXResourceSet(".\StoreResources.resx")
      Dim dict As IDictionaryEnumerator = resSet.GetEnumerator()
      Do While dict.MoveNext()
         Dim key As String = CStr(dict.Key)
         ' Retrieve resource by name.
         If typeof dict.Value Is String Then
            Console.WriteLine("{0}: {1}", key, resSet.GetString(key))
         Else
            Console.WriteLine("{0}: {1}", key, resSet.GetObject(key))   
         End If
      Loop
   End Sub
   
   Private Sub CreateResXFile()
      Dim logo As New Bitmap(".\Logo.bmp")
      Dim node As ResXDataNode
      
      Dim rw As New ResXResourceWriter(".\StoreResources.resx")
      node = New ResXDataNode("Logo", logo)
      node.Comment = "The corporate logo."
      rw.AddResource(node) 
      rw.AddResource("AppTitle", "Store Locations")
      node = New ResXDataNode("nColumns", 5)
      node.Comment = "The number of columns in the Store Location table"
      rw.AddResource(node)
      rw.AddResource("City", "City")
      rw.AddResource("State", "State")
      rw.AddResource("Code", "Zip Code")
      rw.AddResource("Telephone", "Phone")
      rw.Generate()
      rw.Close()
   End Sub
End Module
' The example displays the following output:
'       Telephone: Phone
'       Code: Zip Code
'       State: State
'       City: City
'       nColumns: 5
'       AppTitle: Store Locations
'       Logo: System.Drawing.Bitmap

예제에서는 호출을 CreateResXFile 메서드를 필요한 XML 리소스 파일을 만듭니다. 이 예제에서는 실행 되는 디렉터리에 Logo.bmp 라는 비트맵 파일이 필요 합니다.

설명

중요

신뢰할 수 없는 데이터로 이 클래스에서 메서드를 호출하는 것은 보안상 위험합니다. 신뢰할 수 있는 데이터로만 이 클래스에서 메서드를 호출하세요. 자세한 내용은 모든 입력 유효성 검사를 참조하세요.

합니다 ResXResourceSet 클래스에 대해 열거는 IResourceReader, 모든 이름 및 값을 로드 하 고 해시 테이블에 저장 합니다. 다음 리소스를 열거할 수 있습니다는 ResXResourceSet 개체 또는 개별 리소스 이름으로 검색 합니다.

ResXResourceSet 개체는 메모리에.resx 파일에 있는 모든 리소스를 읽을 수 있는 편리한 방법을 제공 합니다. 사용할 수는 GetObject .resx 파일을 읽은 경우 특정 리소스를 검색 하는 메서드를 ResXResourceSet 인스턴스.

상속자 참고

파생 클래스인 ResXResourceSet 자체 리소스 판독기를 사용 하 고 작성기를 재정의 해야 합니다 GetDefaultReader()GetDefaultWriter() 해석 하기 위한 적절 한 기능을 제공 하는 방법은 ResXResourceSet 인스턴스.

생성자

ResXResourceSet(Stream)

지정된 스트림에서 리소스를 읽는 시스템 기본 ResXResourceReader를 사용하여 ResXResourceSet 클래스의 새 인스턴스를 초기화합니다.

ResXResourceSet(String)

지정된 파일에서 리소스를 열고 읽는 시스템 기본값 ResXResourceReader 을 사용하여 클래스의 ResXResourceSet 새 instance 초기화합니다.

필드

Reader

리소스를 읽는 데 사용하는 IResourceReader를 나타냅니다.

(다음에서 상속됨 ResourceSet)
Table

리소스가 저장되는 Hashtable입니다.

(다음에서 상속됨 ResourceSet)

메서드

Close()

ResourceSet에서 사용하는 모든 리소스를 닫고 해제합니다.

(다음에서 상속됨 ResourceSet)
Dispose()

현재 ResourceSet 인스턴스에서 사용하는 리소스(메모리 제외)를 삭제합니다.

(다음에서 상속됨 ResourceSet)
Dispose(Boolean)

요청한 경우 관리되는 내부 개체를 닫고 현재 인스턴스와 관련된 리소스(메모리 제외)를 해제합니다.

(다음에서 상속됨 ResourceSet)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetDefaultReader()

이러한 종류의 ResXResourceSet에 대한 기본 설정 리소스 판독기를 반환합니다.

GetDefaultWriter()

이러한 종류의 ResXResourceSet에 대한 기본 설정 리소스 작성기 클래스를 반환합니다.

GetEnumerator()

IDictionaryEnumerator 전체에 걸쳐 반복할 수 있는 ResourceSet를 반환합니다.

(다음에서 상속됨 ResourceSet)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObject(String)

지정된 이름의 리소스 개체를 검색합니다.

(다음에서 상속됨 ResourceSet)
GetObject(String, Boolean)

요청한 경우 지정된 이름의 리소스 개체를 대/소문자를 구분하지 않고 검색합니다.

(다음에서 상속됨 ResourceSet)
GetString(String)

지정된 이름의 String 리소스를 검색합니다.

(다음에서 상속됨 ResourceSet)
GetString(String, Boolean)

요청한 경우 지정된 이름의 String 리소스를 대/소문자를 구분하지 않고 검색합니다.

(다음에서 상속됨 ResourceSet)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ReadResources()

모든 리소스를 읽은 다음 Hashtable 속성에 표시된 Table에 저장합니다.

(다음에서 상속됨 ResourceSet)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IEnumerable.GetEnumerator()

Dispose와의 경쟁 조건이 발생하지 않도록 IEnumerator 개체를 반환합니다. 이 멤버는 사용자 코드에서 직접 사용할 수 없습니다.

(다음에서 상속됨 ResourceSet)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보