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


C# ICommand类代码示例

本文整理汇总了C#中ICommand的典型用法代码示例。如果您正苦于以下问题:C# ICommand类的具体用法?C# ICommand怎么用?C# ICommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: insert

        /// <summary>
        /// ��Ʈw�s�W��k
        /// </summary>
        /// <param name="insert"></param>
        public void insert(ICommand insert)
        {
            string myCmd = insert.getCommand();
            try
            {
                cmd = new OdbcCommand(myCmd, GetConn());
                //cmd = new IBM.Data.DB2.DB2Command(myCmd, GetConn());
                cmd.ExecuteNonQuery();
            }
            catch (OdbcException dobcEx)
            {
                if (dobcEx.ErrorCode == -2146232009)
                {
                    return;
                }

                try
                {
                    lock (typeof(OdbcConnection))
                    {
                        //cmd = new IBM.Data.DB2.DB2Command(myCmd, GetConn());
                        cmd = new OdbcCommand(myCmd, GetConn());
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:35,代码来源:A_OdbcConnect.cs

示例2: Handle

 public override void Handle(IntentsDataFlowData obj)
 {
     if (obj != null) {
         IEnumerable<ICommand> intentStates = EvaluateIntentStates(obj.Value);
         _commandResult = CombineCommands(intentStates);
     }
 }
开发者ID:stewmc,项目名称:vixen,代码行数:7,代码来源:DataFlowDataDispatchingDataPolicy.cs

示例3: Unwrap

		public static ICommand Unwrap(ICommand command) {
			CommandWrapper w = command as CommandWrapper;
			if (w != null)
				return w.wrappedCommand;
			else
				return command;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:7,代码来源:CommandWrapper.cs

示例4: Setup

		public void Setup()
		{

			_testCommand = A.Fake<ICommand>();
			_publisher = A.Fake<IPublisher>();
			_compositeApp = A.Fake<ICompositeApp>();
			_registry = A.Fake<ICommandRegistry>();
			_formatter = A.Fake<IResponseFormatter>();
			_publicationRecord = A.Fake<ICommandPublicationRecord>();
			_jsonSerializer = new DefaultJsonSerializer();
			_xmlSerializer = new DefaultXmlSerializer();

			A.CallTo(() => _testCommand.Created).Returns(DateTime.MaxValue);
			A.CallTo(() => _testCommand.CreatedBy).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _testCommand.Identifier).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _formatter.Serializers).Returns(new List<ISerializer> { _jsonSerializer, _xmlSerializer });
			A.CallTo(() => _publicationRecord.Dispatched).Returns(true);
			A.CallTo(() => _publicationRecord.Error).Returns(false);
			A.CallTo(() => _publicationRecord.Completed).Returns(true);
			A.CallTo(() => _publicationRecord.Created).Returns(DateTime.MinValue);
			A.CallTo(() => _publicationRecord.MessageLocation).Returns(new Uri("http://localhost/fake/message"));
			A.CallTo(() => _publicationRecord.MessageType).Returns(typeof(IPublicationRecord));
			A.CallTo(() => _publicationRecord.CreatedBy).Returns(Guid.Empty);
			A.CallTo(() => _compositeApp.GetCommandForInputModel(A.Dummy<IInputModel>())).Returns(_testCommand);
			A.CallTo(() => _publisher.PublishMessage(A.Fake<ICommand>())).Returns(_publicationId);
			A.CallTo(() => _registry.GetPublicationRecord(_publicationId)).Returns(_publicationRecord);

			_euclidApi = new ApiModule(_compositeApp, _registry, _publisher);
		}
开发者ID:smhinsey,项目名称:Euclid,代码行数:29,代码来源:CompositeInspectorApiTests.cs

示例5: Execute

        public void Execute(ICommand command)
        {
            command.Execute();

            undoStack.Push(command);
            redoStack.Clear();
        }
开发者ID:shootdaj,项目名称:MIDIator,代码行数:7,代码来源:UndoManager.cs

示例6: ForEachCommand

 public ForEachCommand(string name, IExpression expression, ICommand command, bool localvar)
 {
     this.name = name;
     this.expression = expression;
     this.command = command;
     this.localvar = localvar;
 }
开发者ID:ajlopez,项目名称:AjSharp,代码行数:7,代码来源:ForEachCommand.cs

示例7: Handle

        public async Task Handle(ICommand<CreateSale> command)
        {
            var cmd = command.Payload;

            await repository.CreateOrUpdate(cmd.SaleId,
                                            s => s.Create(cmd.SellerId, cmd.Item, cmd.Price, cmd.Stock));
        }
开发者ID:jamesholcomb,项目名称:NDomain,代码行数:7,代码来源:SaleCommandHandler.cs

示例8: RegisterCommand

        /// <summary>
        /// Adds a command to the collection and signs up for the <see cref="ICommand.CanExecuteChanged"/> event of it.
        /// </summary>
        ///  <remarks>
        /// If this command is set to monitor command activity, and <paramref name="command"/> 
        /// implements the <see cref="IActiveAware"/> interface, this method will subscribe to its
        /// <see cref="IActiveAware.IsActiveChanged"/> event.
        /// </remarks>
        /// <param name="command">The command to register.</param>
        public virtual void RegisterCommand(ICommand command)
        {
            if (command == this)
            {
                throw new ArgumentException(Resources.CannotRegisterCompositeCommandInItself);
            }

            lock (this.registeredCommands)
            {
                if (this.registeredCommands.Contains(command))
                {
                    throw new InvalidOperationException(Resources.CannotRegisterSameCommandTwice);
                }
                this.registeredCommands.Add(command);
            }

            command.CanExecuteChanged += this.onRegisteredCommandCanExecuteChangedHandler;
            this.OnCanExecuteChanged();

            if (this.monitorCommandActivity)
            {
                var activeAwareCommand = command as IActiveAware;
                if (activeAwareCommand != null)
                {
                    activeAwareCommand.IsActiveChanged += this.Command_IsActiveChanged;
                }
            }
        }
开发者ID:eslahi,项目名称:prism,代码行数:37,代码来源:CompositeCommand.cs

示例9: GetAttribute

        //private static void UpdateCheckedState(StopAstConversion stopCode)
        //{
        //    // this does not work.
        //    foreach (MenuItem item in MainWindow.Instance.GetMainMenuItems())
        //    {
        //        if (!(item.Command is StopMenuCommand))
        //            continue;
        //        var attr = GetAttribute(item.Command);

        //        if (attr.StopCode == stopCode)
        //        {
        //            item.IsCheckable = true;
        //            item.IsChecked = true;
        //        }
        //        else
        //        {
        //            item.IsChecked = false;
        //        }
        //    }
        //}

        private static StopRLMenuCommandAttribute GetAttribute(ICommand command)
        {
            var attr = command.GetType().GetCustomAttributes(typeof(StopRLMenuCommandAttribute), true)
                              .Cast<StopRLMenuCommandAttribute>()
                              .FirstOrDefault();
            return attr;
        }
开发者ID:jakesays,项目名称:dot42,代码行数:28,代码来源:MenuRLLanguage.cs

示例10: Execute

        public void Execute(ICommand command)
        {
            var commandHandler = _commandHandleProvider.GetInternalCommandHandle(command.GetType());

            var commandContext = new CommandContext(_repository);

            commandHandler(commandContext, command);

            var aggregateRoots = commandContext.AggregateRoots;

            if (aggregateRoots.Count > 1)
                throw new Exception("one command handler can change just only one aggregateRoot.");

            var aggregateRoot = aggregateRoots.First().Value;

            var domainEvents = aggregateRoot.GetUnCommitEvents();

            var eventStream = BuildEventStream(aggregateRoot, command.CommandId);

            _eventStore.AppendAsync(eventStream);

            if (aggregateRoot.Version % 3 == 0)
                _snapshotStorage.Create(new SnapshotRecord(aggregateRoot.AggregateRootId, aggregateRoot.Version,
                    _binarySerializer.Serialize(aggregateRoot)));

            _eventPublisher.PublishAsync(domainEvents);

            aggregateRoot.Clear();

            Console.WriteLine(aggregateRoot.ToString());

            Console.WriteLine("DomainEvents count is {0}", domainEvents.Count);
        }
开发者ID:liuxiqin,项目名称:Sevens,代码行数:33,代码来源:DefaultCommandProssor.cs

示例11: UpdateState

		public override void UpdateState(int chainIndex, ICommand[] outputStates)
		{
			int chan = 0; // Current channel being processed.
			byte[] buf = new byte[2];   // The serial data buffer.

			if (serialPortIsValid && _serialPort.IsOpen)
			{
				for (char port = 'A'; port <= 'C'; ++port)
				{
					buf[0] = (byte)port;
					buf[1] = 0;
					for (int bit = 0; (bit < 8 && chan < outputStates.Length && IsRunning); ++bit, ++chan)
					{
						_commandHandler.Reset();
						ICommand command = outputStates[chan];
						if (command != null)
						{
							command.Dispatch(_commandHandler);
						}
						buf[1] |= (byte)(((_commandHandler.Value > _minIntensity) ? 0x01 : 0x00) << bit);
					}
					_serialPort.Write(buf, 0, 2);
				}
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:25,代码来源:ElexolUSBModule.cs

示例12: CreateCommand

		void CreateCommand()
		{
			try {
				string link = codon.Properties["link"];
				string command = codon.Properties["command"];
				if (link != null && link.Length > 0) {
					var callback = LinkCommandCreator;
					if (callback == null)
						throw new NotSupportedException("MenuCommand.LinkCommandCreator is not set, cannot create LinkCommands.");
					menuCommand = callback(link);
				} else if (command != null && command.Length > 0) {
					var callback = KnownCommandCreator;
					if (callback == null)
						throw new NotSupportedException("MenuCommand.KnownCommandCreator is not set, cannot create commands.");
					menuCommand = callback(codon.AddIn, command);
				} else {
					menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
				}
				if (menuCommand != null) {
					menuCommand.Owner = caller;
				}
			} catch (Exception e) {
				MessageService.ShowException(e, "Can't create menu command : " + codon.Id);
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:25,代码来源:MenuCommand.cs

示例13: EventsViewModel

        public EventsViewModel(INavigationController navigationController)
        {
            Title = AppResources.EventsTitle;

            EventActivatedCommand = ControllerUtil.MakeShowCourseEventCommand(navigationController);
            Index = 8;
        }
开发者ID:banjoh,项目名称:noppawp8,代码行数:7,代码来源:EventsViewModel.cs

示例14: ArticleViewModel

        public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            if (newsFeedService == null)
            {
                throw new ArgumentNullException("newsFeedService");
            }

            if (regionManager == null)
            {
                throw new ArgumentNullException("regionManager");
            }

            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            this.newsFeedService = newsFeedService;
            this.regionManager = regionManager;

            this.showArticleListCommand = new DelegateCommand(this.ShowArticleList);
            this.showNewsReaderViewCommand = new DelegateCommand(this.ShowNewsReaderView);

            eventAggregator.GetEvent<TickerSymbolSelectedEvent>().Subscribe(OnTickerSymbolSelected, ThreadOption.UIThread);
        }
开发者ID:CarlosVV,项目名称:mediavf,代码行数:25,代码来源:ArticleViewModel.cs

示例15: QueryResultsViewModel

        public QueryResultsViewModel(string caption, IQueryResultsView view, IEventAggregator aggregator, ITimeLineService service, 
            IAsyncManager asyncManager, ContextMenuRoot menu)
        {
            this._aggregator = aggregator;
            _service = service;
            this._asyncManager = asyncManager;
            Caption = caption;
            View = view;

            View.DataContext = this;

            this.Tweets = new ObservableCollection<TweetViewModel>();

            this._aggregator.GetEvent<RefreshEvent>().Subscribe(Refresh//,
                ,ThreadOption.UIThread, true,
                _ => !this.Editing
                );

            GlobalCommands.UpCommand.RegisterCommand(new DelegateCommand<object>(MoveUp));
            GlobalCommands.DownCommand.RegisterCommand(new DelegateCommand<object>(MoveDown));

            _contextMenu = menu;

            _editCommand = new DelegateCommand<object>(EditSelectedTweet,
                                                       o =>
                                                       this.SelectedTweet !=
                                                       null);

            _cancelEditCommand = new DelegateCommand<object>(CancelEdit,
                o => this.SelectedTweet != null && this.SelectedTweet.Editable);
        }
开发者ID:ArildF,项目名称:linqtwit,代码行数:31,代码来源:QueryResultsViewModel.cs


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