ValueSerializer::GetSerializerFor Method (Type^)

 

Gets the ValueSerializer declared for the specified type.

Namespace:   System.Windows.Markup
Assembly:  System.Xaml (in System.Xaml.dll)

public:
static ValueSerializer^ GetSerializerFor(
	Type^ type
)

Parameters

type
Type: System::Type^

The type to get the ValueSerializer for.

Return Value

Type: System.Windows.Markup::ValueSerializer^

The serializer associated with the specified type. May return null.

Exception Condition
ArgumentNullException

type is null.

A ValueSerializer for a type is indicated by applying the ValueSerializerAttribute attribute on the type declaration. The GetSerializerFor method is a utility method that reads the CLR type system information and returns a new ValueSerializer class based on the attribute if found on the specified type. null might be returned if no such serializer exists. null might also be returned if a type is deliberately attributed with a null-value ValueSerializerAttribute.

Another mode that GetSerializerFor supports is returning the internal TypeConverterValueSerializer class, which is a ValueSerializer implementation that wraps a TypeConverter and translates the Convert methods to Convert*String methods (for instance TypeConverter::ConvertTo is called with input of the String type, and translates to ConvertToString. This is done only in cases where all of the following are true:

System_CAPS_noteNote

The following are special cases: DateTime types return a DateTimeValueSerializer; String types return an internal but functional serializer (StringValueSerializer).

.NET Framework
Available since 3.0
Return to top
Show: