SerializerWriter 构造函数

定义

初始化 SerializerWriter 类的新实例。

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

示例

以下示例演示如何使用 SerializerProvider方法CreateSerializerWriter创建 SerializerWriter

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

注解

SerializerWriter应使用 CreateSerializerWriter 对象的 方法(而不是 CreateSerializerWriter 对象的 方法SerializerProviderISerializerFactory)创建 的实例。

适用于