[This is preliminary documentation and subject to change.]
他の関数オブジェクトの引数をバインドする関数オブジェクトです
この型のすべてのメンバの一覧については、 BindFunctor メンバを参照してください。
System.Object
Kodama.Function.Functor.Bind.BindFunctor
この型の public static (Visual Basicでは Shared) のすべてのメンバは、 マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
C++でいうSTL/Boostのbindに相当します。
[C#]
public class TestClass1
{
public void Print(string arg1, string arg2, object arg3, string arg4)
{
Console.WriteLine(arg1);
Console.WriteLine(arg2);
Console.WriteLine(arg3.ToString());
Console.WriteLine(arg4);
}
}
public class TestClass2
{
public override string ToString()
{
return "3";
}
}
// この関数を呼ぶと、コンソールに"1"、"2"、"3"、"4"と4行表示されます
public void BindFunctorTest()
{
// 引数をバインドする対象のMemberFunctorを生成する
IFunctor memberFunctor = new MemberFunctor(typeof(TestClass1).GetMethod("Print"));
// BindFunctorを生成する。このとき引数のバインドを行う
IFunctor bindFunctor = new BindFunctor(
// 引数をバインドするMemberFunctor
memberFunctor,
// methodFunctorの第1引数はバインドしない引数の指定
new NotBoundArgument(0),
// methodFunctorの第2引数をバインド
"1",
// methodFunctorの第3引数はバインドしない引数の指定
new NotBoundArgument(1),
// BindFunctor#Invoke毎に新しいTestClass2のインスタンスがバインドされる
BindUtility.Create(typeof(TestClass2), null),
// methodFunctorの第5引数をバインド
"4"});
// 関数オブジェクトの呼び出し
// ここでバインドしてない引数を渡します
bindFunctor.Invoke(new TestClass1(), "2");
}
名前空間: Kodama.Function.Functor.Bind
アセンブリ: Kodama.Function (Kodama.Function.dll 内)
BindFunctor クラス | BindFunctor メンバ | Kodama.Function.Functor.Bind 名前空間 | Boostリファレンス日本語訳