• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ICommandContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Execute

        /// <summary>
        /// Executes the ShowTopScore Command on the passed context.
        /// </summary>
        /// <param name="ctx">The context that contains the Score object</param>
        public void Execute(ICommandContext ctx)
        {
            char separator = '-';
            int sepCount = 15;

            string header = new string(separator, sepCount) + " Top 5 players: " + new string(separator, sepCount) + Environment.NewLine;

            string footer = Environment.NewLine + new string(separator, 2) + " " + new string(separator, 40) + " " + new string(separator, 2) + Environment.NewLine;

            var highscores = ctx.HighscoreProcessor.GetTopHighscores();

            if (highscores.Count() == 0)
            {
                ctx.CurrentMessage = ctx.Messages["noscores"];
            }
            else
            {
                ctx.CurrentMessage = header + string.Join(
                    Environment.NewLine,
                    highscores.Select(x =>
                    {
                        if (x.Item1.Length > 18)
                        {
                            return new Tuple<string, int>(x.Item1.Substring(0, 15) + "...", x.Item2);
                        }

                        return x;
                    }).Select(x => string.Format("{0,-20} {1}", x.Item1, x.Item2))) + footer;
            }
        }
开发者ID:Baloons-Pop-2,项目名称:Balloons-Pop-2,代码行数:34,代码来源:ShowTopScoreCommand.cs


示例2: Run

        public void Run(ICommandContext context)
        {
            var parameters = context.Parameters;

            var allAttributeNames = new[]{
                COMMAND_GET_ALL,
                COMMAND_GET_SINGLE,
                COMMAND_GET_MIN,
                COMMAND_GET_MAX
            };

            if (_setupParameters.Directory == null)
            {
                throw new ApplicationException("No working directory set.  Use 'setup --dir [workingdirectory] to continue.");
            }
            else if (!parameters.Attributes.Select(s => s.Key).Intersect(allAttributeNames).Any())
            {
                throw new ApplicationException("Command parameters required.");
            }

            var versions = _versionRepository.Get(new GetVersionsParameters {
                                Path = _setupParameters.Directory,
                                Single = parameters.GetAttribute(COMMAND_GET_SINGLE, required: false),
                                Min = parameters.GetAttribute(COMMAND_GET_MIN, required: false),
                                Max = parameters.GetAttribute(COMMAND_GET_MAX, required: false)
                                });

            foreach (var version in versions)
            {
                _utility.WriteLine(String.Format(   "Version # {0} \t Down Script: {1} \t Up Script: {2}",
                                                version.Name,
                                                version.DownScript != null,
                                                version.UpScript != null));
            }
        }
开发者ID:BlackjacketMack,项目名称:Versionit,代码行数:35,代码来源:GetCommand.cs


示例3: Do

        public override void Do(ICommandContext context)
        {
            BaseType op2 = null; //context.RunStack.Pop().Clone();
            BaseType op1 = null; //context.RunStack.Pop().Clone();

            BaseType result = null;
            BaseType first = null;
            BaseType second = null;

            using (var listener = new Memory.AutoCleanup())
            {
                op2 = context.RunStack.Pop().Clone();
                op1 = context.RunStack.Pop().Clone();

                TypeEnum biggerType = TypeHierarchy.GetBiggerType(op1.Type, op2.Type);
                first = op1.ConvertTo(biggerType);
                second = op2.ConvertTo(biggerType);

                // Note: Dereference has no effect on tests.
                result = first.Dereference().Clone();

                switch (operation)
                {
                    case Operations.Addition:
                        result.Add(second);
                        break;
                    case Operations.Subtraction:
                        result.Subtract(second);
                        break;
                    case Operations.Multiplication:
                        result.Multiply(second);
                        break;
                    case Operations.Division:
                        result.Divide(second);
                        break;
                    case Operations.Power:
                        result.Power(second);
                        break;
                    case Operations.Modulo:
                        result.Modulo(second);
                        break;
                    case Operations.LogicalXor:
                        result = ValueFactory.Create(first && !second || !first && second);
                        break;
                    case Operations.LogicalOr:
                        result = ValueFactory.Create(first || second);
                        break;
                    case Operations.LogicalAnd:
                        result = ValueFactory.Create(first && second);
                        break;
                    default:
                        break;
                }
            }

            //op1.Delete();
            //op2.Delete();

            context.RunStack.Push(result.Clone());
        }
开发者ID:hunpody,项目名称:psimulex,代码行数:60,代码来源:BinaryOperation.cs


示例4: Invoke

        /// <summary>
        /// Invokes the current command with the specified context as input.
        /// </summary>
        /// <param name="context">The context for the command.</param>
        public void Invoke(ICommandContext context)
        {
            var commandContext = context as ShutdownApplicationContext;
            Debug.Assert(commandContext != null, "Incorrect command context specified.");

            m_Action();
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:11,代码来源:ShutdownApplicationCommand.cs


示例5: Execute

 public override void Execute(ICommandContext context)
 {
     if (context.Memory.Memento != null)
     {
         context.Board.RestoreMemento(context.Memory.Memento);
     }
 }
开发者ID:Fatme,项目名称:King-Survival-4,代码行数:7,代码来源:UndoCommand.cs


示例6: ExecuteShowForumArticles

 public void ExecuteShowForumArticles(ICommandContext context, int? forumId)
 {
     context.OpenUrlInBrowser(
         JanusProtocolDispatcher.FormatURI(
             JanusProtocolResourceType.ArticleList,
             GetForumId(context, forumId).ToString()));
 }
开发者ID:permyakov,项目名称:janus,代码行数:7,代码来源:ForumCommandTarget.cs


示例7: Execute

        public void Execute(ICommandContext context, IList<string> arguments)
        {
            int maxNameLength = context.Service.Commands.Select(i => i.Name.Length).Max();

            foreach (var i in context.Service.Commands.OrderBy(i => i.Name))
                context.NormalWriter.WriteLine("{0,-" + maxNameLength + "} - {1}", i.Name, i.Description);
        }
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:7,代码来源:HelpCommand.cs


示例8: ExecuteGoToMessage

        public void ExecuteGoToMessage(
            ICommandContext context, int? messageId)
        {
            var parentWindow = context
                .GetRequiredService<IUIShell>()
                .GetMainWindowParent();

            if (Config.Instance.ConfirmationConfig.ConfirmJump
                    && MessageBox.Show(
                            parentWindow,
                            SR.Search.JumpRequest,
                            SR.Search.Confirmation,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) != DialogResult.Yes)
                return;

            if (ApplicationManager.Instance.ForumNavigator.SelectMessage(
                    ForumCommandHelper.GetMessageId(context, messageId)))
            {
                var mainWindowSvc = context.GetService<IMainWindowService>();
                if (mainWindowSvc != null)
                    mainWindowSvc.EnsureVisible();
            }
            else
                MessageBox.Show(
                    parentWindow,
                    SR.Search.NotFound,
                    SR.Search.Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
        }
开发者ID:permyakov,项目名称:janus,代码行数:31,代码来源:ForumViewerCommandTarget.cs


示例9: ExecuteGoToMessageWithPrompt

        public void ExecuteGoToMessageWithPrompt(ICommandContext context)
        {
            var parentWindow = context.GetRequiredService<IUIShell>().GetMainWindowParent();

            int mid;
            using (var etf = new EnterTopicMessageIdForm())
                if (etf.ShowDialog(parentWindow) == DialogResult.OK)
                    mid = etf.MessageId;
                else
                    return;

            if (ApplicationManager.Instance.ForumNavigator.SelectMessage(mid))
            {
                var mainWindowSvc = context.GetService<IMainWindowService>();
                if (mainWindowSvc != null)
                    mainWindowSvc.EnsureVisible();
            }
            else if (MessageBox.Show(
                parentWindow,
                SR.Forum.GoToMessage.NotFound.FormatStr(mid),
                SR.Search.Error,
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Exclamation,
                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                context
                    .GetRequiredService<IOutboxManager>()
                    .AddTopicForDownload(mid);
        }
开发者ID:permyakov,项目名称:janus,代码行数:28,代码来源:ForumViewerCommandTarget.cs


示例10: ExecuteCompactDb

        public void ExecuteCompactDb(ICommandContext context)
        {
            ProgressWorker.Run(
                context,
                false,
                progressVisualizer =>
                    {
                        progressVisualizer.SetProgressText(Resources.CompactDbProgressText);

                        var janusDatabaseManager = context.GetRequiredService<IJanusDatabaseManager>();

                        using(janusDatabaseManager.GetLock().GetWriterLock())
                        using (var con = new SQLiteConnection(janusDatabaseManager.GetCurrentConnectionString()))
                        using (var cmd = con.CreateCommand())
                        {
                            con.Open();

                            // This is a REALLY long operation
                            cmd.CommandTimeout = Int32.MaxValue;

                            // Clean up the backend database file
                            cmd.CommandText = @"pragma page_size=" + SqliteSchemaDriver.PageSize + @"; VACUUM; ANALYZE;";
                            cmd.ExecuteNonQuery();
                        }
                    });
        }
开发者ID:permyakov,项目名称:janus,代码行数:26,代码来源:SqliteCommandTarget.cs


示例11: LoadModel

 protected override Rendering.Model LoadModel(ICommandContext commandContext, AssetManager assetManager)
 {
     var meshConverter = CreateMeshConverter(commandContext);
     var materialMapping = Materials.Select((s, i) => new { Value = s, Index = i }).ToDictionary(x => x.Value.Name, x => x.Index);
     var sceneData = meshConverter.Convert(SourcePath, Location, materialMapping);
     return sceneData;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:ImportFbxCommand.cs


示例12: DoCommandOverride

        protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
        {
            logger = commandContext.Logger;
            if (!File.Exists(ProcessPath))
            {
                logger.Error("Unable to find binary file " + ProcessPath);
                return Task.FromResult(ResultStatus.Failed);
            }

            var startInfo = new ProcessStartInfo
            {
                FileName = ProcessPath,
                Arguments = Arguments,
                WorkingDirectory = ".",
                UseShellExecute = false,
                RedirectStandardOutput = true
            };
            process = Process.Start(startInfo);
            process.OutputDataReceived += OnOutputDataReceived;
            process.BeginOutputReadLine();
            process.WaitForExit();

            ExitCode = process.ExitCode;

            return Task.FromResult(CancellationToken.IsCancellationRequested ? ResultStatus.Cancelled : (ExitCode == 0 ? ResultStatus.Successful : ResultStatus.Failed));
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:26,代码来源:ExternalProcessCommand.cs


示例13: ExecuteModerating

 public void ExecuteModerating(ICommandContext context, int? messageId)
 {
     using (var frm = new ModeratingForm(
             context,
             ForumCommandHelper.GetMessageId(context, messageId)))
         frm.ShowDialog(context.GetRequiredService<IUIShell>().GetMainWindowParent());
 }
开发者ID:permyakov,项目名称:janus,代码行数:7,代码来源:ForumMessageCommandTarget.cs


示例14: Do

 public override void Do(ICommandContext context)
 {
     //if (dimension == 1)
     //{
         if (initFromStack)
         {
             if (type.TypeEnum == TypeEnum.Array && readSizesFromStack)
             {
                 type.Dimensions = context.RunStack.Pop(dimension).Select(value => value.ToInt32()).ToList();
             }
             var list = new Types.List();
             for (int i = 0; i < size; i++)
                 list.Insert(context.RunStack.Pop());
             context.RunStack.Push(list.ConvertTo(type));
         }
         else
         {
             // ???
             context.RunStack.Push(new Types.Array(type, context.RunStack.Pop().ToInt32()));
         }
     //}
     //else
     //{
     //    throw new Psimulex.Core.Exceptions.PsimulexException("More than one dimensional array is not implemented yet!");
     //}
 }
开发者ID:hunpody,项目名称:psimulex,代码行数:26,代码来源:CollectionInitializer.cs


示例15: ExecuteAddForumMessageToFavorites

		public void ExecuteAddForumMessageToFavorites(
			ICommandContext context, int? messageId)
		{
			var manager = context.GetRequiredService<IFavoritesManager>();
			var activeMsg = ForumMessageCommandHelper.GetMessage(context, messageId);

			using (var selForm =
				new FavoritesSelectFolderForm(
					context,
					manager.RootFolder,
					true))
			{
				selForm.Comment = activeMsg.Subject;

				var windowParent = context.GetRequiredService<IUIShell>().GetMainWindowParent();

				if (selForm.ShowDialog(windowParent) == DialogResult.OK)
				{
					var folder = selForm.SelectedFolder ?? manager.RootFolder;
					if (!manager.AddMessageLink(activeMsg.ID, selForm.Comment, folder))
						//сообщения уже есть в разделе
						MessageBox.Show(
							windowParent,
							SR.Favorites.ItemExists.FormatWith(
								activeMsg.ID, folder.Name),
							ApplicationInfo.ApplicationName,
							MessageBoxButtons.OK,
							MessageBoxIcon.Information);
				}
			}
		}
开发者ID:rsdn,项目名称:janus,代码行数:31,代码来源:ForumMessageCommandTarget.cs


示例16: DefaultCommandExecutor

        public DefaultCommandExecutor(
            IProcessingCommandCache processingCommandCache,
            ICommandAsyncResultManager commandAsyncResultManager,
            ICommandHandlerProvider commandHandlerProvider,
            IAggregateRootTypeProvider aggregateRootTypeProvider,
            IMemoryCache memoryCache,
            IRepository repository,
            IRetryCommandService retryCommandService,
            IEventStore eventStore,
            IEventPublisher eventPublisher,
            IEventPersistenceSynchronizerProvider eventPersistenceSynchronizerProvider,
            ICommandContext commandContext,
            ILoggerFactory loggerFactory)
        {
            _processingCommandCache = processingCommandCache;
            _commandAsyncResultManager = commandAsyncResultManager;
            _commandHandlerProvider = commandHandlerProvider;
            _aggregateRootTypeProvider = aggregateRootTypeProvider;
            _memoryCache = memoryCache;
            _repository = repository;
            _retryCommandService = retryCommandService;
            _eventStore = eventStore;
            _eventPublisher = eventPublisher;
            _eventPersistenceSynchronizerProvider = eventPersistenceSynchronizerProvider;
            _commandContext = commandContext;
            _trackingContext = commandContext as ITrackingContext;
            _logger = loggerFactory.Create(GetType().Name);

            if (_trackingContext == null)
            {
                throw new Exception("command context must also implement ITrackingContext interface.");
            }
        }
开发者ID:hjlfmy,项目名称:enode,代码行数:33,代码来源:DefaultCommandExecutor.cs


示例17: ExecuteInsertPairTag

        public void ExecuteInsertPairTag(
            ICommandContext context, string start, string end, bool newLine)
        {
            if (start == "url=" && Clipboard.ContainsText())
            {
                var clipboardText = Clipboard.GetText();
                if (clipboardText.StartsWith("www."))
                    start += "http://" + clipboardText;
                else if (Uri.IsWellFormedUriString(clipboardText, UriKind.Absolute))
                    start += clipboardText;
            }

            switch (start)
            {
                case "c#":
                case "nemerle":
                case "msil":
                case "midl":
                case "asm":
                case "ccode":
                case "code":
                case "pascal":
                case "vb":
                case "sql":
                case "java":
                case "perl":
                case "php":
                    Config.Instance.LastLanguageTag = start;
                    break;
            }

            context.GetRequiredService<IMessageEditorService>().SurroundText(
                "[" + start + "]", "[/" + end + "]", newLine);
        }
开发者ID:permyakov,项目名称:janus,代码行数:34,代码来源:MessageEditorCommandTarget.cs


示例18: LoadAnimation

 protected override Dictionary<string, AnimationClip> LoadAnimation(ICommandContext commandContext, ContentManager contentManager, out TimeSpan duration)
 {
     var meshConverter = this.CreateMeshConverter(commandContext);
     var sceneData = meshConverter.ConvertAnimation(SourcePath, Location);
     duration = sceneData.Duration;
     return sceneData.AnimationClips;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:ImportAssimpCommand.cs


示例19: Setup

 public void Setup()
 {
     var mock = new Mock<ICommandContext>();
     mock.SetupGet(x => x.Messages).Returns(this.messages);
     mock.SetupProperty(x => x.CurrentMessage, string.Empty);
     this.ctx = mock.Object;
 }
开发者ID:Baloons-Pop-2,项目名称:Balloons-Pop-2,代码行数:7,代码来源:InvalidInputCommandTests.cs


示例20: CreateMeshConverter

 private Paradox.Importer.AssimpNET.MeshConverter CreateMeshConverter(ICommandContext commandContext)
 {
     return new Paradox.Importer.AssimpNET.MeshConverter(commandContext.Logger)
     {
         AllowUnsignedBlendIndices = this.AllowUnsignedBlendIndices
     };
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:ImportAssimpCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICommandExecutor类代码示例发布时间:2022-05-24
下一篇:
C# ICommandConsole类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap