Export (0) Print
Expand All

MessageEncoderFactory Class

An abstract base class that represents the factory for producing message encoders that can read messages from a stream and write them to a stream for various types of message encoding.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public abstract class MessageEncoderFactory

Encoding is the process of transforming a message into a sequence of bytes. Decoding is the reverse process.

Use this class if you want to implement a custom message encoder. To implement your own custom message encoder, you must provide custom implementations of the following three abstract base classes:

Override the Encoder to return an instance of your custom MessageEncoder. Then wire up your custom MessageEncoderFactory to the binding element stack used to configure the service or client by overriding the CreateMessageEncoderFactory method to return an instance of this factory. For more information about custom encoders, see Custom Encoders.

The following code shows how to write a class that is derived from MessageEncoderFactory:

public override bool IsContentTypeSupported(string contentType) 
{ 
    if (base.IsContentTypeSupported(contentType)) 
    { 
        return true; 
    } 
    if (contentType.Length == this.MediaType.Length) 
    { 
        return contentType.Equals(this.MediaType, StringComparison.OrdinalIgnoreCase); 
    } 
    else 
    { 
        if (contentType.StartsWith(this.MediaType, StringComparison.OrdinalIgnoreCase) 
            && (contentType[this.MediaType.Length] == ';')) 
        { 
            return true; 
        } 
    } 
    return false; 
}

System.Object
  System.ServiceModel.Channels.MessageEncoderFactory

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

Supported in: 3.5, 3.0

.NET Compact Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2014 Microsoft