Exemplo n.º 1
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Serialization.TransitionPhase3";
        var endpointConfiguration = new EndpointConfiguration("Samples.Serialization.TransitionPhase3");

        endpointConfiguration.SharedConfig();

        #region Phase3

        var settingsV2 = new JsonSerializerSettings
        {
            Formatting       = Formatting.Indented,
            ContractResolver = new ExtendedResolver()
        };
        var serializationV2 = endpointConfiguration.UseSerialization <NewtonsoftSerializer>();
        serializationV2.Settings(settingsV2);
        serializationV2.ContentTypeKey("jsonv2");

        var settingsV1 = new JsonSerializerSettings
        {
            Formatting = Formatting.Indented
        };
        var serializationV1 = endpointConfiguration.AddDeserializer <NewtonsoftSerializer>();
        serializationV1.Settings(settingsV1);
        serializationV1.ContentTypeKey("jsonv1");

        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        try
        {
            #region send-to-both
            var message = MessageCreator.NewOrder();
            await endpointInstance.SendLocal(message)
            .ConfigureAwait(false);

            await endpointInstance.Send("Samples.Serialization.TransitionPhase2", message)
            .ConfigureAwait(false);

            await endpointInstance.Send("Samples.Serialization.TransitionPhase4", message)
            .ConfigureAwait(false);

            #endregion
            Console.WriteLine("Order Sent");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpointInstance.Stop()
            .ConfigureAwait(false);
        }
    }
Exemplo n.º 2
0
    static async Task Main()
    {
        //required to prevent possible occurrence of .NET Core issue https://github.com/dotnet/coreclr/issues/12668
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");

        Console.Title = "Samples.Serialization.TransitionPhase3";
        var endpointConfiguration = new EndpointConfiguration("Samples.Serialization.TransitionPhase3");

        endpointConfiguration.SharedConfig();

        #region Phase3

        var settingsV2 = new JsonSerializerSettings
        {
            Formatting       = Formatting.Indented,
            ContractResolver = new ExtendedResolver()
        };
        var serializationV2 = endpointConfiguration.UseSerialization <NewtonsoftSerializer>();
        serializationV2.Settings(settingsV2);
        serializationV2.ContentTypeKey("jsonv2");

        var settingsV1 = new JsonSerializerSettings
        {
            Formatting = Formatting.Indented
        };
        var serializationV1 = endpointConfiguration.AddDeserializer <NewtonsoftSerializer>();
        serializationV1.Settings(settingsV1);
        serializationV1.ContentTypeKey("jsonv1");

        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        #region send-to-both
        var message = MessageCreator.NewOrder();
        await endpointInstance.SendLocal(message)
        .ConfigureAwait(false);

        await endpointInstance.Send("Samples.Serialization.TransitionPhase2", message)
        .ConfigureAwait(false);

        await endpointInstance.Send("Samples.Serialization.TransitionPhase4", message)
        .ConfigureAwait(false);

        #endregion
        Console.WriteLine("Order Sent");
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
Exemplo n.º 3
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Serialization.TransitionPhase1";

        var endpointConfiguration = new EndpointConfiguration("Samples.Serialization.TransitionPhase1");

        endpointConfiguration.SharedConfig();

        #region Phase1

        var settingsV1 = new JsonSerializerSettings
        {
            Formatting = Formatting.Indented
        };
        var serializationV1 = endpointConfiguration.UseSerialization <NewtonsoftSerializer>();
        serializationV1.Settings(settingsV1);
        serializationV1.ContentTypeKey("jsonv1");

        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        var message = MessageCreator.NewOrder();
        await endpointInstance.SendLocal(message)
        .ConfigureAwait(false);

        await endpointInstance.Send("Samples.Serialization.TransitionPhase2", message)
        .ConfigureAwait(false);

        Console.WriteLine("Order Sent");
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }