コード例 #1
0
        public static IServiceCollection ConfigureHttpServices(this IServiceCollection services)
        {
            services.AddTransient <LiGetCompatibilityOptions, LiGetCompatibilityOptions>(provider =>
                                                                                         provider
                                                                                         .GetRequiredService <IOptions <BaGetOptions> >()
                                                                                         .Value
                                                                                         .LiGetCompat
                                                                                         );

            services.AddSingleton <IEdmModel>(provider => {
                var odataModelBuilder = new NuGetWebApiODataModelBuilder();
                odataModelBuilder.Build();
                return(odataModelBuilder.Model);
            });
            services.AddTransient <IODataPackageSerializer, ODataPackageSerializer>();

            AddCarter(services);
            services.AddCors();
            services.AddSingleton <IConfigureOptions <CorsOptions>, ConfigureCorsOptions>();

            services.Configure <ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;

                // Do not restrict to local network/proxy
                options.KnownNetworks.Clear();
                options.KnownProxies.Clear();
            });

            return(services);
        }
コード例 #2
0
        protected override PackagesODataController CreateController()
        {
            repo = new Mock <IMirroringPackageRepository>();

            var builder = new NuGetWebApiODataModelBuilder();

            builder.Build();

            model = builder.Model;

            return(new PackagesODataController {
                Repository = repo.Object
            });
        }