NetDataContractSerializer 생성자

정의

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

오버로드

Name Description
NetDataContractSerializer()

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

NetDataContractSerializer(StreamingContext)

제공된 스트리밍 컨텍스트 데이터를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다.

NetDataContractSerializer(String, String)

제공된 XML 루트 요소 및 네임스페이 NetDataContractSerializer 스를 사용하여 클래스의 새 인스턴스를 초기화합니다.

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString)

콘텐츠를 지정하는 데 사용되는 루트 요소와 네임스페이스를 포함하는 형식 NetDataContractSerializer 의 두 매개 변수를 사용하여 클래스의 새 인스턴스 XmlDictionaryString 를 초기화합니다.

NetDataContractSerializer(StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

NetDataContractSerializer(String, String, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터와 루트 이름 및 네임스페이스를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터와 루트 이름 및 네임스페이스(매개 변수)NetDataContractSerializer를 사용하여 클래스의 XmlDictionaryString 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 발견된 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

NetDataContractSerializer()

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

public:
 NetDataContractSerializer();
public NetDataContractSerializer();
Public Sub New ()

예제

public static void Constructor1()
{
    // Create an instance of the NetDataContractSerializer.
    NetDataContractSerializer ser =
        new NetDataContractSerializer();
    // Other code not shown.
}
Public Shared Sub Constructor1() 
    ' Create an instance of the NetDataContractSerializer.
    Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()

End Sub 

' Other code not shown.

적용 대상

NetDataContractSerializer(StreamingContext)

제공된 스트리밍 컨텍스트 데이터를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다.

public:
 NetDataContractSerializer(System::Runtime::Serialization::StreamingContext context);
public NetDataContractSerializer(System.Runtime.Serialization.StreamingContext context);
new System.Runtime.Serialization.NetDataContractSerializer : System.Runtime.Serialization.StreamingContext -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (context As StreamingContext)

매개 변수

context
StreamingContext

컨텍스트 데이터를 포함하는 A StreamingContext 입니다.

예제

다음 예제에서는 using의 인스턴스를 NetDataContractSerializerStreamingContext만듭니다.

public static void Constructor2()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);
    // Create a DatatContractSerializer with the collection.
    NetDataContractSerializer ser2 = new NetDataContractSerializer(sc);

    // Other code not shown.
}
Public Shared Sub Constructor2() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    ' Create a DatatContractSerializer with the collection.
    Dim ser2 As New System.Runtime.Serialization.NetDataContractSerializer(sc)

   ' Other code not shown.
End Sub

설명

클래스 StreamingContext 를 사용하면 개체를 읽고 쓰는 동안 사용할 사용자별 컨텍스트 데이터를 전달할 수 있습니다.

적용 대상

NetDataContractSerializer(String, String)

제공된 XML 루트 요소 및 네임스페이 NetDataContractSerializer 스를 사용하여 클래스의 새 인스턴스를 초기화합니다.

public:
 NetDataContractSerializer(System::String ^ rootName, System::String ^ rootNamespace);
public NetDataContractSerializer(string rootName, string rootNamespace);
new System.Runtime.Serialization.NetDataContractSerializer : string * string -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As String, rootNamespace As String)

매개 변수

rootName
String

직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 이름입니다.

rootNamespace
String

직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 네임스페이스입니다.

예제

다음 예제에서는 개체를 역직렬화할 때 예상되는 XML 루트 요소 및 네임스페이스를 지정하는 인스턴스 DataContractSerializer 를 만듭니다.

public static void Constructor3()
{
    // Create an instance of the NetDataContractSerializer
    // specifying the name and namespace as strings.
    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        "Customer",
        "http://www.contoso.com");
    // Other code not shown.
}
Public Shared Sub Constructor3() 
    ' Create an instance of the NetDataContractSerializer
    ' specifying the name and namespace as strings.
    Dim ser As New System.Runtime.Serialization. _
       NetDataContractSerializer("Customer", "http://www.contoso.com")

   ' Other code not shown.

End Sub

적용 대상

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString)

콘텐츠를 지정하는 데 사용되는 루트 요소와 네임스페이스를 포함하는 형식 NetDataContractSerializer 의 두 매개 변수를 사용하여 클래스의 새 인스턴스 XmlDictionaryString 를 초기화합니다.

public:
 NetDataContractSerializer(System::Xml::XmlDictionaryString ^ rootName, System::Xml::XmlDictionaryString ^ rootNamespace);
public NetDataContractSerializer(System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace);
new System.Runtime.Serialization.NetDataContractSerializer : System.Xml.XmlDictionaryString * System.Xml.XmlDictionaryString -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As XmlDictionaryString, rootNamespace As XmlDictionaryString)

매개 변수

rootName
XmlDictionaryString

XmlDictionaryString 직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 이름을 포함하는 형식입니다.

rootNamespace
XmlDictionaryString

XmlDictionaryString 직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 네임스페이스를 포함하는 형식입니다.

예제

다음 예제에서는 개체를 역직렬화할 때 예상되는 XML 루트 요소와 네임스페이스를 인수로 DataContractSerializer 지정하는 인스턴스 XmlDictionaryString 를 만듭니다.

public static void Constructor4()
{
    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    // Initialize the out variables.
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // Create the serializer.
    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        name_value,
        ns_value);
    // Other code not shown.
}
 Public Shared Sub Constructor4() 
     ' Create an XmlDictionary and add values to it.
     Dim d As New XmlDictionary()
     Dim name_value As XmlDictionaryString =d.Add("Customer")
     Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
     
     ' Create the serializer.
     Dim ser As New System.Runtime.Serialization. _
        NetDataContractSerializer(name_value, ns_value)

     ' Other code not shown.
 
 End Sub

설명

XmlDictionaryString 개체 인스턴스에서 동일한 문자열 집합을 사용하는 경우 성능을 최적화하는 데 사용할 수 있습니다.

적용 대상

NetDataContractSerializer(StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

public:
 NetDataContractSerializer(System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer(System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

매개 변수

context
StreamingContext

컨텍스트 데이터를 포함하는 A StreamingContext 입니다.

maxItemsInObjectGraph
Int32

직렬화 또는 역직렬화할 그래프의 최대 항목 수입니다.

ignoreExtensionDataObject
Boolean

true형식의 확장에서 제공하는 데이터를 무시하려면 입니다. 그렇지 않으면 . false

assemblyFormat
FormatterAssemblyStyle

FormatterAssemblyStyle 어셈블리를 찾고 로드하는 메서드를 지정하는 열거형 값입니다.

surrogateSelector
ISurrogateSelector

의 구현입니다 ISurrogateSelector.

예외

maxItemsInObjectGraph 값이 0보다 작습니다.

예제

다음 예제에서는 using의 인스턴스를 NetDataContractSerializerStreamingContext만듭니다. 또한 코드는 서로게이트를 ignoreExtensionDataObject선택할 때 직렬 변환기를 지원하기 위해 처리할 인터페이스의 ISurrogateSelector 구현을 설정하고 지정합니다(레거시 형식 역직렬화용).

public static void Constructor5()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);

    // Create an instance of a class that implements the
    // ISurrogateSelector interface. The implementation code
    // is not shown here.
    MySelector mySurrogateSelector = new MySelector();

    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);

    // Other code not shown.
}
Public Shared Sub Constructor5() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
    NetDataContractSerializer _
    (sc, _
     65536, _
     True, _
     FormatterAssemblyStyle.Simple, _
     mySurrogateSelector)

    ' Other code not shown.
End Sub

설명

ignoreExtensionDataObject 이 매개 변수는 직렬화되거나 역직렬화되는 클래스에서 인터페이스가 구현될 때 IExtensibleDataObject 사용됩니다.

적용 대상

NetDataContractSerializer(String, String, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터와 루트 이름 및 네임스페이스를 사용하여 클래스의 NetDataContractSerializer 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

public:
 NetDataContractSerializer(System::String ^ rootName, System::String ^ rootNamespace, System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer(string rootName, string rootNamespace, System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : string * string * System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As String, rootNamespace As String, context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

매개 변수

rootName
String

직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 이름입니다.

rootNamespace
String

직렬화 또는 역직렬화할 콘텐츠를 묶는 XML 요소의 네임스페이스입니다.

context
StreamingContext

컨텍스트 데이터를 포함하는 A StreamingContext 입니다.

maxItemsInObjectGraph
Int32

직렬화 또는 역직렬화할 그래프의 최대 항목 수입니다.

ignoreExtensionDataObject
Boolean

true형식의 확장에서 제공하는 데이터를 무시하려면 입니다. 그렇지 않으면 . false

assemblyFormat
FormatterAssemblyStyle

FormatterAssemblyStyle 어셈블리를 찾고 로드하는 메서드를 지정하는 열거형 값입니다.

surrogateSelector
ISurrogateSelector

레거시 형식을 IDataContractSurrogate 처리하는 구현입니다.

예외

maxItemsInObjectGraph 값이 0보다 작습니다.

예제

다음 예제에서는 역직렬화할 때 예상되는 XML 요소 이름 및 네임스페이스를 지정하는 인스턴스 NetDataContractSerializer 를 만듭니다. 또한 코드는 서로게이트를 ignoreExtensionDataObject선택할 때 직렬 변환기를 지원하기 위해 처리할 인터페이스의 ISurrogateSelector 구현을 설정하고 지정합니다(레거시 형식 역직렬화용).

public static void Constructor6()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);

    // Create an instance of a class that implements the
    // ISurrogateSelector interface. The implementation code
    // is not shown here.
    MySelector mySurrogateSelector = new MySelector();

    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        "Customer",
        "http://www.contoso.com",
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);
    // Other code not shown.
}
Public Shared Sub Constructor6() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
      NetDataContractSerializer( _
      "Customer", _
      "http://www.contoso.com", _
      sc, _
      65536, _
      True, _
      FormatterAssemblyStyle.Simple, _
      mySurrogateSelector)

    ' Other code not shown.            

End Sub

설명

ignoreExtensionDataObject 이 매개 변수는 직렬화되거나 역직렬화되는 클래스에서 인터페이스가 구현될 때 IExtensibleDataObject 사용됩니다.

적용 대상

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

제공된 컨텍스트 데이터와 루트 이름 및 네임스페이스(매개 변수)NetDataContractSerializer를 사용하여 클래스의 XmlDictionaryString 새 인스턴스를 초기화합니다. 또한 serialize할 개체의 최대 항목 수와 발견된 추가 데이터가 무시되는지 여부, 어셈블리 로드 메서드 및 서로게이트 선택기를 지정하는 매개 변수를 지정합니다.

public:
 NetDataContractSerializer(System::Xml::XmlDictionaryString ^ rootName, System::Xml::XmlDictionaryString ^ rootNamespace, System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer(System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : System.Xml.XmlDictionaryString * System.Xml.XmlDictionaryString * System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As XmlDictionaryString, rootNamespace As XmlDictionaryString, context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

매개 변수

rootName
XmlDictionaryString

XmlDictionaryString 콘텐츠의 루트 요소가 들어 있는 항목입니다.

rootNamespace
XmlDictionaryString

XmlDictionaryString 루트 요소의 네임스페이스를 포함하는 항목입니다.

context
StreamingContext

컨텍스트 데이터를 포함하는 A StreamingContext 입니다.

maxItemsInObjectGraph
Int32

직렬화 또는 역직렬화할 그래프의 최대 항목 수입니다.

ignoreExtensionDataObject
Boolean

true형식의 확장에서 제공하는 데이터를 무시하려면 입니다. 그렇지 않으면 . false

assemblyFormat
FormatterAssemblyStyle

FormatterAssemblyStyle 어셈블리를 찾고 로드하는 메서드를 지정하는 열거형 값입니다.

surrogateSelector
ISurrogateSelector

레거시 형식을 IDataContractSurrogate 처리하는 구현입니다.

예외

maxItemsInObjectGraph 값이 0보다 작습니다.

예제

다음 예제에서는 역직렬화할 때 예상되는 XML 요소 이름 및 네임스페이스(인수)NetDataContractSerializer를 지정하는 인스턴스 XmlDictionaryString 를 만듭니다. 또한 코드는 서로게이트를 ignoreExtensionDataObject선택할 때 직렬 변환기를 지원하기 위해 처리할 인터페이스의 ISurrogateSelector 구현을 설정하고 지정합니다(레거시 형식 역직렬화용).

public static void Constructor7()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);

    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // Create an instance of a class that implements the
    // ISurrogateSelector interface. The implementation code
    // is not shown here.
    MySelector mySurrogateSelector = new MySelector();

    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        name_value,
        ns_value,
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);

    // Other code not shown.
}
Public Shared Sub Constructor7() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an XmlDictionary and add values to it.
    Dim d As New XmlDictionary()
    Dim name_value As XmlDictionaryString =d.Add("Customer")
    Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
      NetDataContractSerializer( _
      name_value, _
      ns_value, _
      sc, _
      65536, _
      True, _
      FormatterAssemblyStyle.Simple, _
      mySurrogateSelector)

    ' Other code not shown.    

End Sub

설명

XmlDictionaryString 개체 인스턴스에서 동일한 문자열 집합을 사용하는 경우 성능을 최적화하는 데 사용할 수 있습니다.

ignoreExtensionDataObject 이 매개 변수는 직렬화되거나 역직렬화되는 클래스에서 인터페이스가 구현될 때 IExtensibleDataObject 사용됩니다.

적용 대상