ValueSerializer::GetSerializerFor Method (Type^, IValueSerializerContext^)
Gets the ValueSerializer declared for the specified type, using the specified context.
Assembly: System.Xaml (in System.Xaml.dll)
public: static ValueSerializer^ GetSerializerFor( Type^ type, IValueSerializerContext^ context )
Parameters
- type
-
Type:
System::Type^
The type to get the ValueSerializer for.
- context
-
Type:
System.Windows.Markup::IValueSerializerContext^
Context information that is used for conversion.
Return Value
Type: System.Windows.Markup::ValueSerializer^The serializer associated with the specified type.
| Exception | Condition |
|---|---|
| ArgumentNullException | type is null. |
Rather than relying purely on attributes reported in the CLR type system, this overload uses the context as a service, and calls the service's implementation of IValueSerializerContext::GetValueSerializerFor. The IValueSerializerContext::GetValueSerializerFor implementation would typically also rely on the type, but might implement special behavior for certain contexts.
This method should be called when the caller has an available IValueSerializerContext from a service. This will ensure that the correct ValueSerializer is returned for the specific context.
If the context returns null from its IValueSerializerContext::GetValueSerializerFor for your specified type, or if the context you specify is null, then behavior is identical to calling the GetSerializerFor(Type^) overload.
Available since 3.0