Ejemplo n.º 1
0
    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");
    }
Ejemplo n.º 2
0
    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 Task FromStreamAsync(int iteration)
    {
        var jilStreamAsync            = JilHelper.ToStream(_testModel);
        var messagePackStreamAsync    = MessagePackHelper.ToStream(_testModel);
        var msgPackStreamAsync        = MsgPackHelper.ToStream(_testModel);
        var newtonsoftJsonStreamAsync = NewtonsoftJsonHelper.ToStream(_testModel);
        var systemTextJsonStreamAsync = SystemTextJsonHelper.ToStream(_testModel);
        var utf8JsonStreamAsync       = Utf8JsonHelper.ToStream(_testModel);

        Console.WriteLine("FromStreamAsync go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("JilHelper FromStreamAsync", iteration,
                                      async() => await JilHelper.FromStreamAsync <TestModel>(jilStreamAsync)));
        Console.WriteLine(Runner.Time("MessagePackHelper FromStreamAsync", iteration,
                                      async() => await MessagePackHelper.FromStreamAsync <TestModel>(messagePackStreamAsync)));
        Console.WriteLine(Runner.Time("MsgPackHelper FromStreamAsync", iteration,
                                      async() => await MsgPackHelper.FromStreamAsync <TestModel>(msgPackStreamAsync)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromStreamAsync", iteration,
                                      async() => await NewtonsoftJsonHelper.FromStreamAsync <TestModel>(newtonsoftJsonStreamAsync)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper FromStreamAsync", iteration,
                                      async() => await SystemTextJsonHelper.FromStreamAsync <TestModel>(systemTextJsonStreamAsync)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper FromStreamAsync", iteration,
                                      async() => await Utf8JsonHelper.FromStreamAsync <TestModel>(utf8JsonStreamAsync)));

        Console.WriteLine("\r\nFromStreamAsync complete!\r\n");

        return(Task.CompletedTask);
    }
Ejemplo n.º 4
0
    public void FromStream(int iteration)
    {
#pragma warning disable CS0618
        var binaryStream = BinaryHelper.ToStream(_testModel);
#pragma warning restore CS0618
        var dataContractStream   = DataContractHelper.ToStream(_testModel);
        var jilStream            = JilHelper.ToStream(_testModel);
        var messagePackStream    = MessagePackHelper.ToStream(_testModel);
        var msgPackStream        = MsgPackHelper.ToStream(_testModel);
        var newtonsoftJsonStream = NewtonsoftJsonHelper.ToStream(_testModel);
        var protobufStream       = ProtobufHelper.ToStream(_testModel);
        var sharpYamlStream      = SharpYamlHelper.ToStream(_testModel);
        var systemTextJsonStream = SystemTextJsonHelper.ToStream(_testModel);
        var utf8JsonStream       = Utf8JsonHelper.ToStream(_testModel);
        var xmlStream            = XmlHelper.ToStream(_testModel);
        var yamlDotNetStream     = YamlDotNetHelper.ToStream(_testModel);
        var zeroFormatterStream  = ZeroFormatterHelper.ToStream(_testModel);

        Console.WriteLine("FromStream go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("BinaryHelper FromStream", iteration,
#pragma warning disable CS0618
                                      () => BinaryHelper.FromStream <TestModel>(binaryStream)));
#pragma warning restore CS0618
        Console.WriteLine(Runner.Time("DataContractHelper FromStream", iteration,
                                      () => DataContractHelper.FromStream <TestModel>(dataContractStream)));
        Console.WriteLine(Runner.Time("JilHelper FromStream", iteration,
                                      () => JilHelper.FromStream <TestModel>(jilStream)));
        Console.WriteLine(Runner.Time("MessagePackHelper FromStream", iteration,
                                      () => MessagePackHelper.FromStream <TestModel>(messagePackStream)));
        Console.WriteLine(Runner.Time("MsgPackHelper FromStream", iteration,
                                      () => MsgPackHelper.FromStream <TestModel>(msgPackStream)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromStream", iteration,
                                      () => NewtonsoftJsonHelper.FromStream <TestModel>(newtonsoftJsonStream)));
        Console.WriteLine(Runner.Time("ProtobufHelper FromStream", iteration,
                                      () => ProtobufHelper.FromStream <TestModel>(protobufStream)));
        Console.WriteLine(Runner.Time("SharpYamlHelper FromStream", iteration,
                                      () => SharpYamlHelper.FromStream <TestModel>(sharpYamlStream)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper FromStream", iteration,
                                      () => SystemTextJsonHelper.FromStream <TestModel>(systemTextJsonStream)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper FromStream", iteration,
                                      () => Utf8JsonHelper.FromStream <TestModel>(utf8JsonStream)));
        Console.WriteLine(Runner.Time("XmlHelper FromStream", iteration,
                                      () => XmlHelper.FromStream <TestModel>(xmlStream)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper FromStream", iteration,
                                      () => YamlDotNetHelper.FromStream <TestModel>(yamlDotNetStream)));
        Console.WriteLine(Runner.Time("ZeroFormatterHelper FromStream", iteration,
                                      () => ZeroFormatterHelper.FromStream <TestModel>(zeroFormatterStream)));

        Console.WriteLine("\r\nFromStream complete!\r\n");
    }
Ejemplo n.º 5
0
    public void ToStream(int iteration)
    {
        Console.WriteLine("ToStream go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("BinaryHelper ToStream", iteration,
#pragma warning disable CS0618
                                      () => BinaryHelper.ToStream(_testModel)));
#pragma warning restore CS0618
        Console.WriteLine(Runner.Time("DataContractHelper ToStream", iteration,
                                      () => DataContractHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("JilHelper ToStream", iteration,
                                      () => JilHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("MessagePackHelper ToStream", iteration,
                                      () => MessagePackHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("MsgPackHelper ToStream", iteration,
                                      () => MsgPackHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper ToStream", iteration,
                                      () => NewtonsoftJsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("ProtobufHelper ToStream", iteration,
                                      () => ProtobufHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("SharpYamlHelper ToStream", iteration,
                                      () => SharpYamlHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper ToStream", iteration,
                                      () => SystemTextJsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper ToStream", iteration,
                                      () => Utf8JsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("XmlHelper ToStream", iteration,
                                      () => XmlHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper ToStream", iteration,
                                      () => YamlDotNetHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("ZeroFormatterHelper ToStream", iteration,
                                      () => ZeroFormatterHelper.ToStream(_testModel)));

        Console.WriteLine("\r\nToStream complete!\r\n");
    }
Ejemplo n.º 6
0
 public static Task PackByAsync(this Stream?stream, Type type, object?value,
                                IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.PackAsync(type, value, stream, resolver);
Ejemplo n.º 7
0
 public static Task PackByAsync <TValue>(this Stream?stream, TValue?value,
                                         IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.PackAsync(value, stream, resolver);
Ejemplo n.º 8
0
 public static object?FromJson(this string?json, Type type, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromJson(type, json, resolver);
Ejemplo n.º 9
0
 public static TValue?FromJson <TValue>(this string?json, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromJson <TValue>(json, resolver);
 public static TValue?FromBytes <TValue>(this byte[]?bytes, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromBytes <TValue>(bytes, resolver);
Ejemplo n.º 11
0
 public static void PackTo(this object?value, Stream?stream, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.Pack(value, stream, resolver);
Ejemplo n.º 12
0
 public static Task PackToAsync(this object?value, Stream?stream,
                                IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.PackAsync(value, stream, resolver);
 public static byte[] ToBytes(this object?value, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.ToBytes(value, resolver);
 public static MemoryStream ToStream(this object?value, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.ToStream(value, resolver);
 public static void PackBy <TValue>(this Stream?stream, TValue?value, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.Pack(value, stream, resolver);
Ejemplo n.º 16
0
 public static TValue?FromStream <TValue>(this Stream?stream, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromStream <TValue>(stream, resolver);
Ejemplo n.º 17
0
 public static object?FromStream(this Stream?stream, Type type, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromStream(type, stream, resolver);
Ejemplo n.º 18
0
 public static string ToJson <TValue>(this TValue?value, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.ToJson(value, resolver);
 public static object?FromBytes(this byte[]?bytes, Type type, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.FromBytes(type, bytes, resolver);
Ejemplo n.º 20
0
 public static string ToJson(this object?value, IJsonFormatterResolver?resolver = null) =>
 Utf8JsonHelper.ToJson(value, resolver);