示例#1
0
        protected internal IReadOnlyDictionary <string, PromptCmdlet> GetCmdlets(PromptCmdletContext context)
        {
            const string CmdletsKey = "Prompt.Cmdlets";
            IReadOnlyDictionary <string, PromptCmdlet> cmdlets;

            if (!this.UseDynamicCmdlets)
            {
                if (!context.Annotations.TryGetValue(CmdletsKey, out var storedCmdlets))
                {
                    storedCmdlets = CreateCmdlets(context);
                    context.Annotations[CmdletsKey] = storedCmdlets;
                }

                cmdlets = (IReadOnlyDictionary <string, PromptCmdlet>)storedCmdlets;
            }
            else
            {
                cmdlets = CreateCmdlets(context);
            }

            return(cmdlets);
        }
示例#2
0
 protected virtual IReadOnlyDictionary <string, PromptCmdlet> CreateCmdlets(PromptCmdletContext context)
 {
     return(new Dictionary <string, PromptCmdlet>(StringComparer.OrdinalIgnoreCase));
 }
示例#3
0
 protected virtual string GetPromptText(PromptCmdletContext context)
 {
     return(">");
 }
示例#4
0
 public sealed override Task <PromptCmdletResult> ExecuteAsync(PromptCmdletContext context, params string[] args)
 {
     return(ExecuteAsync((TContext)context, args));
 }
示例#5
0
 protected sealed override IReadOnlyDictionary <string, PromptCmdlet> CreateCmdlets(PromptCmdletContext context)
 {
     return(CreateCmdlets((TContext)context));
 }
示例#6
0
 protected sealed override string GetPromptText(PromptCmdletContext context)
 {
     return(GetPromptText((TContext)context));
 }
示例#7
0
 public abstract Task <PromptCmdletResult> ExecuteAsync(PromptCmdletContext context, params string[] args);