MailUtils wird noch von DakotaSender verwendet
This commit is contained in:
26
Shared/Extensions/DictionaryExtensions.cs
Normal file
26
Shared/Extensions/DictionaryExtensions.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.Extensions
|
||||
{
|
||||
public static class DictionaryExtensions
|
||||
{
|
||||
public static T2 GetValueOrDefault<T1, T2>(this Dictionary<T1, T2> dictionary, T1 key, T2 t_default)
|
||||
{
|
||||
if (dictionary is null || !dictionary.Any())
|
||||
return t_default;
|
||||
|
||||
if (dictionary.TryGetValue(key, out var val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
return t_default;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user