Class FieldOptionValueViewModelExtensionMethods
- Namespace
- Dynamicweb.Ecommerce.ProductCatalog
- Assembly
- Dynamicweb.Ecommerce.dll
public static class FieldOptionValueViewModelExtensionMethods
- Inheritance
-
FieldOptionValueViewModelExtensionMethods
- Inherited Members
Methods
GetColor(FieldOptionValueViewModel)
Gets the color model.
public static ColorViewModel? GetColor(this FieldOptionValueViewModel model)
Parameters
modelFieldOptionValueViewModelThe FieldOptionValueViewModel
Returns
- ColorViewModel
The ColorViewModel if the value kind is color, otherwise null
Remarks
This method checks if the value of the FieldOptionValueViewModel is a color by examining the value string. If the value starts with '#' and has a length greater than 0, it is considered a color. If the value is a color, it creates and returns a ColorViewModel using the ViewModelFactory. If the value is not a color, it returns null.
IsColor(FieldOptionValueViewModel)
Gets value indicated if the field value is color
public static bool IsColor(this FieldOptionValueViewModel model)
Parameters
modelFieldOptionValueViewModelThe FieldOptionValueViewModel
Returns
- bool
True if the field value is a color, otherwise false
Remarks
This method checks if the value of the FieldOptionValueViewModel is a color by examining the value string. If the value starts with '#' and has a length greater than 0, it is considered a color. If the value is not a color, it returns false.
TryGetColor(FieldOptionValueViewModel, out ColorViewModel?)
Tries to get the color model.
public static bool TryGetColor(this FieldOptionValueViewModel model, out ColorViewModel? color)
Parameters
modelFieldOptionValueViewModelThe FieldOptionValueViewModel
colorColorViewModelThe ColorViewModel if the value kind is color, otherwise null
Returns
- bool
True if the value kind is color and a ColorViewModel can be created, otherwise false
Remarks
This method checks if the value of the FieldOptionValueViewModel is a color by examining the value string. If the value starts with '#' and has a length greater than 0, it is considered a color. If the value is a color, it creates a ColorViewModel using the ViewModelFactory and assigns it to the out parameter. If the value is not a color, it assigns null to the out parameter.