Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddMediatR(typeof(Startup));
            services.AddMvc();

            #region Repository
            services.AddSingleton <IGroupRepository, GroupRepository>();
            services.AddSingleton <IPersonRepository, PersonRepository>();
            services.AddSingleton <IMessageRepository, MessageRepository>();
            #endregion

            #region AutoMapper
            MapperConfiguration mapperConfig = new MapperConfiguration(a => { a.AddProfile(new MappingProfile()); });
            IMapper             mapper       = mapperConfig.CreateMapper();
            services.AddSingleton(mapper);
            #endregion

            #region Swagger
            services.AddSwaggerGen(a =>
            {
                a.SwaggerDoc(SwaggerHelper.Version, SwaggerHelper.GetOpenApiInfo());
                //a.IncludeXmlComments(SwaggerHelper.GetXmlComments());
            });
            #endregion
        }