private void BindOnPremiseFileContainer(IServiceCollection services)
        {
            OnPremiseConfiguration onPremiseConfiguration = Configuration.GetOnPremiseConfiguration();

            services.BindOnPremiseFileContainer(onPremiseConfiguration);
        }
Exemple #2
0
        /// <summary>
        /// Bind all filecontainer which are located to traingingsdata-path.
        /// </summary>
        /// <param name="services">Current context of services</param>
        /// <param name="onPremiseConfiguration">Configuration for on premise file containers</param>
        public static void BindOnPremiseFileContainer(this IServiceCollection services, OnPremiseConfiguration onPremiseConfiguration)
        {
            #region validation

            if (onPremiseConfiguration == null)
            {
                throw new ArgumentNullException(nameof(onPremiseConfiguration));
            }

            #endregion

            services.BindSystemFileDataStore(EDataStoreType.TrainingData, onPremiseConfiguration.TrainingDataDirectoryPath);
        }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            OnPremiseConfiguration onPremiseConfiguration = Configuration.GetOnPremiseConfiguration();

            services.BindOnPremiseFileContainer(onPremiseConfiguration);

            ImagePathUtil.ValidImageExtensions = new List <string>()
            {
                ".png", ".jpg", ".jpeg"
            };

            services.BindRepositories();
            services.BindServices();

            // accessor to use httpcontext inside of methods
            services.AddHttpContextAccessor();

            services.AddMvc(options =>
            {
                options.CacheProfiles.Add(CacheProfileNames.Default,
                                          new CacheProfile()
                {
                    Duration = 60
                });
                options.CacheProfiles.Add(CacheProfileNames.Never,
                                          new CacheProfile()
                {
                    Location = ResponseCacheLocation.None,
                    NoStore  = true
                });
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc(APPLICATION_VERSION, new Swashbuckle.AspNetCore.Swagger.Info()
                {
                    Title       = APPLICATION_NAME,
                    Version     = APPLICATION_VERSION,
                    Description = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()
                });

                //c.OperationFilter<FormFileOperationFilter>();

                // Set the comments path for the Swagger JSON and UI.
                string xmlPath = Path.Combine(AppContext.BaseDirectory, "Documentation", "Rcv.LabelTool.Backend.xml");
                c.IncludeXmlComments(xmlPath);

                c.DescribeAllEnumsAsStrings();
            });

            // add CORS rules
            services.AddCors(options =>
            {
                options.AddPolicy(CORS_POLICY_NAME, builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });
        }