ValueSerializer ValueSerializer ValueSerializer ValueSerializer Class

Definition

Abstract class that defines conversion behavior for serialization from an object representation.

public ref class ValueSerializer abstract
public abstract class ValueSerializer
type ValueSerializer = class
Public MustInherit Class ValueSerializer
Inheritance
ValueSerializerValueSerializerValueSerializerValueSerializer
Derived

Remarks

The string a converter returns for serialization must be loss-less and the converter must always return the same string for a particular value. If a type converter (derived from TypeConverter) does not meet these requirements in its ConvertTo implementations for string output, a custom ValueSerializer must be declared. Either the ValueSerializer should meet the requirements, or a null ValueSerializer should be associated with the type. A ValueSerializer is associated with a type by applying the ValueSerializerAttribute attribute.

A null ValueSerializer indicates the type converter should be ignored for convert-to-string conversions from the object graph.

Important

Implementation of ValueSerializer should avoid throwing exceptions. Any exceptions thrown could terminate serialization.

IValueSerializerContext for a ValueSerializer and its APIs is analogous to ITypeDescriptorContext for a TypeConverter. In fact, IValueSerializerContext inherits ITypeDescriptorContext. When a ValueSerializer derived class API is called, the caller (typically a serializer process) passes a context that may provide certain services. Because of the general guidance that a ValueSerializer must not throw exceptions. Failure to return a particular service from the context must also not throw any exceptions.

In previous versions of the .NET Framework, this class existed in the WPF-specific assembly WindowsBase. In .NET Framework 4, ValueSerializer is in the System.Xaml assembly. For more information, see Types Migrated from WPF to System.Xaml.

Constructors

ValueSerializer() ValueSerializer() ValueSerializer() ValueSerializer()

Initializes a new instance of the ValueSerializer class.

Methods

CanConvertFromString(String, IValueSerializerContext) CanConvertFromString(String, IValueSerializerContext) CanConvertFromString(String, IValueSerializerContext) CanConvertFromString(String, IValueSerializerContext)

When overridden in a derived class, determines whether the specified String can be converted to an instance of the type that the implementation of ValueSerializer supports.

CanConvertToString(Object, IValueSerializerContext) CanConvertToString(Object, IValueSerializerContext) CanConvertToString(Object, IValueSerializerContext) CanConvertToString(Object, IValueSerializerContext)

When overridden in a derived class, determines whether the specified object can be converted into a String.

ConvertFromString(String, IValueSerializerContext) ConvertFromString(String, IValueSerializerContext) ConvertFromString(String, IValueSerializerContext) ConvertFromString(String, IValueSerializerContext)

When overridden in a derived class, converts a String to an instance of the type that the implementation of ValueSerializer supports.

ConvertToString(Object, IValueSerializerContext) ConvertToString(Object, IValueSerializerContext) ConvertToString(Object, IValueSerializerContext) ConvertToString(Object, IValueSerializerContext)

When overridden in a derived class, converts the specified object to a String.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetConvertFromException(Object) GetConvertFromException(Object) GetConvertFromException(Object) GetConvertFromException(Object)

Returns an exception to throw when a conversion cannot be performed.

GetConvertToException(Object, Type) GetConvertToException(Object, Type) GetConvertToException(Object, Type) GetConvertToException(Object, Type)

Returns an exception to throw when a conversion cannot be performed.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetSerializerFor(PropertyDescriptor) GetSerializerFor(PropertyDescriptor) GetSerializerFor(PropertyDescriptor) GetSerializerFor(PropertyDescriptor)

Gets the ValueSerializer declared for a property, by passing a CLR property descriptor for the property.

GetSerializerFor(PropertyDescriptor, IValueSerializerContext) GetSerializerFor(PropertyDescriptor, IValueSerializerContext) GetSerializerFor(PropertyDescriptor, IValueSerializerContext) GetSerializerFor(PropertyDescriptor, IValueSerializerContext)

Gets the ValueSerializer declared for the specified property, using the specified context.

GetSerializerFor(Type) GetSerializerFor(Type) GetSerializerFor(Type) GetSerializerFor(Type)

Gets the ValueSerializer declared for the specified type.

GetSerializerFor(Type, IValueSerializerContext) GetSerializerFor(Type, IValueSerializerContext) GetSerializerFor(Type, IValueSerializerContext) GetSerializerFor(Type, IValueSerializerContext)

Gets the ValueSerializer declared for the specified type, using the specified context.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TypeReferences(Object, IValueSerializerContext) TypeReferences(Object, IValueSerializerContext) TypeReferences(Object, IValueSerializerContext) TypeReferences(Object, IValueSerializerContext)

Gets an enumeration of the types referenced by the ValueSerializer.

Applies to

See also