This commit is contained in:
CortexCore
2024-11-03 16:38:17 +08:00
parent 056e2cada5
commit 4ba741408d
4693 changed files with 2445 additions and 5443 deletions

View File

@@ -8,7 +8,8 @@ namespace BITKit
{
public static IEnumerable<Func<T>> CastAsFunc<T>(this Func<T> self)
{
return self is null ? Array.Empty<Func<T>>() : self?.GetInvocationList().Cast<Func<T>>();
var value = self;
return value is null? Array.Empty<Func<T>>() : self?.GetInvocationList().Cast<Func<T>>();
}
public static IEnumerable<Func<T0, T1>> CastAsFunc<T0, T1>(this Func<T0, T1> self)
{

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -186,6 +187,10 @@ namespace BITKit
self.Add(key, value);
}
}
public static TValue Get<TKey,TValue>(this IDictionary<Type,TValue> self)
{
return self[typeof(TKey)];
}
public static TValue Get<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key) where TValue : new()
{
lock (self)