17 lines
456 B
C#
17 lines
456 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace BITKit
|
|
{
|
|
public static partial class Extensions
|
|
{
|
|
public static IDictionary<TKey, TValue> CreateOrAddIfEmety<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key, Func<TValue> createFactory)
|
|
{
|
|
if (self.ContainsKey(key) is false)
|
|
{
|
|
self.Add(key, createFactory.Invoke());
|
|
}
|
|
return self;
|
|
}
|
|
}
|
|
} |