예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddControllersWithViews()
            .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);

            services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(LogProvider.CreateLogger(Configuration)));

            services.AddSignalR();

            services.AddMemoryCache();

            services.AddMassTransit(x =>
            {
                x.AddSignalRHub <SignalRHub>();

                x.UsingRabbitMq((ctx, cfg) =>
                {
                    cfg.Durable        = false;
                    cfg.AutoDelete     = true;
                    cfg.PurgeOnStartup = true;

                    cfg.Host($"rabbitmq://{Configuration["Lyzo_RabbitMq"]}");

                    cfg.ConfigureEndpoints(ctx);
                });
            });

            if (_isDevelopmentEnvironment)
            {
                services.AddDataProtection()
                .SetApplicationName("Lyzo")
                .PersistKeysToFileSystem(new DirectoryInfo("/keys/storage"));
            }
            else
            {
                //services.AddDataProtection()
                //	.PersistKeysToAzureBlobStorage(Configuration["CloudStorageAccountConnectionString"], "dataprotection", "keys")
                //	.ProtectKeysWithAzureKeyVault(new Uri("https://picro.vault.azure.net/"), new DefaultAzureCredential());
            }
        }