Пример #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);