Ejemplo n.º 1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o => o.AddPolicy("OrbitalPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddMvc()
            .AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new OpenApiJsonConverter()); })
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <MetadataInfoValidator>())
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddMemoryCache();
            services.AddMediatR(typeof(Startup).Assembly);

            services.AddSingleton <IAssertFactory, AssertFactory>();
            services.AddSingleton <IRuleMatcher, RuleMatcher>();
            services.AddSingleton <IPipeline <MessageProcessorInput, Task <MockResponse> > >(s =>
            {
                var processor = new MockServerProcessor(new AssertFactory(), new RuleMatcher(), ConfigureTemplateContext());
                processor.Start();
                return(processor);
            });
            services.AddSingleton <CommonData>();

            ApiVersionRegistration.ConfigureService(services);
            SwaggerRegistration.ConfigureService(services);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Compliance on the requirement of allegro using authorization, logging and Swagger.
 /// </summary>
 /// <param name="configuration">parameter provided in the startup</param>
 public WebApiRegistration(IConfiguration configuration)
 {
     _configuration       = configuration;
     _swaggerRegistration = SwaggerRegistration();
     _authentication      = new AuthenticationManager();
 }