ResXDataNode 클래스

정의

XML 리소스(.resx) 파일의 요소를 나타냅니다.

public ref class ResXDataNode sealed : System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class ResXDataNode : System.Runtime.Serialization.ISerializable
public sealed class ResXDataNode : System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type ResXDataNode = class
    interface ISerializable
type ResXDataNode = class
    interface ISerializable
Public NotInheritable Class ResXDataNode
Implements ISerializable
상속
ResXDataNode
특성
구현

예제

다음 예제에서는 메서드를 ResXResourceReader.GetEnumerator 사용 하 여 .resx 파일에서 개체를 열거 ResXDataNode 하는 데 사용 되는 개체를 가져옵니다IDictionaryEnumerator. 이 예제에는 필요한 XML 리소스 파일을 만드는 루틴이 포함되어 CreateResourceFile 있습니다.

using System;
using System.Collections;
using System.ComponentModel.Design;
using System.Resources;

public class Example
{
   private const string resxFilename = @".\CountryHeaders.resx";
    
   public static void Main()
   {
      // Create a resource file to read.
      CreateResourceFile();
      
      // Enumerate the resources in the file.
      ResXResourceReader rr = new ResXResourceReader(resxFilename);
      rr.UseResXDataNodes = true;
      IDictionaryEnumerator dict = rr.GetEnumerator();
      while (dict.MoveNext()) {
         ResXDataNode node = (ResXDataNode) dict.Value;
         Console.WriteLine("{0,-20} {1,-20} {2}", 
                           node.Name + ":", 
                           node.GetValue((ITypeResolutionService) null), 
                           ! String.IsNullOrEmpty(node.Comment) ? "// " + node.Comment : "");
      }
   }

   private static void CreateResourceFile()
   {
      ResXResourceWriter rw = new ResXResourceWriter(resxFilename);
      string[] resNames = {"Country", "Population", "Area", 
                           "Capital", "LCity" };
      string[] columnHeaders = { "Country Name", "Population (2010}", 
                                 "Area", "Capital", "Largest City" };
      string[] comments = { "The localized country name", "Estimated population, 2010", 
                            "The area in square miles", "Capital city or chief administrative center", 
                            "The largest city based on 2010 data" };
      rw.AddResource("Title", "Country Information");
      rw.AddResource("nColumns", resNames.Length);
      for (int ctr = 0; ctr < resNames.Length; ctr++) {
         ResXDataNode node = new ResXDataNode(resNames[ctr], columnHeaders[ctr]);
         node.Comment = comments[ctr];
         rw.AddResource(node);
      }
      rw.Generate();
      rw.Close();
   }
}
// The example displays the following output:
//    Title:               Country Information
//    nColumns:            5
//    Country:             Country Name         // The localized country name
//    Population:          Population (2010}    // Estimated population, 2010
//    Area:                Area                 // The area in square miles
//    Capital:             Capital              // Capital city or chief administrative center
//    LCity:               Largest City         // The largest city based on 2010 data
Imports System.Collections
Imports System.ComponentModel.Design
Imports System.Resources

Module Example
   Private Const resxFilename As String = ".\CountryHeaders.resx"
     
   Public Sub Main()
      ' Create a resource file to read.
      CreateResourceFile()
      
      ' Enumerate the resources in the file.
      Dim rr As New ResXResourceReader(resxFilename)
      rr.UseResXDataNodes = True
      Dim dict As IDictionaryEnumerator = rr.GetEnumerator()
      Do While dict.MoveNext()
         Dim node As ResXDataNode = DirectCast(dict.Value, ResXDataNode)
         Console.WriteLine("{0,-20} {1,-20} {2}", 
                           node.Name + ":", 
                           node.GetValue(CType(Nothing, ITypeResolutionService)), 
                           If(Not String.IsNullOrEmpty(node.Comment), "// " + node.Comment, ""))
      Loop
   End Sub
   
   Private Sub CreateResourceFile()
      Dim rw As New ResxResourceWriter(resxFilename)
      Dim resNames() As String = {"Country", "Population", "Area", 
                                  "Capital", "LCity" }
      Dim columnHeaders() As String = { "Country Name", "Population (2010}", 
                                        "Area", "Capital", "Largest City" }
      Dim comments() As String = { "The localized country name", "Estimated population, 2010", 
                                   "The area in square miles", "Capital city or chief administrative center", 
                                   "The largest city based on 2010 data" }
      rw.AddResource("Title", "Country Information")
      rw.AddResource("nColumns", resNames.Length)
      For ctr As Integer = 0 To resNames.Length - 1
         Dim node As New ResXDataNode(resNames(ctr), columnHeaders(ctr))
         node.Comment = comments(ctr)
         rw.AddResource(node)
      Next
      rw.Generate()
      rw.Close()
   End Sub
End Module
' The example displays the following output:
'    Title:               Country Information
'    nColumns:            5
'    Country:             Country Name         // The localized country name
'    Population:          Population (2010}    // Estimated population, 2010
'    Area:                Area                 // The area in square miles
'    Capital:             Capital              // Capital city or chief administrative center
'    LCity:               Largest City         // The largest city based on 2010 data

속성이 UseResXDataNodes 이므로 속성의 IDictionaryEnumerator.Value 값은 리소스 값이 아닌 개체 ResXDataNodetrue입니다. 이렇게 하면 속성에서 리소스 항목의 주석을 ResXDataNode.Comment 사용할 수 있습니다.

설명

중요

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

클래스는 ResXDataNode 리소스 파일 내에서 서식 있는 데이터 형식의 표현을 지원합니다. 개체가 serialization 및 형식 편집기를 지원하는 한 리소스 파일에 있는 개체의 스토리지를 지원할 수 있습니다.

오버로드된 ResXDataNode 클래스 생성자 중 하나를 호출하여 개체를 만들 수 있습니다. 그런 다음, 메서드를 호출 ResXResourceWriter.AddResource 하여 리소스 항목 또는 요소를 리소스 파일에 추가할 수 있습니다.

기존 ResXDataNode 개체를 검색하려면 개체를 인스턴스 ResXResourceReaderResXDataNode 하고 속성을 로 설정하고 메서드를 호출 ResXResourceReader.GetEnumerator 하여 XML 리소스 파일의 ResXResourceReader.UseResXDataNodestrue개체를 열거하여 열거해야 합니다. 예제에서는 그림을 제공합니다.

생성자

ResXDataNode(String, Object)

ResXDataNode 클래스의 새 인스턴스를 초기화합니다.

ResXDataNode(String, Object, Func<Type,String>)

ResXDataNode 클래스의 새 인스턴스를 초기화합니다.

ResXDataNode(String, ResXFileRef)

리소스 파일에 대한 참조를 사용하여 ResXDataNode 클래스의 새 인스턴스를 초기화합니다.

ResXDataNode(String, ResXFileRef, Func<Type,String>)

리소스 파일에 대한 참조를 사용하여 ResXDataNode 클래스의 새 인스턴스를 초기화합니다.

속성

Comment

이 리소스와 관련된 임의의 설명을 가져오거나 설정합니다.

FileRef

이 리소스에 대한 파일 참조를 가져옵니다.

Name

이 리소스의 이름을 가져오거나 설정합니다.

메서드

Equals(Object)

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

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

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

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

리소스 파일에서의 리소스 위치를 검색합니다.

GetType()

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

(다음에서 상속됨 Object)
GetValue(AssemblyName[])

지정된 어셈블리를 검색함으로서 이 노드에 의해 저장된 개체를 검색합니다.

GetValue(ITypeResolutionService)

지정된 유형 해결 서비스를 사용하여 이 노드로 저장된 개체를 검색합니다.

GetValueTypeName(AssemblyName[])

지정된 어셈블리를 검색하여 값에 대한 type name을 검색합니다.

GetValueTypeName(ITypeResolutionService)

지정된 유형 해결 서비스를 사용하여 값에 대한 유형명을 검색합니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

대상 개체를 직렬화하는 데 필요한 데이터로 SerializationInfo 개체를 채웁니다.

적용 대상

추가 정보