Partilhar via


SerializerWriter Construtor

Definição

Inicializa uma nova instância da classe SerializerWriter.

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

Exemplos

O exemplo a seguir mostra como criar um SerializerWriter usando o SerializerProvider.CreateSerializerWriter método.

// 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;
}

Comentários

Instâncias de SerializerWriter devem ser criadas usando o CreateSerializerWriter método de um SerializerProvider objeto, não o CreateSerializerWriter método de um ISerializerFactory objeto.

Aplica-se a