TypeExtensionsRegisterTypeConverterTConverter Method
Registers a type converter for a type.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
public static void RegisterTypeConverter<TConverter>(
this Type type
)
where TConverter : TypeConverter
<ExtensionAttribute>
Public Shared Sub RegisterTypeConverter(Of TConverter As TypeConverter) (
type As Type
)
public:
[ExtensionAttribute]
generic<typename TConverter>
where TConverter : TypeConverter
static void RegisterTypeConverter(
Type^ type
)
[<ExtensionAttribute>]
static member RegisterTypeConverter :
type : Type -> unit when 'TConverter : TypeConverter
- type Type
- The Type to be associated with the new TConverter.
- TConverter
- The TypeConverter to be registered.
In Visual Basic and C#, you can call this method as an instance method on any object of type
Type. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
After calling this method the TypeDescriptor.GetConverter
method will return the converter defined in TConverter.
To remove the registered converter and restore the previous one call
the UnregisterTypeConverter method.
If you want to permanently set a custom converter for a type, then it is recommended to register it at the start of your application
or service. It is also possible to register a converter temporarily, and then restore the previous converter by calling
the
UnregisterTypeConverter method but then you must make sure there is no
running concurrent operation on a different thread that expects to use an other converter for the same type.