Skip to content

Class RootValueConverterFactory

Definition

Namespace: StardewUI.Framework.Converters
Assembly: StardewUI.dll

Standard implementation of IValueConverterFactory that allows registering new converters.

public class RootValueConverterFactory : 
    StardewUI.Framework.Converters.IValueConverterFactory

Inheritance
Object ⇦ RootValueConverterFactory

Implements
IValueConverterFactory

Members

Constructors

Name Description
RootValueConverterFactory() Initializes a new RootValueConverterFactory instance.

Methods

Name Description
Default() Creates a RootValueConverterFactory with the default set of built-in framework converters already registered.
Register(IValueConverterFactory) Registers a delegate factory that may be used to obtain a converter for which there is no explicit registration.
TryGetConverter(Type, Type, IValueConverter) Attempts to obtain a converter from a given source type to a given destination type.
TryGetConverter<TSource, TDestination>(IValueConverter<TSource, TDestination>) Attempts to obtain a converter from a given source type to a given destination type.
TryRegister<TSource, TDestination>(IValueConverter<TSource, TDestination>) Attempts to register a new converter.
TryRegister<TSource, TDestination>(Func<TSource, TDestination>) Attempts to register a new converter.

Details

Constructors

RootValueConverterFactory()

Initializes a new RootValueConverterFactory instance.

public RootValueConverterFactory();

Methods

Default()

Creates a RootValueConverterFactory with the default set of built-in framework converters already registered.

public static StardewUI.Framework.Converters.RootValueConverterFactory Default();
Returns

RootValueConverterFactory


Register(IValueConverterFactory)

Registers a delegate factory that may be used to obtain a converter for which there is no explicit registration.

public void Register(StardewUI.Framework.Converters.IValueConverterFactory factory);
Parameters

factory   IValueConverterFactory
The delegate factory.

Remarks

Use when a single converter may handle many input or output types, e.g. string-to-enum conversions.


TryGetConverter(Type, Type, IValueConverter)

Attempts to obtain a converter from a given source type to a given destination type.

public bool TryGetConverter(System.Type sourceType, System.Type destinationType, out StardewUI.Framework.Converters.IValueConverter converter);
Parameters

sourceType   Type
The type of value to be converted.

destinationType   Type
The converted value type.

converter   IValueConverter
If the method returns true, holds the converter that converts between the specified types; otherwise null.

Returns

Boolean

true if the conversion is supported, otherwise false.


TryGetConverter<TSource, TDestination>(IValueConverter<TSource, TDestination>)

Attempts to obtain a converter from a given source type to a given destination type.

public bool TryGetConverter<TSource, TDestination>(out IValueConverter<TSource, TDestination> converter);
Parameters

converter   IValueConverter<TSource, TDestination>
If the method returns true, holds the converter that converts between the specified types; otherwise null.

Returns

Boolean

true if the conversion is supported, otherwise false.


TryRegister<TSource, TDestination>(IValueConverter<TSource, TDestination>)

Attempts to register a new converter.

public bool TryRegister<TSource, TDestination>(StardewUI.Framework.Converters.IValueConverter<TSource, TDestination> converter);
Parameters

converter   IValueConverter<TSource, TDestination>
The converter that handles this conversion.

Returns

Boolean

true if the converter was registered for the specified types; false if there was already a registration or cached converter for those types.


TryRegister<TSource, TDestination>(Func<TSource, TDestination>)

Attempts to register a new converter.

public bool TryRegister<TSource, TDestination>(Func<TSource, TDestination> convert);
Parameters

convert   Func<TSource, TDestination>
Function to convert from TSource to TDestination.

Returns

Boolean

true if the conversion function was registered for the specified types; false if there was already a registration or cached converter for those types.