Пример #1
0
        protected override void OnRestorePreviousScope()
        {
            // When dotting a script cmdlet, pop the locals of automatic variables from
            // the 'DottedScopes' of the current scope.
            PSScriptCmdlet scriptCmdlet = this.Command as PSScriptCmdlet;

            if (scriptCmdlet != null && !UseLocalScope)
            {
                scriptCmdlet.PopDottedScope(CommandSessionState.CurrentScope);
            }
        }
Пример #2
0
        private void Init(IScriptCommandInfo scriptCommandInfo)
        {
            InternalCommand command = new PSScriptCmdlet(scriptCommandInfo.ScriptBlock, base._useLocalScope, base.FromScriptFile, base._context);

            base.Command      = command;
            base.CommandScope = base._useLocalScope ? base.CommandSessionState.NewScope(base._fromScriptFile) : base.CommandSessionState.CurrentScope;
            this.InitCommon();
            if (!base.UseLocalScope)
            {
                CommandProcessorBase.ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, base._context.LanguageMode, base.Command.MyInvocation);
            }
        }
Пример #3
0
        private void Init(IScriptCommandInfo scriptCommandInfo)
        {
            PSScriptCmdlet psScriptCmdlet = new PSScriptCmdlet(scriptCommandInfo.ScriptBlock);

            psScriptCmdlet.UseLocalScope = this._useLocalScope;
            if (scriptCommandInfo.ScriptBlock.SessionStateInternal != null)
            {
                this.CommandSessionState = scriptCommandInfo.ScriptBlock.SessionStateInternal;
            }
            this.Command = (InternalCommand)psScriptCmdlet;
            this.InitCommon();
        }
        private void Init(IScriptCommandInfo scriptCommandInfo)
        {
            InternalCommand scriptCmdlet =
                new PSScriptCmdlet(scriptCommandInfo.ScriptBlock, _useLocalScope, FromScriptFile, _context);

            this.Command      = scriptCmdlet;
            this.CommandScope = _useLocalScope
                                    ? this.CommandSessionState.NewScope(_fromScriptFile)
                                    : this.CommandSessionState.CurrentScope;

            InitCommon();

            // If the script has been dotted, throw an error if it's from a different language mode.
            if (!this.UseLocalScope)
            {
                ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, _context.LanguageMode, Command.MyInvocation);
            }
        }
Пример #5
0
        private void Init(IScriptCommandInfo scriptCommandInfo)
        {
            var scriptCmdlet = new PSScriptCmdlet(scriptCommandInfo.ScriptBlock, UseLocalScope, FromScriptFile, _context);

            this.Command      = scriptCmdlet;
            this.CommandScope = UseLocalScope
                                    ? this.CommandSessionState.NewScope(_fromScriptFile)
                                    : this.CommandSessionState.CurrentScope;

            if (UseLocalScope)
            {
                // Set the 'LocalsTuple' of the new scope to that of the scriptCmdlet
                scriptCmdlet.SetLocalsTupleForNewScope(CommandScope);
            }

            InitCommon();

            // If the script has been dotted, throw an error if it's from a different language mode.
            if (!this.UseLocalScope)
            {
                ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, _context.LanguageMode, Command.MyInvocation);
            }
        }
Пример #6
0
        private void Init(IScriptCommandInfo scriptCommandInfo)
        {
            InternalCommand scriptCmdlet =
                new PSScriptCmdlet(scriptCommandInfo.ScriptBlock, _useLocalScope, FromScriptFile, _context);

            this.Command = scriptCmdlet;
            this.CommandScope = _useLocalScope
                                    ? this.CommandSessionState.NewScope(_fromScriptFile)
                                    : this.CommandSessionState.CurrentScope;

            InitCommon();

            // If the script has been dotted, throw an error if it's from a different language mode.
            if (!this.UseLocalScope)
            {
                ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, _context.LanguageMode, Command.MyInvocation);
            }
        }
Пример #7
0
 private void Init(IScriptCommandInfo scriptCommandInfo)
 {
     InternalCommand command = new PSScriptCmdlet(scriptCommandInfo.ScriptBlock, base._useLocalScope, base.FromScriptFile, base._context);
     base.Command = command;
     base.CommandScope = base._useLocalScope ? base.CommandSessionState.NewScope(base._fromScriptFile) : base.CommandSessionState.CurrentScope;
     this.InitCommon();
     if (!base.UseLocalScope)
     {
         CommandProcessorBase.ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, base._context.LanguageMode, base.Command.MyInvocation);
     }
 }