示例#1
0
        } // ScriptInfo ctor

        /// <summary>
        /// This is a copy constructor, used primarily for get-command.
        /// </summary>
        internal ScriptInfo(ScriptInfo other)
            : base(other)
        {
            this.ScriptBlock = other.ScriptBlock;
        }
 internal DlrScriptCommandProcessor(ScriptInfo scriptInfo, ExecutionContext context, bool useNewScope, SessionStateInternal sessionState)
     : base(scriptInfo, context, useNewScope, sessionState)
 {
     Init();
 }
 internal DlrScriptCommandProcessor(ScriptInfo scriptInfo, ExecutionContext context, bool useNewScope, SessionStateInternal sessionState) : base(scriptInfo, context, useNewScope, sessionState)
 {
     this._input = new ArrayList();
     this.Init();
 }
示例#4
0
 internal DlrScriptCommandProcessor(ScriptInfo scriptInfo, ExecutionContext context, bool useNewScope, SessionStateInternal sessionState)
     : base(scriptInfo, context, useNewScope, sessionState)
 {
     Init();
 }
示例#5
0
        internal CommandProcessorBase LookupCommandProcessor(
            CommandInfo commandInfo,
            CommandOrigin commandOrigin,
            bool?useLocalScope)
        {
            if (commandInfo.CommandType == CommandTypes.Alias && (commandOrigin == CommandOrigin.Internal || commandInfo.Visibility == SessionStateEntryVisibility.Public))
            {
                AliasInfo aliasInfo = (AliasInfo)commandInfo;
                commandInfo = aliasInfo.ResolvedCommand;
                if (commandInfo == null)
                {
                    CommandNotFoundException notFoundException = new CommandNotFoundException(aliasInfo.Name, (Exception)null, "AliasNotResolvedException", new object[1]
                    {
                        (object)aliasInfo.UnresolvedCommandName
                    });
                    CommandDiscovery.tracer.TraceException((Exception)notFoundException);
                    throw notFoundException;
                }
                PSSQMAPI.IncrementData(CommandTypes.Alias);
            }
            CommandDiscovery.ShouldRun(this._context, (PSHost)this._context.EngineHostInterface, commandInfo, commandOrigin);
            CommandProcessorBase commandProcessorBase;

            switch (commandInfo.CommandType)
            {
            case CommandTypes.Function:
            case CommandTypes.Filter:
                FunctionInfo     functionInfo = (FunctionInfo)commandInfo;
                ExecutionContext context1     = this._context;
                bool?            nullable1    = useLocalScope;
                int num1 = nullable1.HasValue ? (nullable1.GetValueOrDefault() ? 1 : 0) : 1;
                commandProcessorBase = CommandDiscovery.CreateCommandProcessorForScript(functionInfo, context1, num1 != 0);
                break;

            case CommandTypes.Cmdlet:
                commandProcessorBase = (CommandProcessorBase) new CommandProcessor((CmdletInfo)commandInfo, this._context);
                break;

            case CommandTypes.ExternalScript:
                ExternalScriptInfo externalScriptInfo = (ExternalScriptInfo)commandInfo;
                externalScriptInfo.SignatureChecked = true;
                try
                {
                    if (!this._context.IsSingleShell)
                    {
                        ExternalScriptInfo scriptInfo = externalScriptInfo;
                        bool?nullable2 = useLocalScope;
                        int  num2      = nullable2.HasValue ? (nullable2.GetValueOrDefault() ? 1 : 0) : 1;
                        commandProcessorBase = this.CreateScriptProcessorForMiniShell(scriptInfo, num2 != 0);
                        break;
                    }
                    ExternalScriptInfo           scriptInfo1           = externalScriptInfo;
                    RunspaceConfigForSingleShell runspaceConfiguration = this._context.RunspaceConfiguration as RunspaceConfigForSingleShell;
                    bool?nullable3 = useLocalScope;
                    int  num3      = nullable3.HasValue ? (nullable3.GetValueOrDefault() ? 1 : 0) : 1;
                    commandProcessorBase = this.CreateScriptProcessorForSingleShell(scriptInfo1, runspaceConfiguration, num3 != 0);
                    break;
                }
                catch (ScriptRequiresSyntaxException ex)
                {
                    CommandNotFoundException notFoundException = new CommandNotFoundException(ex.Message, (Exception)ex);
                    CommandDiscovery.tracer.TraceException((Exception)notFoundException);
                    throw notFoundException;
                }
                catch (PSArgumentException ex)
                {
                    CommandNotFoundException notFoundException = new CommandNotFoundException(commandInfo.Name, (Exception)ex, "ScriptRequiresInvalidFormat", new object[0]);
                    CommandDiscovery.tracer.TraceException((Exception)notFoundException);
                    throw notFoundException;
                }

            case CommandTypes.Application:
                commandProcessorBase = (CommandProcessorBase) new NativeCommandProcessor((ApplicationInfo)commandInfo, this._context);
                break;

            case CommandTypes.Script:
                ScriptInfo       scriptInfo2 = (ScriptInfo)commandInfo;
                ExecutionContext context2    = this._context;
                bool?            nullable4   = useLocalScope;
                int num4 = nullable4.HasValue ? (nullable4.GetValueOrDefault() ? 1 : 0) : 1;
                commandProcessorBase = CommandDiscovery.CreateCommandProcessorForScript(scriptInfo2, context2, num4 != 0);
                break;

            default:
                CommandNotFoundException notFoundException1 = new CommandNotFoundException(commandInfo.Name, (Exception)null, "CommandNotFoundException", new object[0]);
                CommandDiscovery.tracer.TraceException((Exception)notFoundException1);
                throw notFoundException1;
            }
            PSSQMAPI.IncrementData(commandInfo.CommandType);
            commandProcessorBase.Command.CommandOriginInternal       = commandOrigin;
            commandProcessorBase.Command.MyInvocation.InvocationName = commandInfo.Name;
            return(commandProcessorBase);
        }
示例#6
0
 /// <summary>
 /// Create a copy of commandInfo for GetCommandCommand so that we can generate parameter
 /// sets based on an argument list (so we can get the dynamic parameters.)
 /// </summary>
 internal override CommandInfo CreateGetCommandCopy(object[] argumentList)
 {
     ScriptInfo copy = new ScriptInfo(this) { IsGetCommandCopy = true, Arguments = argumentList };
     return copy;
 }
示例#7
0
        } // ScriptInfo ctor

        /// <summary>
        /// This is a copy constructor, used primarily for get-command.
        /// </summary>
        internal ScriptInfo(ScriptInfo other)
            : base(other)
        {
            this.ScriptBlock = other.ScriptBlock;
        }