Edytuj

Udostępnij za pośrednictwem


SerializerWriter Class

Definition

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

public ref class SerializerWriter abstract
public abstract class SerializerWriter
type SerializerWriter = class
Public MustInherit Class SerializerWriter
Inheritance
SerializerWriter
Derived

Examples

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

Constructors

SerializerWriter()

Initializes a new instance of the SerializerWriter class.

Methods

CancelAsync()

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

CreateVisualsCollator()

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

CreateVisualsCollator(PrintTicket, PrintTicket)

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

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
Write(DocumentPaginator)

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

Write(DocumentPaginator, PrintTicket)

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

Write(FixedDocument)

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

Write(FixedDocument, PrintTicket)

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

Write(FixedDocumentSequence)

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

Write(FixedDocumentSequence, PrintTicket)

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

Write(FixedPage)

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

Write(FixedPage, PrintTicket)

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

Write(Visual)

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

Write(Visual, PrintTicket)

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

WriteAsync(DocumentPaginator)

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

WriteAsync(DocumentPaginator, Object)

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

WriteAsync(DocumentPaginator, PrintTicket)

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

WriteAsync(DocumentPaginator, PrintTicket, Object)

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

WriteAsync(FixedDocument)

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

WriteAsync(FixedDocument, Object)

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

WriteAsync(FixedDocument, PrintTicket)

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

WriteAsync(FixedDocument, PrintTicket, Object)

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

WriteAsync(FixedDocumentSequence)

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

WriteAsync(FixedDocumentSequence, Object)

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

WriteAsync(FixedDocumentSequence, PrintTicket)

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

WriteAsync(FixedDocumentSequence, PrintTicket, Object)

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

WriteAsync(FixedPage)

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

WriteAsync(FixedPage, Object)

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

WriteAsync(FixedPage, PrintTicket)

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

WriteAsync(FixedPage, PrintTicket, Object)

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

WriteAsync(Visual)

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

WriteAsync(Visual, Object)

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

WriteAsync(Visual, PrintTicket)

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

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

Events

WritingCancelled

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

WritingCompleted

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

WritingPrintTicketRequired

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

WritingProgressChanged

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

Applies to

See also