Class ObjectExtensions
Class ObjectExtensions.
Inherited Members
Namespace: FastMoq.Extensions
Assembly: FastMoq.Core.dll
Syntax
public static class ObjectExtensions
Methods
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds or updates (if key exists) the value in the dictionary.
Declaration
public static void AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<TKey, TValue> | dictionary | The dictionary. |
| TKey | key | The key. |
| TValue | value | The value. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the t key. |
| TValue | The type of the t value. |
RaiseIf(Func<bool>, string, string, int, string)
Raises if predicate is true.
Declaration
public static bool RaiseIf(Func<bool> predicate, string name, string path, int line, string exp)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | predicate | The predicate. |
| string | name | The name. |
| string | path | The path. |
| int | line | The line. |
| string | exp | The exp. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
RaiseIfNullOrEmpty(string?, string?, string?, int?, string?)
Raises if null or empty.
Declaration
public static void RaiseIfNullOrEmpty(this string? thing, string? name = null, string? path = null, int? line = null, string? exp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | thing | The thing. |
| string | name | The name. |
| string | path | The path. |
| int? | line | The line. |
| string | exp | The exp. |
RaiseIfNullOrWhitespace(string?, string?, string?, int?, string?)
Raises if null or whitespace.
Declaration
public static void RaiseIfNullOrWhitespace(this string? thing, string? name = null, string? path = null, int? line = null, string? exp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | thing | The thing. |
| string | name | The name. |
| string | path | The path. |
| int? | line | The line. |
| string | exp | The exp. |
RaiseIfNull<T>(T?, string?, string?, int?, string?)
Raises if null.
Declaration
public static void RaiseIfNull<T>(this T? thing, string? name = null, string? path = null, int? line = null, string? exp = null) where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| T? | thing | The thing. |
| string | name | The name. |
| string | path | The path. |
| int? | line | The line. |
| string | exp | The exp. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
RaiseIfNull<T>(T?, string?, string?, int?, string?)
Raises if null.
Declaration
public static T RaiseIfNull<T>(this T? thing, string? name = null, string? path = null, int? line = null, string? exp = null) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| T | thing | The thing. |
| string | name | The name. |
| string | path | The path. |
| int? | line | The line. |
| string | exp | The exp. |
Returns
| Type | Description |
|---|---|
| T | Raises if null. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | |
| InvalidOperationException |