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


C# EndpointConfiguration.UseSerialization方法代码示例

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


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

示例1: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.RavenDBCustomSagaFinder";
        using (new RavenHost())
        {
            EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.RavenDBCustomSagaFinder");
            endpointConfiguration.UseSerialization<JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.SendFailedMessagesTo("error");

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

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

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

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

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

示例2: Application_Start

    protected void Application_Start()
    {
        #region ApplicationStart

        ContainerBuilder builder = new ContainerBuilder();

        // Register MVC controllers.
        builder.RegisterControllers(typeof(MvcApplication).Assembly);

        // Set the dependency resolver to be Autofac.
        IContainer container = builder.Build();

        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.MvcInjection.WebApplication");
        // instruct NServiceBus to use a custom AutoFac configuration
        endpointConfiguration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");

        endpoint = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

        ContainerBuilder updater = new ContainerBuilder();
        updater.RegisterInstance(endpoint);
        updater.Update(container);

        DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);

        #endregion
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:33,代码来源:Global.asax.cs

示例3: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.MessageMutators";
        var endpointConfiguration = new EndpointConfiguration("Samples.MessageMutators");
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.SendFailedMessagesTo("error");

        #region ComponentRegistartion
        endpointConfiguration.RegisterComponents(components =>
        {
            components.ConfigureComponent<ValidationMessageMutator>(DependencyLifecycle.InstancePerCall);
            components.ConfigureComponent<TransportMessageCompressionMutator>(DependencyLifecycle.InstancePerCall);
        });
        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        try
        {
            await Runner.Run(endpointInstance)
                .ConfigureAwait(false);
        }
        finally
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:29,代码来源:Program.cs

示例4: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.StructureMap";
        #region ContainerConfiguration
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.StructureMap");
        Container container = new Container(x => x.For<MyService>().Use(new MyService()));
        endpointConfiguration.UseContainer<StructureMapBuilder>(c => c.ExistingContainer(container));
        #endregion
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            await endpoint.SendLocal(new MyMessage());
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

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

示例5: AsyncMain

    static async Task AsyncMain()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration();
        endpointConfiguration.EndpointName("Samples.WcfCallbacks");
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");

        #region startbus


        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            using (StartWcfHost(endpoint))
            {
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }
        finally
        {
            await endpoint.Stop();
        }

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

示例6: Start

    static async Task Start()
    {
        Console.Title = "Samples.Ninject";
        #region ContainerConfiguration
        var endpointConfiguration = new EndpointConfiguration("Samples.Ninject");
        endpointConfiguration.SendFailedMessagesTo("error");

        var kernel = new StandardKernel();
        kernel.Bind<MyService>().ToConstant(new MyService());
        endpointConfiguration.UseContainer<NinjectBuilder>(c => c.ExistingKernel(kernel));
        #endregion
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();


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

        try
        {
            var myMessage = new MyMessage();
            await endpointInstance.SendLocal(myMessage)
                .ConfigureAwait(false);

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally 
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:34,代码来源:Program.cs

示例7: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.Unity";
        #region ContainerConfiguration
        var endpointConfiguration = new EndpointConfiguration("Samples.Unity");
        var container = new UnityContainer();
        container.RegisterInstance(new MyService());
        endpointConfiguration.UseContainer<UnityBuilder>(c => c.UseExistingContainer(container));
        #endregion
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        try
        {
            var myMessage = new MyMessage();
            await endpointInstance.SendLocal(myMessage)
                .ConfigureAwait(false);
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:30,代码来源:Program.cs

示例8: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.AzureBlobStorageDataBus.Sender";
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.AzureBlobStorageDataBus.Sender");
        endpointConfiguration.UseSerialization<JsonSerializer>();

        #region ConfiguringDataBusLocation

        endpointConfiguration.UseDataBus<AzureDataBus>()
            .ConnectionString("UseDevelopmentStorage=true");

        #endregion

        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            await Run(endpoint);
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:27,代码来源:Program.cs

示例9: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.RavenDB.Migration";
        #region registerConverter
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.RavenDB.Migration");
        DocumentStore documentStore = new DocumentStore
        {
            Url = "http://localhost:8083",
            DefaultDatabase = "RavenSampleData",
        };
        documentStore.Listeners.RegisterListener(new CustomDocumentConverter());
        documentStore.Initialize();

        var persistence = endpointConfiguration.UsePersistence<RavenDBPersistence>();
        persistence.DoNotSetupDatabasePermissions(); //Only required to simplify the sample setup
        persistence.SetDefaultDocumentStore(documentStore);
        #endregion


        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.EnableInstallers();

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            Console.WriteLine("Press 'S' to start reset the saga");
            Console.WriteLine("Press 'I' to increment the order count");
            Console.WriteLine("Press any other key to exit");

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

                if (key.Key == ConsoleKey.S)
                {
                    await endpoint.SendLocal(new StartOrder
                    {
                        OrderId = 10,
                        ItemCount = 5
                    });
                    continue;
                }

                if (key.Key == ConsoleKey.I)
                {
                    await endpoint.SendLocal(new IncrementOrder
                    {
                        OrderId = 10,
                    });
                    continue;
                }
                return;
            }
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:60,代码来源:Program.cs

示例10: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.UsernameHeader.Endpoint1";
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.UsernameHeader.Endpoint1");
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.SendFailedMessagesTo("error");
        
        #region ComponentRegistartion
        endpointConfiguration.RegisterComponents(components =>
        {
            components.ConfigureComponent<UsernameMutator>(DependencyLifecycle.InstancePerCall);
        });
        #endregion

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            #region SendMessage
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("FakeUser"), new string[0]);
            await endpoint.Send("Samples.UsernameHeader.Endpoint2", new MyMessage());
            #endregion
            Console.WriteLine("Message sent. Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:30,代码来源:Program.cs

示例11: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.RavenDB.Server";
        using (new RavenHost())
        {
            #region Config

            EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.RavenDB.Server");
            DocumentStore documentStore = new DocumentStore
            {
                Url = "http://localhost:32076",
                DefaultDatabase = "RavenSampleData"
            };
            documentStore.Initialize();

            var persistence = endpointConfiguration.UsePersistence<RavenDBPersistence>();
            persistence.DoNotSetupDatabasePermissions(); //Only required to simplify the sample setup
            persistence.SetDefaultDocumentStore(documentStore);

            #endregion

            endpointConfiguration.SendFailedMessagesTo("error");
            endpointConfiguration.UseSerialization<JsonSerializer>();
            endpointConfiguration.EnableInstallers();

            IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);

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

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

示例12: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.PubSub.Subscriber2";
        LogManager.Use<DefaultFactory>().Level(LogLevel.Info);
        var endpointConfiguration = new EndpointConfiguration("Samples.PubSub.Subscriber2");
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.DisableFeature<AutoSubscribe>();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.EnableInstallers();

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        try
        {
            await endpointInstance.Subscribe<IMyEvent>()
                .ConfigureAwait(false);
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
            await endpointInstance.Unsubscribe<IMyEvent>()
                .ConfigureAwait(false);
        }
        finally
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:28,代码来源:Program.cs

示例13: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.MessageDurability.Sender";
        #region non-transactional

        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.MessageDurability.Sender");
        endpointConfiguration.UseTransport<MsmqTransport>()
            .Transactions(TransportTransactionMode.None);

        #endregion

        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.SendFailedMessagesTo("error");

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

示例14: GetConfiguration

        public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, IConfigurationSource configSource, Action<EndpointConfiguration> configurationBuilderCustomization)
        {
            var settings = runDescriptor.Settings;

            var types = endpointConfiguration.GetTypesScopedByTestClass();

            typesToInclude.AddRange(types);

            var builder = new EndpointConfiguration(endpointConfiguration.EndpointName);

            builder.TypesToIncludeInScan(typesToInclude);
            builder.CustomConfigurationSource(configSource);
            builder.EnableInstallers();

            builder.DisableFeature<TimeoutManager>();
            builder.Recoverability().Delayed(cfg => cfg.NumberOfRetries(0));
            builder.Recoverability().Immediate(cfg => cfg.NumberOfRetries(0));

            await builder.DefineTransport(settings, endpointConfiguration.EndpointName).ConfigureAwait(false);

            builder.DefineBuilder(settings);
            builder.RegisterComponentsAndInheritanceHierarchy(runDescriptor);

            Type serializerType;
            if (settings.TryGet("Serializer", out serializerType))
            {
                builder.UseSerialization((SerializationDefinition) Activator.CreateInstance(serializerType));
            }
            await builder.DefinePersistence(settings, endpointConfiguration.EndpointName).ConfigureAwait(false);

            builder.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true);
            configurationBuilderCustomization(builder);

            return builder;
        }
开发者ID:Particular,项目名称:ServiceControl.Plugin.Nsb6.Heartbeat,代码行数:35,代码来源:DefaultServer.cs

示例15: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.Logging.CustomFactory";
        #region ConfigureLogging

        var loggerDefinition = LogManager.Use<ConsoleLoggerDefinition>();

        // optionally set the log level in code or read from app.config
        loggerDefinition.Level(LogLevel.Info);

        // logging configuration should occur prior to endpoint configuration
        var endpointConfiguration = new EndpointConfiguration("Samples.Logging.CustomFactory");

        #endregion
        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.UseSerialization<JsonSerializer>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        try
        {
            var myMessage = new MyMessage();
            await endpointInstance.SendLocal(myMessage)
                .ConfigureAwait(false);
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:35,代码来源:Program.cs


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