コード例 #1
0
        static internal async Task <SymbolDetails> Create(
            SymbolReference symbolReference,
            PowerShellContext powerShellContext)
        {
            SymbolDetails symbolDetails = new SymbolDetails();

            symbolDetails.SymbolReference = symbolReference;

            // If the symbol is a command, get its documentation
            if (symbolReference.SymbolType == SymbolType.Function)
            {
                CommandInfo commandInfo =
                    await CommandHelpers.GetCommandInfo(
                        symbolReference.SymbolName,
                        powerShellContext);

                if (commandInfo != null)
                {
                    symbolDetails.Documentation =
                        await CommandHelpers.GetCommandSynopsis(
                            commandInfo,
                            powerShellContext);

                    if (commandInfo.CommandType == CommandTypes.Application)
                    {
                        symbolDetails.DisplayString = "(application) " + symbolReference.SymbolName;
                    }
                    else
                    {
                        symbolDetails.DisplayString = "function " + symbolReference.SymbolName;
                    }
                }
                else
                {
                    // Command information can't be loaded.  This is likely due to
                    // the symbol being a function that is defined in a file that
                    // hasn't been loaded in the runspace yet.
                    symbolDetails.DisplayString = "function " + symbolReference.SymbolName;
                }
            }
            else if (symbolReference.SymbolType == SymbolType.Parameter)
            {
                // TODO: Get parameter help
                symbolDetails.DisplayString = "(parameter) " + symbolReference.SymbolName;
            }
            else if (symbolReference.SymbolType == SymbolType.Variable)
            {
                symbolDetails.DisplayString = symbolReference.SymbolName;
            }

            return(symbolDetails);
        }
コード例 #2
0
        internal SymbolDetails(
            SymbolReference symbolReference, 
            Runspace runspace)
        {
            this.SymbolReference = symbolReference;

            // If the symbol is a command, get its documentation
            if (symbolReference.SymbolType == SymbolType.Function)
            {
                CommandInfo commandInfo =
                    CommandHelpers.GetCommandInfo(
                        symbolReference.SymbolName,
                        runspace);

                if (commandInfo != null)
                {
                    this.Documentation =
                        CommandHelpers.GetCommandSynopsis(
                            commandInfo,
                            runspace);

                    if (commandInfo.CommandType == CommandTypes.Application)
                    {
                        this.DisplayString = "(application) " + symbolReference.SymbolName;
                    }
                    else
                    {
                        this.DisplayString = "function " + symbolReference.SymbolName;
                    }
                }
                else
                {
                    // Command information can't be loaded.  This is likely due to
                    // the symbol being a function that is defined in a file that
                    // hasn't been loaded in the runspace yet.
                    this.DisplayString = "function " + symbolReference.SymbolName;
                }
            }
            else if (symbolReference.SymbolType == SymbolType.Parameter)
            {
                // TODO: Get parameter help
                this.DisplayString = "(parameter) " + symbolReference.SymbolName;
            }
            else if (symbolReference.SymbolType == SymbolType.Variable)
            {
                this.DisplayString = symbolReference.SymbolName;
            }
        }