Export (0) Print
Expand All

SerializerWriter Class

Defines the abstract methods and events that are required to implement a plug-in document output serializer.

System.Object
  System.Windows.Documents.Serialization.SerializerWriter
    System.Windows.Xps.XpsDocumentWriter

Namespace:  System.Windows.Documents.Serialization
Assembly:  PresentationFramework (in PresentationFramework.dll)

public abstract class SerializerWriter

The SerializerWriter type exposes the following members.

  NameDescription
Protected methodSerializerWriterInitializes a new instance of the SerializerWriter class.
Top

  NameDescription
Public methodCancelAsyncWhen overridden in a derived class, cancels an asynchronous write operation.
Public methodCreateVisualsCollator()When overridden in a derived class, returns a SerializerWriterCollator that writes collated Visual elements.
Public methodCreateVisualsCollator(PrintTicket, PrintTicket)When overridden in a derived class, returns a SerializerWriterCollator that writes collated Visual elements together with the given print tickets.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWrite(DocumentPaginator)When overridden in a derived class, synchronously writes the content of a given DocumentPaginator to the serialization Stream.
Public methodWrite(FixedDocument)When overridden in a derived class, synchronously writes a given FixedDocument to the serialization Stream.
Public methodWrite(FixedDocumentSequence)When overridden in a derived class, synchronously writes a given FixedDocumentSequence to the serialization Stream.
Public methodWrite(FixedPage)When overridden in a derived class, synchronously writes a given FixedPage to the serialization Stream.
Public methodWrite(Visual)When overridden in a derived class, synchronously writes a given Visual element to the serialization Stream.
Public methodWrite(DocumentPaginator, PrintTicket)When overridden in a derived class, synchronously writes paginated content together with an associated PrintTicket to the serialization Stream.
Public methodWrite(FixedDocument, PrintTicket)When overridden in a derived class, synchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.
Public methodWrite(FixedDocumentSequence, PrintTicket)When overridden in a derived class, synchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.
Public methodWrite(FixedPage, PrintTicket)When overridden in a derived class, synchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.
Public methodWrite(Visual, PrintTicket)When overridden in a derived class, synchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(DocumentPaginator)When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.
Public methodWriteAsync(FixedDocument)When overridden in a derived class, asynchronously writes a given FixedDocument to the serialization Stream.
Public methodWriteAsync(FixedDocumentSequence)When overridden in a derived class, asynchronously writes a given FixedDocumentSequence to the serialization Stream.
Public methodWriteAsync(FixedPage)When overridden in a derived class, asynchronously writes a given FixedPage to the serialization Stream.
Public methodWriteAsync(Visual)When overridden in a derived class, asynchronously writes a given Visual element to the serialization Stream.
Public methodWriteAsync(DocumentPaginator, Object)When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.
Public methodWriteAsync(DocumentPaginator, PrintTicket)When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.
Public methodWriteAsync(FixedDocument, Object)When overridden in a derived class, asynchronously writes a given FixedDocument to the serialization Stream.
Public methodWriteAsync(FixedDocument, PrintTicket)When overridden in a derived class, asynchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(FixedDocumentSequence, Object)When overridden in a derived class, asynchronously writes a given FixedDocumentSequence to the serialization Stream.
Public methodWriteAsync(FixedDocumentSequence, PrintTicket)When overridden in a derived class, asynchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(FixedPage, Object)When overridden in a derived class, asynchronously writes a given FixedPage to the serialization Stream.
Public methodWriteAsync(FixedPage, PrintTicket)When overridden in a derived class, asynchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(Visual, Object)When overridden in a derived class, asynchronously writes a given Visual element to the serialization Stream.
Public methodWriteAsync(Visual, PrintTicket)When overridden in a derived class, asynchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(DocumentPaginator, PrintTicket, Object)When overridden in a derived class, asynchronously writes paginated content together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(FixedDocument, PrintTicket, Object)When overridden in a derived class, asynchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(FixedDocumentSequence, PrintTicket, Object)When overridden in a derived class, asynchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(FixedPage, PrintTicket, Object)When overridden in a derived class, asynchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.
Public methodWriteAsync(Visual, PrintTicket, Object)When overridden in a derived class, asynchronously writes a given Visual element together with an associated PrintTicket and identifier to the serialization Stream.
Top

  NameDescription
Public eventWritingCancelledWhen overridden in a derived class, occurs when a CancelAsync operation is performed.
Public eventWritingCompletedWhen overridden in a derived class, occurs when a write operation finishes.
Public eventWritingPrintTicketRequiredWhen overridden in a derived class, occurs just before a PrintTicket is added to a stream by a Write or WriteAsync method.
Public eventWritingProgressChangedWhen overridden in a derived class, occurs when the SerializerWriter updates its progress.
Top

The following example illustrates the use of 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;
}
// ------------------------ PlugInFileFilter -------------------------- 
/// <summary> 
///   Gets a filter string for installed plug-in serializers.</summary> 
/// <remark> 
///   PlugInFileFilter is used to set the SaveFileDialog or 
///   OpenFileDialog "Filter" property when saving or opening files
///   using plug-in serializers.</remark> 
private string PlugInFileFilter
{
    get
    {   // Create a SerializerProvider for accessing plug-in serializers.
        SerializerProvider serializerProvider = new SerializerProvider();
        string filter = "";

        // For each loadable serializer, add its display 
        // name and extension to the filter string. 
        foreach (SerializerDescriptor serializerDescriptor in
            serializerProvider.InstalledSerializers)
        {
            if (serializerDescriptor.IsLoadable)
            {
                // After the first, separate entries with a "|".
                if (filter.Length > 0)   filter += "|";

                // Add an entry with the plug-in name and extension.
                filter += serializerDescriptor.DisplayName + " (*" +
                    serializerDescriptor.DefaultFileExtension + ")|*" +
                    serializerDescriptor.DefaultFileExtension;
            }
        }

        // Return the filter string of installed plug-in serializers. 
        return filter;
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft