Change Name to MultiTool
This commit is contained in:
17
MultiTool.Shared/IDictionaryEx.vb
Normal file
17
MultiTool.Shared/IDictionaryEx.vb
Normal file
@@ -0,0 +1,17 @@
|
||||
Imports System.Runtime.CompilerServices
|
||||
|
||||
Module IDictionaryEx
|
||||
<Extension()>
|
||||
Function GetOrDefault(Of TKey, TValue)(pDictionary As Dictionary(Of TKey, TValue), pKey As TKey, Optional pOnMissing As TValue = Nothing) As TValue
|
||||
Dim oValue As TValue
|
||||
Return IIf(pDictionary.TryGetValue(pKey, oValue), oValue, pOnMissing)
|
||||
End Function
|
||||
|
||||
<Extension()>
|
||||
Function GetOrInsertNew(Of T, U As New)(dic As Dictionary(Of T, U), key As T) As U
|
||||
If dic.ContainsKey(key) Then Return dic(key)
|
||||
Dim newObj As U = New U()
|
||||
dic(key) = newObj
|
||||
Return newObj
|
||||
End Function
|
||||
End Module
|
||||
Reference in New Issue
Block a user