public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as AddFromTemplateMode; if (mode == null) { return; } if (!mode.IsReady) { return; } var templates = mode.Templates.Where(c => c.Name.IsFilterMatch(context.Text)).ToList(); if (!templates.Any()) { return; } var commands = new List <Hit>(); foreach (var templateHeader in templates) { var command = new AddFromTemplate(templateHeader); commands.Add(new Hit(templateHeader.Name, command)); } context.Commandy.AddHits(commands); }
public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as WorkflowMode; if (mode == null) { return; } if (!mode.IsReady) { return; } var workflowCommands = mode.WorkflowCommands.Where(c => c.Name.IsFilterMatch(context.Text)).ToList(); if (!workflowCommands.Any()) { return; } var commands = new List <Hit>(); foreach (var workflowCommand in workflowCommands) { commands.Add(new Hit(workflowCommand.Name, workflowCommand)); } context.Commandy.AddHits(commands); }
public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as InsertRenderingMode; if (mode == null) { return; } if (!mode.IsReady) { return; } var renderingItems = mode.RenderingItems.Where(c => c.Name.IsFilterMatch(context.Text)).ToList(); if (!renderingItems.Any()) { return; } var commands = new List <Hit>(); foreach (var renderingItem in renderingItems) { commands.Add(new Hit(renderingItem.Name, renderingItem)); } context.Commandy.AddHits(commands); }
public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as LanguageMode; if (mode == null) { return; } if (!mode.IsReady) { return; } var languages = mode.Languages.Where(c => c.Name.IsFilterMatch(context.Text) || c.DisplayName.IsFilterMatch(context.Text)); if (!languages.Any()) { return; } var commands = new List <Hit>(); foreach (var language in languages) { commands.Add(new Hit(language.Name + " - " + language.DisplayName, language)); } context.Commandy.AddHits(commands); }
public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as SearchBasedMode; if (mode == null) { return; } if (string.IsNullOrEmpty(context.Text) || context.Text == text) { return; } mode.IsReady = false; text = context.Text; var s = context.Commandy.Parameter as ISiteSelectionContext; if (s == null) { return; } GetItemsCompleted <ItemHeader> completed = delegate(IEnumerable <ItemHeader> items) { var hits = new List <Hit>(); foreach (var itemHeader in items) { var rank = 2; if (itemHeader.Name.StartsWith(context.Text, StringComparison.InvariantCultureIgnoreCase)) { rank = 0; } else if (itemHeader.Name.IsFilterMatch(context.Text)) { rank = 1; } var hit = new Hit(string.Format(@"{0} - [{1}, {2}]", itemHeader.Name, itemHeader.TemplateName, itemHeader.Path), itemHeader, rank); hits.Add(hit); } context.Commandy.AddHits(hits); mode.IsReady = true; }; s.Site.DataService.Search(context.Text, new DatabaseUri(s.Site, DatabaseName.Master), string.Empty, string.Empty, ItemUri.Empty, 0, completed); }
public override void Search(CommandyContext context) { Assert.ArgumentNotNull(context, nameof(context)); var mode = context.Mode as CommandMode; if (mode == null) { return; } var commands = mode.Commands.Where(c => c.Text.IsFilterMatch(context.Text)).ToList(); if (!commands.Any()) { return; } context.Commandy.AddHits(commands.Select(c => new Hit(c.Text, c))); }
public abstract void Search(CommandyContext context);