当前位置: 首页>>代码示例>>C#>>正文


C# BusConfiguration.UseSerialization方法代码示例

本文整理汇总了C#中BusConfiguration.UseSerialization方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.UseSerialization方法的具体用法?C# BusConfiguration.UseSerialization怎么用?C# BusConfiguration.UseSerialization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BusConfiguration的用法示例。


在下文中一共展示了BusConfiguration.UseSerialization方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllTheSerialization

        public void AllTheSerialization()
        {

            #region ConfigureSerialization

            BusConfiguration busConfiguration = new BusConfiguration();

            busConfiguration.UseSerialization<BinarySerializer>();
            busConfiguration.UseSerialization<BsonSerializer>();
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.UseSerialization<XmlSerializer>();

            #endregion
        }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:14,代码来源:Serialization.cs

示例2: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.FaultTolerance.Client");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press enter to send a message");
            Console.WriteLine("Press any key to exit");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                if (key.Key != ConsoleKey.Enter)
                {
                    return;
                }
                Guid id = Guid.NewGuid();

                bus.Send("Samples.FaultTolerance.Server", new MyMessage
                {
                    Id = id
                });

                Console.WriteLine("Sent a new message with id: {0}", id.ToString("N"));
            }
        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:31,代码来源:Program.cs

示例3: AsyncMain

    static async Task AsyncMain()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.RavenDB.Client");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);

        Console.WriteLine("Press 'enter' to send a StartOrder messages");
        Console.WriteLine("Press any other key to exit");

        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            if (key.Key != ConsoleKey.Enter)
            {
                break;
            }

            Guid orderId = Guid.NewGuid();
            await endpoint.Send(new StartOrder
            {
                OrderId = orderId
            });
            Console.WriteLine("StartOrder Message sent with OrderId  " + orderId);
        }

        await endpoint.Stop();
    }
开发者ID:Diedzz,项目名称:docs.particular.net,代码行数:33,代码来源:Program.cs

示例4: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.DataBus.Sender");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.UseDataBus<FileShareDataBus>().BasePath(BasePath);
        busConfiguration.UsePersistence<InMemoryPersistence>();
        busConfiguration.EnableInstallers();
        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press 'D' to send a databus large message");
            Console.WriteLine("Press 'N' to send a normal large message exceed the size limit and throw");
            Console.WriteLine("Press any other key to exit");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                Console.WriteLine();

                if (key.Key == ConsoleKey.N)
                {
                    SendMessageTooLargePayload(bus);
                    continue;
                }

                if (key.Key == ConsoleKey.D)
                {
                    SendMessageLargePayload(bus);
                    continue;
                }
                return;
            }
        }
    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:34,代码来源:Program.cs

示例5: Main

        static void Main()
        {
            var busConfiguration = new BusConfiguration();
            busConfiguration.EndpointName( "UserInterface" );
        
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.UsePersistence<NHibernatePersistence>();

            busConfiguration.Conventions()
                .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
                .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));

                //TODO: talk about encryption of sensitive data
                //.DefiningEncryptedPropertiesAs(t => t.Name.Equals("Password"));

            if( Environment.UserInteractive && Debugger.IsAttached )
            {
                busConfiguration.EnableInstallers();
            }

            using( var bus = Bus.Create( busConfiguration ).Start() )
            {
                Console.ReadKey();
            }
        }
开发者ID:mauroservienti,项目名称:NServiceBus.POCs.Integration,代码行数:25,代码来源:Program.cs

示例6: Main

    static void Main()
    {
        LogManager.Use<DefaultFactory>()
            .Level(LogLevel.Warn);

        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.ErrorHandling.WithSLR");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.UsePersistence<InMemoryPersistence>();
        busConfiguration.EnableInstallers();
        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press enter to send a message that will throw an exception.");
            Console.WriteLine("Press any key to exit");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                if (key.Key != ConsoleKey.Enter)
                {
                    return;
                }
                MyMessage m = new MyMessage
                {
                    Id = Guid.NewGuid()
                };
                bus.SendLocal(m);
            }
        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:30,代码来源:Program.cs

示例7: AsyncMain

    static async Task AsyncMain()
    {
        using (new RavenHost())
        {
            BusConfiguration busConfiguration = new BusConfiguration();
            busConfiguration.EndpointName("Samples.RavenDBCustomSagaFinder");
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.EnableInstallers();
            busConfiguration.SendFailedMessagesTo("error");

            DocumentStore documentStore = new DocumentStore
            {
                Url = "http://localhost:32076",
                DefaultDatabase = "NServiceBus"
            };
            documentStore.RegisterListener(new UniqueConstraintsStoreListener());
            documentStore.Initialize();

            busConfiguration.UsePersistence<RavenDBPersistence>()
                .DoNotSetupDatabasePermissions() //Only required to simplify the sample setup
                .SetDefaultDocumentStore(documentStore);

            IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
            await endpoint.SendLocal(new StartOrder
            {
                OrderId = "123"
            });

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

            await endpoint.Stop();
        }
    }
开发者ID:Diedzz,项目名称:docs.particular.net,代码行数:34,代码来源:Program.cs

示例8: Run

        public static void Run(
            int maximumNumberOfTweetsPerCatchUp,
            TimeSpan defaultTransactionTimeout,
            string nserviceBusConnectionString,
            string endpointName,
            string consumerKey,
            string consumerSecret,
            string accessToken,
            string accessTokenSecret)
        {
            var busConfiguration = new BusConfiguration();
            busConfiguration.Transactions().DoNotWrapHandlersExecutionInATransactionScope();
            busConfiguration.Transactions().DefaultTimeout(defaultTransactionTimeout);
            busConfiguration.EndpointName(endpointName);
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.EnableInstallers();
            busConfiguration.UsePersistence<NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
            busConfiguration.ApplyMessageConventions();
            busConfiguration.RegisterComponents(c=>c.RegisterSingleton<ITweetService>(
                new TweetService(maximumNumberOfTweetsPerCatchUp, consumerKey, consumerSecret, accessToken, accessTokenSecret)));

            using (Bus.Create(busConfiguration).Start())
            {
                Console.ReadLine();
            }
        }
开发者ID:adamralph,项目名称:HashBus,代码行数:26,代码来源:App.cs

示例9: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.FullDuplex.Client");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.UsePersistence<InMemoryPersistence>();
        busConfiguration.EnableInstallers();

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press 'Enter' to send a message.To exit, Ctrl + C");

            #region ClientLoop

            while (Console.ReadLine() != null)
            {
                Guid g = Guid.NewGuid();
                Console.WriteLine("Requesting to get data by id: {0}", g.ToString("N"));

                RequestDataMessage message = new RequestDataMessage
                                             {
                                                 DataId = g,
                                                 String = "<node>it's my \"node\" & i like it<node>"
                                             };
                bus.Send("Samples.FullDuplex.Server", message);
            }

            #endregion
        }
    }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:30,代码来源:Program.cs

示例10: Init

        public static void Init()
        {
            if (Bus != null)
            return;

              lock (SyncLock)
              {
            if (Bus != null)
              return;
            var cfg = new BusConfiguration();

            cfg.EndpointName(MethodBase.GetCurrentMethod().DeclaringType.Namespace);
            cfg.UseTransport<MsmqTransport>();
            cfg.UsePersistence<InMemoryPersistence>();
            cfg.EnableInstallers();
            cfg.UseSerialization<JsonSerializer>();

            cfg.Conventions()
               .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Messages"))
               .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
               .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));

            Bus = NServiceBus.Bus.Create(cfg).Start();
              }
        }
开发者ID:rioka,项目名称:NsbServiceHostBasedGateway,代码行数:25,代码来源:ServiceBus.cs

示例11: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.FaultTolerance.Client");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press 'Enter' to send a message.To exit, Ctrl + C");

            while (Console.ReadLine() != null)
            {
                Guid id = Guid.NewGuid();

                bus.Send("Samples.FaultTolerance.Server", new MyMessage
                {
                    Id = id
                });

                Console.WriteLine("Sent a new message with id: {0}", id.ToString("N"));
            }

        }
    }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:26,代码来源:Program.cs

示例12: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.StepByStep.Server");
        busConfiguration.UseSerialization<JsonSerializer>();
        /*
         * JSON
         * XML
         * Binary
         */

        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        /*
         * InMemory
         * MSMQ
         * RavenDB
         * NHibernate
         * Azure Storage
         */
        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
开发者ID:karol1990,项目名称:NServiceBus,代码行数:27,代码来源:Program.cs

示例13: Main

    static void Main()
    {
        #region EndpointConfiguration
        BusConfiguration busConfiguration = new BusConfiguration();

        busConfiguration.UseTransport<SqlServerTransport>()
            .ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=samples;Integrated Security=True");
        busConfiguration.EndpointName("Samples.SqlServer.NativeIntegration");
        busConfiguration.UseSerialization<JsonSerializer>();
        #endregion
        busConfiguration.UsePersistence<InMemoryPersistence>();

        using (Bus.Create(busConfiguration).Start())
        {

            Console.WriteLine("Press enter to send a message");
            Console.WriteLine("Press any key to exit");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                Console.WriteLine();

                if (key.Key != ConsoleKey.Enter)
                {
                    return;
                }
                PlaceOrder();

            }

        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:33,代码来源:Program.cs

示例14: AsyncMain

    static async Task AsyncMain()
    {
        #region ConfigureLogging
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.Logging.Default");
        //Note that no config is required in version 5 and higher since logging is enabled by default
        #endregion
        busConfiguration.SendFailedMessagesTo("error");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
        try
        {
            IBusSession busSession = endpoint.CreateBusSession();
            await busSession.SendLocal(new MyMessage());
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:25,代码来源:Program.cs

示例15: AsyncMain

    static async Task AsyncMain()
    {
        #region logging
        DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
        defaultFactory.Level(LogLevel.Fatal);
        #endregion
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.Logging.Default");
        busConfiguration.SendFailedMessagesTo("error");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence<InMemoryPersistence>();

        IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
        try
        {
            await endpoint.SendLocal(new MyMessage());
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:25,代码来源:Program.cs


注:本文中的BusConfiguration.UseSerialization方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。