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


C# CommandContext类代码示例

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


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

示例1: QueryState

        public override CommandState QueryState(CommandContext context)
        {
            if (context.Items.Length != 1)
             {
            return CommandState.Disabled;
             }

             Item poll = context.Items[0];
             if (!poll.Access.CanWrite())
             {
            return CommandState.Disabled;
             }

             PollItem pollItem = new PollItem(context.Items[0]);
             if (pollItem.IsClosed)
             {
            return CommandState.Disabled;
             }

             if (pollItem.IsArchived)
             {
            return CommandState.Disabled;
             }

             return CommandState.Enabled;
        }
开发者ID:Warunika,项目名称:SitecorePollModule,代码行数:26,代码来源:ClosePoll.cs

示例2: Create

 public static CommandContext Create(CommandContext parent, FileInfo fileInfo, TagCache cache, StringIdCache stringIds, HaloTag tag, Model model)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.hlmt", tag.Index));
     context.AddCommand(new HlmtListVariantsCommand(model, stringIds));
     context.AddCommand(new HlmtExtractModeCommand(cache, fileInfo, model, stringIds));
     return context;
 }
开发者ID:theTwist84,项目名称:DarkConvert,代码行数:7,代码来源:HlmtContextFactory.cs

示例3: BotAddCommand

        public void BotAddCommand(CommandContext context, IEnumerable<string> arguments)
        {
            if (arguments.Count() < 1)
            {
                SendInContext(context, "Usage: !bot add name [nick [arguments]]");
                return;
            }

            string botID = arguments.ElementAt(0);
            if (!GameManager.Bots.ContainsKey(botID))
            {
                SendInContext(context, "Invalid bot!");
                return;
            }

            string botNick = arguments.ElementAtOrDefault(1) ?? botID;

            try
            {
                Manager.AddBot(botNick, (IBot)GameManager.Bots[botID].GetConstructor(new Type[] { typeof(GameManager), typeof(IEnumerable<string>) }).Invoke(new object[] { Manager, arguments.Skip(2) }));
                Manager.SendPublic(context.Nick, "Added <{0}> (a bot of type {1})", botNick, botID);
            }
            catch (ArgumentException e)
            {
                SendInContext(context, "Error adding {0}: {1}", botNick, e.Message);
            }
        }
开发者ID:puckipedia,项目名称:CardsAgainstIRC,代码行数:27,代码来源:Base.cs

示例4: Render

        public override void Render(HtmlTextWriter output, Ribbon ribbon, Item button, CommandContext context)
        {
            var contextChunks = context.CustomData as List<Item>;
            if (contextChunks != null)
            {
                var chunk = contextChunks[0];
                contextChunks.RemoveAt(0);
                var psButtons = chunk.Children;
                var contextItem = context.Items.Length > 0 ? context.Items[0] : null;

                var ruleContext = new RuleContext
                {
                    Item = contextItem
                };
                foreach (var parameter in context.Parameters.AllKeys)
                {
                    ruleContext.Parameters[parameter] = context.Parameters[parameter];
                }

                foreach (Item psButton in psButtons)
                {
                    if (!RulesUtils.EvaluateRules(psButton["ShowRule"], ruleContext))
                    {
                        continue;
                    }

                    RenderLargeButton(output, ribbon, Control.GetUniqueID("script"),
                        Translate.Text(psButton.DisplayName),
                        psButton["__Icon"], string.Empty,
                        $"ise:runplugin(scriptDb={psButton.Database.Name},scriptId={psButton.ID})",
                        context.Parameters["ScriptRunning"] == "0" && RulesUtils.EvaluateRules(psButton["EnableRule"], ruleContext),
                        false, context);
                }
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:35,代码来源:IsePluginPanel.cs

示例5: Execute

 public override void Execute(CommandContext context)
 {
     if (context is DeleteScheduleContext)
      {
     Execute((DeleteScheduleContext) context);
      }
 }
开发者ID:Refactored,项目名称:SitecoreCalendarModule,代码行数:7,代码来源:DeleteSchedule.cs

示例6: GetSubmenuItems

        public override Control[] GetSubmenuItems(CommandContext context)
        {
            var controls = base.GetSubmenuItems(context);

            if (controls == null || context.Items.Length != 1 || context.Items[0] == null)
            {
                return controls;
            }

            var menuItems = new List<Control>();

            var roots = ModuleManager.GetFeatureRoots(IntegrationPoints.ContentEditorInsertItemFeature);

            foreach (var root in ModuleManager.GetFeatureRoots(IntegrationPoints.ContentEditorInsertItemFeature))
            {
                ScriptLibraryMenuItem.GetLibraryMenuItems(context.Items[0], menuItems, root);
            }

            if (roots.Count > 0 && controls.Length > 0)
            {
                menuItems.Add(new MenuDivider());
            }
            menuItems.AddRange(controls);
            return menuItems.ToArray();
        }
开发者ID:sobek85,项目名称:Console,代码行数:25,代码来源:NewItem.cs

示例7: Execute

 // Methods
 public override void Execute(CommandContext context)
 {
     var searchStringModel = ExtractSearchQuery(context.Parameters.GetValues("url")[0].Replace("\"", ""));
     var hitsCount = 0;
     var listOfItems = context.Items[0].Search(searchStringModel, out hitsCount).ToList();
     Items.CloneTo(listOfItems.Select(i => i.GetItem()).ToArray());
 }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:8,代码来源:CloneToCommand.cs

示例8: QueryState

        /// <summary>
        /// Get the state of the command. The command is always visible, but disabled if
        /// there is already a version in each language or if the user has no permission
        /// to edit the item.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <returns>State of the command.</returns>
        public override CommandState QueryState(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            if (context.Items.Length != 1)
            {
                return CommandState.Hidden;
            }

            Item item = context.Items[0];

            if (!Sitecore.Context.IsAdministrator && (!item.Access.CanWrite() || (!item.Locking.CanLock() && !item.Locking.HasLock())))
            {
                return CommandState.Disabled;
            }

            foreach (Language language in LanguageManager.GetLanguages(item.Database))
            {
                Item itemInLanguage = ItemManager.GetItem(item.ID, language, Sitecore.Data.Version.Latest, item.Database);
                if (itemInLanguage.Versions.GetVersions().Length == 0)
                {
                    return CommandState.Enabled;
                }
            }

            return CommandState.Disabled;
        }
开发者ID:studert,项目名称:SitecoreItemVersioner,代码行数:34,代码来源:CreateVersions.cs

示例9: Execute

        /// <summary>
        /// Executes the command in the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

              string id = context.Parameters["id"];
              if (!ID.IsID(id))
              {
            return;
              }

              Item orderItem = Sitecore.Context.ContentDatabase.GetItem(new ID(id));
              if (orderItem == null)
              {
            return;
              }

              ICatalogView view = context.CustomData as ICatalogView;
              if (view == null)
              {
            return;
              }

              ClientPipelineArgs args = new ClientPipelineArgs(new NameValueCollection(context.Parameters));
              args.Parameters.Add("uri", orderItem.Uri.ToString());
              args.Parameters["fields"] = this.GetFields(view.EditorFields);
              args.CustomData.Add("catalogView", view);

              ContinuationManager.Current.Start(this, "Run", args);
        }
开发者ID:HydAu,项目名称:sitecore8ecommerce,代码行数:33,代码来源:EditOrder.cs

示例10: Execute

        public override void Execute(CommandContext context)
        {
            if (context.Items.Length != 1) return;

            //TODO put the GUIDS used here somewhere central
            //If this is a template, launch the single template generator
            if (context.Items[0].TemplateID.ToString() == "{AB86861A-6030-46C5-B394-E8F99E8B87DB}")
            {
                //Build the url for the control
                string controlUrl = UIUtil.GetUri("control:xmlGenerateCustomItem");
                string id = context.Items[0].ID.ToString();
                string url = string.Format("{0}&id={1}", controlUrl, id);

                //Open the dialog
                Context.ClientPage.ClientResponse.Broadcast(Context.ClientPage.ClientResponse.ShowModalDialog(url), "Shell");
            }

                //If this is a template folder, launch the folder template generateor
            else if (context.Items[0].TemplateID.ToString() == "{0437FEE2-44C9-46A6-ABE9-28858D9FEE8C}")
            {
                //Build the url for the control
                string controlUrl = UIUtil.GetUri("control:xmlGenerateCustomItemByFolder");
                string id = context.Items[0].ID.ToString();
                string url = string.Format("{0}&id={1}", controlUrl, id);

                //Open the dialog
                Context.ClientPage.ClientResponse.Broadcast(Context.ClientPage.ClientResponse.ShowModalDialog(url), "Shell");
            }
            else
            {
                SheerResponse.Alert("You can only run the Custom Item Generator on a Template or Template Folder.", new string[0]);
            }
        }
开发者ID:kmazzoni,项目名称:Custom-Item-Generator,代码行数:33,代码来源:CustomItemGeneratorCommand.cs

示例11: Execute

        public override void Execute(CommandContext context)
        {
            PersonaHelper personaHelper = PersonaHelper.GetHelper();
            personaHelper.ResetProfiles();

            SheerResponse.Redraw();
        }
开发者ID:adoprog,项目名称:Sitecore-Persona-Switcher,代码行数:7,代码来源:ResetProfile.cs

示例12: Execute

 public override void Execute(CommandContext context)
 {
     if (Context.Request.FilePath == "/sitecore/shell/~/xaml/sitecore.shell.applications.analytics.trackingfielddetails.aspx")
      {
     SheerResponse.Eval("window.location.href = window.location.href");
      }
 }
开发者ID:Warunika,项目名称:SitecorePollModule,代码行数:7,代码来源:RefreshTracking.cs

示例13: Render

        public override void Render(HtmlTextWriter output, Ribbon ribbon, Item button, CommandContext context)
        {
            var psButtons = button.GetChildren();
            foreach (Item psButton in psButtons)
            {
                var msg = Message.Parse(this, psButton["Click"]);
                var scriptDb = msg.Arguments["scriptDB"];
                var scriptId = msg.Arguments["script"];

                if (string.IsNullOrWhiteSpace(scriptDb) || string.IsNullOrWhiteSpace(scriptId))
                {
                    continue;
                }

                var scriptItem = Factory.GetDatabase(scriptDb).GetItem(scriptId);
                if (scriptItem == null || !RulesUtils.EvaluateRules(scriptItem["ShowRule"], context.Items[0]))
                {
                    continue;
                }

                RenderLargeButton(output, ribbon, Control.GetUniqueID("script"),
                    Translate.Text(scriptItem.DisplayName),
                    scriptItem["__Icon"], string.Empty,
                    psButton["Click"],
                    RulesUtils.EvaluateRules(scriptItem["EnableRule"], context.Items[0]),
                    false, context);

                return;
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:30,代码来源:ContentEditorRibbonPanel.cs

示例14: Execute

        public override void Execute(CommandContext context)
        {
            var selectedItem = context.Items.FirstOrDefault();
            if (selectedItem == null)
                return;

            string templateId = "{CC80011D-8EAE-4BFC-84F1-67ECD0223E9E}";

            TemplateItem newTemplate = new TemplateItem(Sitecore.Context.Database.GetItem(templateId));

            if (newTemplate != null)
            {
                try
                {
                    using (new Sitecore.SecurityModel.SecurityDisabler())
                    {
                        selectedItem.Editing.BeginEdit();
                        selectedItem.ChangeTemplate(newTemplate);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message, ex, this);
                    throw;
                }
                finally
                {
                    selectedItem.Editing.EndEdit();
                }
            }
        }
开发者ID:islaytitans,项目名称:AssignTemplates,代码行数:31,代码来源:AssignTemplates.cs

示例15: Execute

        public override void Execute(CommandContext context)
        {
            ID id = ID.Null;
            bool isId = false;

            var fieldId = context.Parameters["fieldId"];

            if (!string.IsNullOrEmpty(fieldId))
            {
                var form = System.Web.HttpContext.Current.Request.Form;

                if (form != null)
                {
                    string targetId = form[string.Format("{0}{1}", fieldId, Constants.Selected)];

                    if (string.IsNullOrEmpty(targetId))
                    {
                        targetId = form[string.Format("{0}{1}", fieldId, Constants.Unselected)];
                    }

                    isId = ID.TryParse(targetId, out id);
                }
            }

            Sitecore.Context.ClientPage.SendMessage(this, "item:load(id=" + (isId ? id.ToString() : string.Empty) + ")");
        }
开发者ID:islaytitans,项目名称:FollowTarget,代码行数:26,代码来源:FollowMultilist.cs


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