Class ConditionalCssClasses
This is a helper class to conditionally apply CSS classes to an HTML element. Classes are added with the "AddIf(string, Func(bool))" method. From "ToString()" just the classes satisfying the condition are returned, joined into one string.
public class ConditionalCssClasses
- Inheritance
-
ConditionalCssClasses
- Inherited Members
Constructors
ConditionalCssClasses()
public ConditionalCssClasses()
Methods
AddIf(string, Func<bool>)
Adds a CSS class, whenever the "func" method returns true.
public ConditionalCssClasses AddIf(string name, Func<bool> func)
Parameters
name
stringThe string to be conditionally returned
func
Func<bool>The function to be executed to determine if the string is included
Returns
- ConditionalCssClasses
The instance of the class
ToString()
Executes the defined functions, returning a concatenation of the results separated by a space
public override string ToString()
Returns
- string
string