Class FieldOptionValueViewModelExtensionMethods
- Namespace
- Dynamicweb.Ecommerce.ProductCatalog
- Assembly
- Dynamicweb.Ecommerce.dll
Extension methods for FieldOptionValueViewModel that provide colour detection and conversion.
public static class FieldOptionValueViewModelExtensionMethods
- Inheritance
-
FieldOptionValueViewModelExtensionMethods
- Inherited Members
Methods
GetColor(FieldOptionValueViewModel)
Returns a ColorViewModel for a colour option, or null if the value is not a colour.
public static ColorViewModel? GetColor(this FieldOptionValueViewModel model)
Parameters
modelFieldOptionValueViewModelThe field option value model to examine.
Returns
- ColorViewModel
A ColorViewModel built from Value when IsColor(FieldOptionValueViewModel) is true; otherwise null.
- See Also
IsColor(FieldOptionValueViewModel)
Returns true if the option value is a CSS hex colour string.
public static bool IsColor(this FieldOptionValueViewModel model)
Parameters
modelFieldOptionValueViewModelThe field option value model to examine.
Returns
- bool
true when Value is a non-empty string whose first non-whitespace character is
#; otherwise false.
- See Also
TryGetColor(FieldOptionValueViewModel, out ColorViewModel?)
Tries to resolve a ColorViewModel from the option value.
public static bool TryGetColor(this FieldOptionValueViewModel model, out ColorViewModel? color)
Parameters
modelFieldOptionValueViewModelThe field option value model to examine.
colorColorViewModelWhen this method returns true, contains a ColorViewModel built from the hex string in Value; otherwise null.
Returns
- bool
true when IsColor(FieldOptionValueViewModel) is true and a ColorViewModel could be created; otherwise false.
- See Also