private static void InitImpl() { ArgPipelineObjectMapper.CurrentMapper = new JObjectArgPipelineMapper(); PipelineOutputFormatter.RegisterFormatter(typeof(JObject), FuncPipelineOutputFormatter.Create((obj) => { JObject jObj = (JObject)obj; ConsoleTableBuilder builder = new ConsoleTableBuilder(); List <ConsoleString> headers = new List <ConsoleString>() { new ConsoleString("PROPERTY", ConsoleColor.Yellow), new ConsoleString("VALUE", ConsoleColor.Yellow) }; List <List <ConsoleString> > rows = new List <List <ConsoleString> >(); foreach (var prop in jObj.Properties()) { rows.Add(new List <ConsoleString>() { new ConsoleString(prop.Name, ConsoleColor.Gray), new ConsoleString("" + prop.Value, ConsoleColor.Green) }); } var jObjRet = builder.FormatAsTable(headers, rows); jObjRet = new ConsoleString("Pipeline output of type JObject: \n") + jObjRet; return(jObjRet); })); }
/// <summary> /// Use this method to push an object to the given pipeline stage's next stage. You should only use this /// for advanced scenarios where you're processing objects on a thread that was not created for you by /// PowerArgs. If you're doing that and find the need to use this method, cool :). /// </summary> /// <param name="o">The object to push</param> /// <param name="current">The current pipeline stage. The object is pushed to the next stage.</param> public static void Push(object o, PipelineStage current) { if (o == null) { if (ConsoleOutInterceptor.Instance.IsInitialized) { return; } ConsoleString.WriteLine("null object pushed through the pipeline", ConsoleColor.Yellow); } else if (current != null && current.NextStage != null && current.Manager != null) { current.Manager.Push(o, current); } else { ArgPipeline.FireObjectExited(o); if (ConsoleOutInterceptor.Instance.IsInitialized) { return; } PipelineOutputFormatter.Format(o).WriteLine(); } }