public void ToText(int iteration) { Console.WriteLine("ToText go!"); Runner.Initialize(); Console.WriteLine(Runner.Time("DataContractHelper ToText", iteration, () => DataContractHelper.ToXml(_testModel))); Console.WriteLine(Runner.Time("JilHelper ToText", iteration, () => JilHelper.ToJson(_testModel))); Console.WriteLine(Runner.Time("NewtonsoftJsonHelper ToText", iteration, () => NewtonsoftJsonHelper.ToJson(_testModel))); Console.WriteLine(Runner.Time("SharpYamlHelper ToText", iteration, () => SharpYamlHelper.ToYaml(_testModel))); Console.WriteLine(Runner.Time("SystemTextJsonHelper ToText", iteration, () => SystemTextJsonHelper.ToJson(_testModel))); Console.WriteLine(Runner.Time("Utf8JsonHelper ToText", iteration, () => Utf8JsonHelper.ToJson(_testModel))); Console.WriteLine(Runner.Time("XmlHelper ToText", iteration, () => XmlHelper.ToXml(_testModel))); Console.WriteLine(Runner.Time("YamlDotNetHelper ToText", iteration, () => YamlDotNetHelper.ToYaml(_testModel))); Console.WriteLine("\r\nToText complete!\r\n"); }
public void FromText(int iteration) { var dataContractXml = DataContractHelper.ToXml(_testModel); var jilJson = JilHelper.ToJson(_testModel); var newtonsoftJsonJson = NewtonsoftJsonHelper.ToJson(_testModel); var sharpYamlText = SharpYamlHelper.ToYaml(_testModel); var systemTextJsonJson = SystemTextJsonHelper.ToJson(_testModel); var utf8JsonJson = Utf8JsonHelper.ToJson(_testModel); var xml = XmlHelper.ToXml(_testModel); var yamlDotNetText = YamlDotNetHelper.ToYaml(_testModel); Console.WriteLine("FromText go!"); Runner.Initialize(); Console.WriteLine(Runner.Time("DataContractHelper FromText", iteration, () => DataContractHelper.FromXml <TestModel>(dataContractXml))); Console.WriteLine(Runner.Time("JilHelper FromText", iteration, () => JilHelper.FromJson <TestModel>(jilJson))); Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromText", iteration, () => NewtonsoftJsonHelper.FromJson <TestModel>(newtonsoftJsonJson))); Console.WriteLine(Runner.Time("SharpYamlHelper FromText", iteration, () => SharpYamlHelper.FromYaml <TestModel>(sharpYamlText))); Console.WriteLine(Runner.Time("SystemTextJsonHelper FromText", iteration, () => SystemTextJsonHelper.FromJson <TestModel>(systemTextJsonJson))); Console.WriteLine(Runner.Time("Utf8JsonHelper FromText", iteration, () => Utf8JsonHelper.FromJson <TestModel>(utf8JsonJson))); Console.WriteLine(Runner.Time("XmlHelper FromText", iteration, () => XmlHelper.FromXml <TestModel>(xml))); Console.WriteLine(Runner.Time("YamlDotNetHelper FromText", iteration, () => YamlDotNetHelper.FromYaml <TestModel>(yamlDotNetText))); Console.WriteLine("\r\nFromText complete!\r\n"); }
public static string ToXml(this object?value, Type type) => DataContractHelper.ToXml(type, value);
public static string ToXml <TValue>(this TValue?value) => DataContractHelper.ToXml(value);