Class IfExtensions
Extension methods for 'If' checking like checking If something is null or not null
Inheritance
System.Object
Namespace: Umbraco.Core
Assembly: Umbraco.Core.dll
Syntax
public static class IfExtensions
Methods
View SourceIfNotNull<TItem>(TItem, Action<TItem>)
The if not null.
Declaration
public static void IfNotNull<TItem>(this TItem item, Action<TItem> action)
where TItem : class
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item. |
System.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 : class
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item. |
System.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 : class
Parameters
Type | Name | Description |
---|---|---|
TItem | item | |
System.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. |
System.Action | action | The action. |