Provides generic extension methods for safe invocation, dictionary operations, and string formatting.
More...
|
| static void | SafeInvoke< T > (this T obj, Action< T > action) |
| | Safely invokes the specified action if the object is not null.
|
| static void | AddOrUpdate< TKey, TValue > (this Dictionary< TKey, TValue > dictionary, TKey key, TValue value) |
| | Adds a key-value pair to the dictionary or updates the value if the key already exists.
|
| static string | ToSeparatedString (this IEnumerable< string > collection, string separator=", ") |
| | Joins a collection of strings into a single string, separated by the specified separator. Returns a single space if the collection is null.
|
Provides generic extension methods for safe invocation, dictionary operations, and string formatting.
◆ AddOrUpdate< TKey, TValue >()
| void IuvoUnity.Extensions.GenericExtensions.AddOrUpdate< TKey, TValue > |
( |
this Dictionary< TKey, TValue > | dictionary, |
|
|
TKey | key, |
|
|
TValue | value ) |
|
static |
Adds a key-value pair to the dictionary or updates the value if the key already exists.
- Template Parameters
-
| TKey | The type of keys in the dictionary. |
| TValue | The type of values in the dictionary. |
- Parameters
-
| dictionary | The dictionary to update. |
| key | The key to add or update. |
| value | The value to set. |
37 {
38 dictionary[key] = value;
39 }
◆ SafeInvoke< T >()
| void IuvoUnity.Extensions.GenericExtensions.SafeInvoke< T > |
( |
this T | obj, |
|
|
Action< T > | action ) |
|
static |
Safely invokes the specified action if the object is not null.
- Template Parameters
-
- Parameters
-
| obj | The object to invoke the action on. |
| action | The action to invoke. |
21 {
22 if (obj != null)
23 {
24 action(obj);
25 }
26 }
◆ ToSeparatedString()
| string IuvoUnity.Extensions.GenericExtensions.ToSeparatedString |
( |
this IEnumerable< string > | collection, |
|
|
string | separator = ", " ) |
|
static |
Joins a collection of strings into a single string, separated by the specified separator. Returns a single space if the collection is null.
- Parameters
-
| collection | The string collection to join. |
| separator | The separator to use. |
- Returns
- A separated string or a space if the collection is null.
49 {
50 return collection == null ? " " : string.Join(separator, collection);
51 }
The documentation for this class was generated from the following file: