Modifica

Condividi tramite


SerializerDescriptor Class

Definition

Provides information about installed plug-in serializers.

public ref class SerializerDescriptor sealed
public sealed class SerializerDescriptor
type SerializerDescriptor = class
Public NotInheritable Class SerializerDescriptor
Inheritance
SerializerDescriptor

Examples

The following examples illustrate using a SerializerDescriptor to return information on installed plug-in serializers.

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

Remarks

Plug-in serializer classes derive from and implement the ISerializerFactory interface.

Properties

AssemblyName

Gets the name of the assembly that contains the serializer.

AssemblyPath

Gets the path to the assembly file that contains the serializer.

AssemblyVersion

Gets the version of the assembly that contains the serializer.

DefaultFileExtension

Gets the default extension associated with files that the serializer outputs.

DisplayName

Gets the public display name of the serializer.

FactoryInterfaceName

Gets the name of the ISerializerFactory derived class that implements the serializer.

IsLoadable

Gets a value indicating whether the serializer can be loaded with the currently installed version of .NET.

ManufacturerName

Gets the name of the company that developed the serializer.

ManufacturerWebsite

Gets the web address of the company that developed the serializer.

WinFXVersion

Gets the version of .NET required by the serializer.

Methods

CreateFromFactoryInstance(ISerializerFactory)

Creates a new SerializerDescriptor through a given ISerializerFactory implementation.

Equals(Object)

Tests two SerializerDescriptor objects for equality.

GetHashCode()

Gets the unique hash code value of the serializer.

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)

Applies to