本文整理汇总了C#中Command.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Command.Run方法的具体用法?C# Command.Run怎么用?C# Command.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command.Run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(Type resolver)
{
Start(resolver, (InputCommands input) =>
{
var command = new Command();
command.Add(new KeyTrigger(Key.Y, State.Releasing));
command.Run(input);
});
}
示例2: TestCommandLambdaRegister
public void TestCommandLambdaRegister()
{
var dummy = NSubstitute.Substitute.For<IDummy>();
var command = new Command();
command.RegisterLambda(dummy , (d) => d.Method1() );
command.Run("method1", new string[]{});
dummy.Received().Method1();
command.RegisterLambda<IDummy , int,int>(dummy, (instance, a1 , a2) => instance.Method2(a1,a2));
command.Run("method2", new [] { "1" , "2"});
dummy.Received().Method2( 1 , 2);
command.RegisterLambda<IDummy, int, int , float>(dummy, (instance, a1, a2) => instance.Method3(a1, a2) , (result) => {});
command.Run("method3", new[] { "3", "4" });
dummy.Received().Method3(3, 4);
}
示例3: TestCommandRegisterEvent1
public void TestCommandRegisterEvent1()
{
var dummy = NSubstitute.Substitute.For<IDummy>();
var command = new Command();
command.RegisterEvent += (cmd, ret, args) =>
{
Assert.AreEqual("Method3" , cmd);
Assert.AreEqual(typeof(float), ret.Param);
Assert.AreEqual(typeof(int), args[0].Param);
Assert.AreEqual(typeof(int), args[1].Param);
};
command.RegisterLambda<IDummy, int, int, float>(dummy, (d,i1,i2) => d.Method3(i1,i2), (result) => { });
command.Run("method3", new [] { "3" , "9"});
}
示例4: TestCommandRegisterEvent2
public void TestCommandRegisterEvent2()
{
var dummy = NSubstitute.Substitute.For<IDummy>();
var command = new Command();
command.RegisterEvent += (cmd, ret, args) =>
{
Assert.AreEqual("Method2", cmd);
Assert.AreEqual(typeof(void), ret.Param);
Assert.AreEqual(typeof(int), args[0].Param);
Assert.AreEqual(typeof(int), args[1].Param);
Assert.AreEqual("return_Void" ,ret.Description );
};
command.RegisterLambda<IDummy, int, int>(dummy, (d, i1, i2) => d.Method2(i1, i2));
command.Run("method2", new[] { "3", "9" });
}
示例5: TestCommandRegister4
public void TestCommandRegister4()
{
var command = new Command();
int result = 0;
var cr = new CommandRegisterReturn<ICallTester, int>(
command,
(caller) => caller.Function5,
ret => { result = ret; });
var callTester = Substitute.For<ICallTester>();
callTester.Function5.Returns(1);
cr.Register(callTester);
command.Run(
"Function5",
new string[0]);
cr.Unregister();
Assert.AreEqual(1 , result);
}
示例6: TestCommandRegister3
public void TestCommandRegister3()
{
var command = new Command();
var cr = new CommandRegisterReturn<ICallTester, int, byte, float, int>(
command,
(caller, arg1, arg2, arg3) => caller.Function4(arg1, arg2, arg3),
ret => { });
var callTester = Substitute.For<ICallTester>();
cr.Register(callTester);
command.Run(
"Function4",
new[]
{
"1",
"2",
"3"
});
callTester.Received(1).Function4(Arg.Any<int>(), Arg.Any<byte>(), Arg.Any<float>());
cr.Unregister();
}
示例7: TestCommandRegister2
public void TestCommandRegister2()
{
var command = new Command();
var cr = new CommandRegisterReturn<ICallTester, int>(
command,
caller => caller.Function3(),
ret => { });
var callTester = Substitute.For<ICallTester>();
cr.Register(callTester);
command.Run(
"Function3",
new string[]
{
});
callTester.Received(1).Function3();
cr.Unregister();
}
示例8: TestCommandRegister1
public void TestCommandRegister1()
{
// data
var command = new Command();
var cr = new CommandRegister<ICallTester, int>(
command,
(caller, arg1) => caller.Function2(arg1));
var callTester = Substitute.For<ICallTester>();
// test
cr.Register(callTester);
command.Run(
"Function2",
new[]
{
"1"
});
// verify
cr.Unregister();
}
示例9: TestCommandRegister0
public void TestCommandRegister0()
{
var callTester = Substitute.For<ICallTester>();
var command = new Command();
var cr = new CommandRegister<ICallTester>(command, caller => caller.Function1());
cr.Register(callTester);
command.Run("Function1", new string[0]);
callTester.Received(1).Function1();
cr.Unregister();
}