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


C# ICommandContext类代码示例

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


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


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