Пример #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)
        {
            //mvc registeration
            services.AddMvc();

            ServiceSettings.InitializeSettings(Configuration);


            //Swagger registeration
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc(ApiVersion, new Info
                {
                    Version        = ApiVersion,
                    Title          = ServiceName,
                    Description    = ServiceTitle,
                    TermsOfService = "None",
                    Contact        = new Contact
                    {
                        Name  = "Emre Ergüden",
                        Email = "*****@*****.**"
                    },
                    License = new License()
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
                c.OperationFilter <AuthorizationHeaderFilter>();
            });

            //controllers' services
            services.AddSingleton <IClassworkService>(new ClassworkService());
            services.AddSingleton <ICommonService>(new CommonService());

            //Simualation of client services that consumes apis
            services.AddSingleton <IClassworkClientService>(new ClassworkClientService());
        }