SerializerWriter Class

SerializerWriter Class

 

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

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

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

public abstract class SerializerWriter

NameDescription
System_CAPS_protmethodSerializerWriter()

Initializes a new instance of the SerializerWriter class.

NameDescription
System_CAPS_pubmethodCancelAsync()

When overridden in a derived class, cancels an asynchronous write operation.

System_CAPS_pubmethodCreateVisualsCollator()

When overridden in a derived class, returns a SerializerWriterCollator that writes collated Visual elements.

System_CAPS_pubmethodCreateVisualsCollator(PrintTicket, PrintTicket)

When overridden in a derived class, returns a SerializerWriterCollator that writes collated Visual elements together with the given print tickets.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWrite(DocumentPaginator)

When overridden in a derived class, synchronously writes the content of a given DocumentPaginator to the serialization Stream.

System_CAPS_pubmethodWrite(DocumentPaginator, PrintTicket)

When overridden in a derived class, synchronously writes paginated content together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWrite(FixedDocument)

When overridden in a derived class, synchronously writes a given FixedDocument to the serialization Stream.

System_CAPS_pubmethodWrite(FixedDocument, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWrite(FixedDocumentSequence)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence to the serialization Stream.

System_CAPS_pubmethodWrite(FixedDocumentSequence, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWrite(FixedPage)

When overridden in a derived class, synchronously writes a given FixedPage to the serialization Stream.

System_CAPS_pubmethodWrite(FixedPage, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWrite(Visual)

When overridden in a derived class, synchronously writes a given Visual element to the serialization Stream.

System_CAPS_pubmethodWrite(Visual, PrintTicket)

When overridden in a derived class, synchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(DocumentPaginator)

When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.

System_CAPS_pubmethodWriteAsync(DocumentPaginator, Object)

When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.

System_CAPS_pubmethodWriteAsync(DocumentPaginator, PrintTicket)

When overridden in a derived class, asynchronously writes the content of a given DocumentPaginator to the serialization Stream.

System_CAPS_pubmethodWriteAsync(DocumentPaginator, PrintTicket, Object)

When overridden in a derived class, asynchronously writes paginated content together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocument)

When overridden in a derived class, asynchronously writes a given FixedDocument to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocument, Object)

When overridden in a derived class, asynchronously writes a given FixedDocument to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocument, PrintTicket)

When overridden in a derived class, asynchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocument, PrintTicket, Object)

When overridden in a derived class, asynchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocumentSequence)

When overridden in a derived class, asynchronously writes a given FixedDocumentSequence to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocumentSequence, Object)

When overridden in a derived class, asynchronously writes a given FixedDocumentSequence to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocumentSequence, PrintTicket)

When overridden in a derived class, asynchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedDocumentSequence, PrintTicket, Object)

When overridden in a derived class, asynchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedPage)

When overridden in a derived class, asynchronously writes a given FixedPage to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedPage, Object)

When overridden in a derived class, asynchronously writes a given FixedPage to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedPage, PrintTicket)

When overridden in a derived class, asynchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(FixedPage, PrintTicket, Object)

When overridden in a derived class, asynchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(Visual)

When overridden in a derived class, asynchronously writes a given Visual element to the serialization Stream.

System_CAPS_pubmethodWriteAsync(Visual, Object)

When overridden in a derived class, asynchronously writes a given Visual element to the serialization Stream.

System_CAPS_pubmethodWriteAsync(Visual, PrintTicket)

When overridden in a derived class, asynchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.

System_CAPS_pubmethodWriteAsync(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.

NameDescription
System_CAPS_pubeventWritingCancelled

When overridden in a derived class, occurs when a CancelAsync operation is performed.

System_CAPS_pubeventWritingCompleted

When overridden in a derived class, occurs when a write operation finishes.

System_CAPS_pubeventWritingPrintTicketRequired

When overridden in a derived class, occurs just before a PrintTicket is added to a stream by a Write or WriteAsync method.

System_CAPS_pubeventWritingProgressChanged

When overridden in a derived class, occurs when the SerializerWriter updates its progress.

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
Available since 3.0

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

Return to top
Show:
© 2016 Microsoft