共用方式為


SerializerWriter 建構函式

定義

初始化 SerializerWriter 類別的新執行個體。

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

範例

下列範例示範如何使用 方法來建立 SerializerWriterSerializerProviderCreateSerializerWriter

// 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 物件的 方法 SerializerProvider 建立,而不是 CreateSerializerWriter 物件的 方法 ISerializerFactory

適用於