Class IfExtensions
Extension methods for 'If' checking like checking If something is null or not null
Inheritance
System.Object
      Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class IfExtensionsMethods
View SourceIfNotNull<TItem>(TItem, Action<TItem>)
The if not null.
Declaration
public static void IfNotNull<TItem>(this TItem item, Action<TItem> action)
    where TItem : classParameters
| Type | Name | Description | 
|---|---|---|
| TItem | item | The item. | 
| Action<TItem> | action | The action. | 
Type Parameters
| Name | Description | 
|---|---|
| TItem | The type | 
IfNotNull<TResult, TItem>(TItem, Func<TItem, TResult>, TResult)
Checks if the item is not null, and if so returns an action on that item, or a default value
Declaration
public static TResult IfNotNull<TResult, TItem>(this TItem item, Func<TItem, TResult> action, TResult defaultValue = null)
    where TItem : classParameters
| Type | Name | Description | 
|---|---|---|
| TItem | item | The item. | 
| Func<TItem, TResult> | action | The action. | 
| TResult | defaultValue | The default value. | 
Returns
| Type | Description | 
|---|---|
| TResult | 
Type Parameters
| Name | Description | 
|---|---|
| TResult | the result type | 
| TItem | The type | 
IfNull<TItem>(TItem, Func<TItem, TItem>)
Checks if the value is null, if it is it returns the value specified, otherwise returns the non-null value
Declaration
public static TItem IfNull<TItem>(this TItem item, Func<TItem, TItem> action)
    where TItem : classParameters
| Type | Name | Description | 
|---|---|---|
| TItem | item | |
| Func<TItem, TItem> | action | 
Returns
| Type | Description | 
|---|---|
| TItem | 
Type Parameters
| Name | Description | 
|---|---|
| TItem | 
IfTrue(Boolean, Action)
The if true.
Declaration
public static void IfTrue(this bool predicate, Action action)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | predicate | The predicate. | 
| Action | action | The action. |