当前位置: 首页>>代码示例>>C#>>正文


C# Command.Execute方法代码示例

本文整理汇总了C#中Command.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Command.Execute方法的具体用法?C# Command.Execute怎么用?C# Command.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


在下文中一共展示了Command.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

    public void Update()
    {
        command = inputHandler.HandleInput();
        
        if (command != null)
        {
            command.Execute(this);
        }

        Vector2 vectorR  = new Vector2(transform.position.x+0.13f, transform.position.y);
        Vector2 vectorL  = new Vector2(transform.position.x-0.13f, transform.position.y);
        Vector2 vectorD  = new Vector2(transform.position.x      , transform.position.y-0.17f);
        Vector2 vectorDL = new Vector2(transform.position.x-0.12f, transform.position.y-0.17f);
        Vector2 vectorDR = new Vector2(transform.position.x+0.12f, transform.position.y-0.17f);
        
        hitR = Physics2D.Raycast(vectorR  , Vector2.right);
        hitL = Physics2D.Raycast(vectorL  , Vector2.left );
        hitD = Physics2D.Raycast(vectorD  , Vector2.down );
        hitDL = Physics2D.Raycast(vectorDL, Vector2.down );
        hitDR = Physics2D.Raycast(vectorDR, Vector2.down );
            
        distanceR  = Mathf.Abs(hitR.point.x  - vectorR.x);
        distanceL  = Mathf.Abs(hitL.point.x  - vectorL.x);
        distanceD  = Mathf.Abs(hitD.point.y  - vectorD.y);
        distanceDL = Mathf.Abs(hitDL.point.y - vectorDL.y);
        distanceDR = Mathf.Abs(hitDR.point.y - vectorDR.y);
        
        SetAnimation();

        canJump  = (distanceDL <= 0.01f) || (distanceDR <= 0.01f);
        canTotem = (distanceD  <= 0.01f);
        
    }
开发者ID:LuizFernandoVieira,项目名称:GGJ,代码行数:33,代码来源:Player.cs

示例2: Execute

        public void Execute(Command command)
        {
            // コマンドを実行
            command.Execute();

            // Undo機能の為にリストに追加する
            commandList.Add(command);
        }
开发者ID:noda0320,项目名称:Design-Pattern,代码行数:8,代码来源:CommandManager.cs

示例3: ExecuteWithCanExecute

		public void ExecuteWithCanExecute ()
		{
			bool executed = false;
			var cmd = new Command (() => executed = true, () => true);

			cmd.Execute (null);
			Assert.True (executed);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:CommandTests.cs

示例4: ExecuteParameterized

		public void ExecuteParameterized ()
		{
			object executed = null;
			var cmd = new Command (o => executed = o);

			var expected = new object ();
			cmd.Execute (expected);

			Assert.AreEqual (expected, executed);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:10,代码来源:CommandTests.cs

示例5: OnItemTappedChanged

 public static void OnItemTappedChanged(BindableObject bo, Command oldValue, Command newValue)
 {
     var lv = bo as ListView;
     if (lv != null)
     {
         lv.ItemTapped += (sender, args) =>
         {
             newValue.Execute(args.Item);
         };
     }
 }
开发者ID:tmyers5,项目名称:XamarinFormsWorkshop,代码行数:11,代码来源:ListViewCommands.cs

示例6: Execute

        public void Execute(Command command, MessageSender executor, IrcMessage message, CommandParameters parameters)
        {
            var isExecutionAllowed = securityLevelChecker.IsCommandExecutionAllowed(command, bot, executor.HostMask);
            if (!isExecutionAllowed)
            {
                bot.SayTo(executor.Channel, "You don't have required permission for this command");
                return;
            }

            command.Execute(executor, message, parameters);
        }
开发者ID:mikoskinen,项目名称:ircbot-dotnet,代码行数:11,代码来源:CommandExecutor.cs

示例7: MenuPage

        public MenuPage()
        {
            InitializeComponent();

            _chosenItemCmd = new Command(obj =>
            {
                var mic = MenuItemChanged;
                if (mic != null)
                {
                    mic.Invoke(this, new MenuItemChangedEventArg()
                    {
                        SelectedMenuItem = obj as MenuItem,
                    });
                }
            });

            _calcMenuItems = new List<MenuItem>()
            {
                new MenuItem("Introduction", () => new IntroPage()),
                new MenuItem("Step 1", () => new Step1Page()),
                new MenuItem("Step 2", () => new Step2Page()),
                new MenuItem("Step 3", () => new Step3Page()),
                new MenuItem("Step 4", () => new Step4Page()),
                new MenuItem("Step 5", () => new ContentPage()),
            };

            _appMenuItems = new List<MenuItem>()
            {
                new MenuItem("About", () => new ContentPage()),
                new MenuItem("Settings", () => new ContentPage()),
                new MenuItem("Help", () => new ContentPage()),
            };

            _subMenu.ItemsSource = _calcMenuItems;

            _subMenu.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                if (e.SelectedItem != null)
                {
                    var mi = (MenuItem)e.SelectedItem;
                    _subMenu.SelectedItem = null;
                    _chosenItemCmd.Execute(mi);
                }
            };

            _subMenu.ItemTemplate = new DataTemplate(() =>
            {
                var tc = new TextCell();
                tc.SetBinding(TextCell.TextProperty, "MenuTitle");

                return tc;
            });
        }
开发者ID:NamXH,项目名称:Orchard,代码行数:53,代码来源:MenuPage.xaml.cs

示例8: Execute_ShouldExecuteAction

		public void Execute_ShouldExecuteAction(
			object arg,
			ISchedulers schedulers,
			Mock<ICanExecuteStrategy<object>> canExecute)
		{
			//arrange
			object actual = null;
			var sut = new Command<object>(o => actual = o, schedulers, "name", canExecute.Object);

			//act
			sut.Execute(arg);

			//assert
			actual.Should().Be(arg);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:15,代码来源:CommandTests.cs

示例9: ZoomVM

        public ZoomVM()
        {
            _indexGenerator = new Random();
            _imageUrls = new List<ImageResource>
            {
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://yeahsoup.s3-us-west-2.amazonaws.com/wp-content/uploads/2015/05/img1114.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://i.telegraph.co.uk/multimedia/archive/02262/A124CE_2262003b.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://i.telegraph.co.uk/multimedia/archive/01476/chimp_1476818c.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://i.huffpost.com/gen/1490756/images/o-CHIMPANZEE-facebook.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://static1.squarespace.com/static/523b539be4b0a75330f9c8ce/55a55614e4b01d30adbfe144/55a557ace4b0632463d49108/1436909257139/babyowl.jpg?format=1000w"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://www.rantlifestyle.com/wp-content/uploads/2014/06/schattigebabydier11.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://ww2.valdosta.edu/~kaletour/bb1.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "https://36.media.tumblr.com/5c493da746cc1c1f438ae304591244c4/tumblr_n9a78n99Ea1tvs3v3o1_500.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://streetloop.com/wp-content/uploads/2014/07/Baby-animals-looking-like-their-parents25.jpg"}
            };

            ToggleZoomCommand = new Command((_) =>
            {
                EnableZoom = !EnableZoom;
            });
            ChangeImageCommand = new Command(async (_) =>
            {
                var index = _indexGenerator.Next(0, _imageUrls.Count - 1);
                var resource = _imageUrls[index];
                ImageComesFrom = Enum.GetName(typeof(ImageOrigin), resource.ImageFrom);
                if (resource.ImageFrom == ImageOrigin.Uri)
                    Image = new UriImageSource() { Uri = new Uri(resource.ImageSourceText)};
                else if (resource.ImageFrom == ImageOrigin.Stream)
                {
                    // this would normally be something off the device, but any stream will do so we'll just manually get a stream to the online image
                    var client = new HttpClient(new NativeMessageHandler());
                    var stream = await client.GetStreamAsync(resource.ImageSourceText);
                    Image = ImageSource.FromStream(() => stream);
                }
                else
                    throw new NotSupportedException($"Unable to load image of type {ImageComesFrom} with value {resource.ImageSourceText}.");
            });

            // enable zoom should initially be false
            EnableZoom = false;

            // initialize the image
            ChangeImageCommand.Execute(null);
        }
开发者ID:JC-Chris,项目名称:XFExtensions,代码行数:44,代码来源:ZoomVM.cs

示例10: ExecuteShouldInvokeCallback

        public void ExecuteShouldInvokeCallback()
        {
            // arrange
            var execute = new Mock<Action<object>>();

            execute.Setup( f => f( It.IsAny<object>() ) );

            var command = new Command<object>( execute.Object );
            var executed = false;

            command.Executed += ( s, e ) => executed = true;

            // act
            command.Execute();

            // assert
            Assert.True( executed );
            execute.Verify( f => f( null ), Times.Once() );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:19,代码来源:CommandTTest.cs

示例11: ExecuteWherigoCommandOnTarget

		private void ExecuteWherigoCommandOnTarget(Command command, Thing target)
		{
			command.Execute(target);
		}
开发者ID:rautava,项目名称:WF.Player.WinPhone,代码行数:4,代码来源:ThingViewModel.cs

示例12: WriteSomething

 public static void WriteSomething(Command HowToWrite)
 {
     HowToWrite.Execute();
 }
开发者ID:TheoAndersen,项目名称:CommandPatternsInCSharp,代码行数:4,代码来源:Program.cs

示例13: ExecuteCommand

 private void ExecuteCommand(Command command)
 {
     command.Listener = this;
     command.Execute();
 }
开发者ID:rodrigod89,项目名称:project-decubed-online,代码行数:5,代码来源:CubeController.cs

示例14: Execute

 protected void Execute(Command command)
 {
     command.MongoContext = MongoContext;
     command.EntityStore = EntityStore;
     command.Execute();
 }
开发者ID:JefClaes,项目名称:topdevlinks,代码行数:6,代码来源:CommandTestFixture.cs

示例15: GenericExecuteWithCanExecute

		public void GenericExecuteWithCanExecute ()
		{
			string result = null;
			var cmd = new Command<string> (s => result = s, s => true);

			cmd.Execute ("Foo");
			Assert.AreEqual ("Foo", result);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:CommandTests.cs


注:本文中的Command.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。