Esempio n. 1
0
        protected override void OnExecute()
        {
            if (this.List == true)
            {
                this.CommandContext.Out.Write(this.ScriptContext.GenerateDeclaration(ScriptContextBase.GetArgumentTypes(this.Arguments)));
            }
            else
            {
                var oldPath = Directory.GetCurrentDirectory();
                try
                {
                    DirectoryUtility.Prepare(this.CommandContext.BaseDirectory);
                    Directory.SetCurrentDirectory(this.CommandContext.BaseDirectory);
                    if (this.Filename != string.Empty)
                    {
                        this.Scripts = File.ReadAllText(this.Filename);
                    }

                    var authentication = this.CommandContext.GetAuthenticationInternal(this);
                    if (this.IsAsync == false)
                    {
                        this.ScriptContext.RunInternal(this.Scripts, authentication);
                    }
                    else
                    {
                        this.ScriptContext.RunAsyncInternal(this.Scripts, authentication);
                    }
                }
                finally
                {
                    Directory.SetCurrentDirectory(oldPath);
                }
            }
        }
Esempio n. 2
0
        protected override void OnExecute()
        {
            if (this.List == true)
            {
                this.Out.Write(this.ScriptContext.GenerateDeclaration(ScriptContextBase.GetArgumentTypes(this.Arguments)));
            }
            else
            {
                if (this.Filename != string.Empty)
                {
                    this.Scripts = File.ReadAllText(this.Filename);
                }

                var authentication = this.CommandContext.GetAuthenticationInternal(this);
                if (this.IsAsync == false)
                {
                    this.ScriptContext.RunInternal(this.Scripts, authentication, this.GetProperties());
                }
                else
                {
                    this.ScriptContext.RunAsyncInternal(this.Scripts, authentication, this.GetProperties());
                }
            }
        }