Exemplo n.º 1
0
 private void WriteLine(object value)
 {
     if (value != null && ScriptContextBase.IsDictionaryType(value.GetType()))
     {
         var text = JsonConvert.SerializeObject(value, Formatting.Indented);
         this.Context.Out.WriteLine(text);
     }
     else if (value is System.Dynamic.ExpandoObject exobj)
     {
         var text = JsonConvert.SerializeObject(exobj, Formatting.Indented, new ExpandoObjectConverter());
         this.Context.Out.WriteLine(text);
     }
     else if (value != null && value.GetType().IsArray)
     {
         var text = JsonConvert.SerializeObject(value, Formatting.Indented);
         this.Context.Out.WriteLine(text);
     }
     else if (value is bool b)
     {
         this.Context.Out.WriteLine(b.ToString().ToLower());
     }
     else
     {
         this.Context.Out.WriteLine(value);
     }
 }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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());
                }
            }
        }