別の型の Func を引数に取るジェネリック型に拡張メソッドを実装する方法はありますか?
たとえば、次のような使用法があります。
myFirstObject.Extension<myOtherObject>( other => other.Prop );
または、より複雑な Func を使用します。
myFirstObject.Extension<myOtherObject>( other => other.Prop > 2 && other.Prop < 15 );
this oneのような関連する質問がいくつか見つかりましたが、私の場合、拡張メソッド内にもジェネリック型が必要です。
これが私が思いついたものです:
public static bool Extension<TSource, TIn, TKey>(this TSource p_Value, Expression<Func<TIn, TKey>> p_OutExpression)
{ return true; }
しかし、いざ使おうとすると、2番目のタイプが考慮されていません。
何か不足していますか?