1
This commit is contained in:
@@ -1,24 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public static class FuncExtensions
|
||||
{
|
||||
public static IEnumerable<Func<T0,T1>> CastAsFunc<T0,T1>(this Func<T0,T1> self)
|
||||
{
|
||||
return self.GetInvocationList().Cast<Func<T0, T1>>();
|
||||
}
|
||||
public static IEnumerable<Func<T0,T1,T2>> CastAsFunc<T0,T1,T2>(this Func<T0,T1,T2> self)
|
||||
{
|
||||
return self.GetInvocationList().Cast<Func<T0, T1,T2>>();
|
||||
}
|
||||
public static IEnumerable<Func<T0,T1,T2,T3>> CastAsFunc<T0,T1,T2,T3>(this Func<T0,T1,T2,T3> self)
|
||||
{
|
||||
return self.GetInvocationList().Cast<Func<T0, T1,T2,T3>>();
|
||||
}
|
||||
}
|
||||
public static class FuncExtensions
|
||||
{
|
||||
public static IEnumerable<Func<T0, T1>> CastAsFunc<T0, T1>(this Func<T0, T1> self)
|
||||
{
|
||||
return self is null ? Array.Empty<Func<T0,T1>>() : self?.GetInvocationList().Cast<Func<T0, T1>>();
|
||||
}
|
||||
|
||||
public static IEnumerable<Func<T0, T1, T2>> CastAsFunc<T0, T1, T2>(this Func<T0, T1, T2> self)
|
||||
{
|
||||
if (self is null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
Delegate[] invocationList = self.GetInvocationList();
|
||||
|
||||
// 遍历委托数组,将每个委托转换为 Func<T0, T1, T2> 并返回
|
||||
foreach (var delegateItem in invocationList)
|
||||
{
|
||||
if (delegateItem is not null && delegateItem is Func<T0, T1, T2> func)
|
||||
{
|
||||
yield return func;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<Func<T0, T1, T2, T3>> CastAsFunc<T0, T1, T2, T3>(this Func<T0, T1, T2, T3> self)
|
||||
{
|
||||
return self?.GetInvocationList().Cast<Func<T0, T1, T2, T3>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user