public ExceptionHandler(RequestDelegate next, IContentTypeResolver contentTypeResolver,
                         IExceptionToHttpStatusCodeParser exceptionToHttpStatusCodeParser)
 {
     _next = next;
     _contentTypeResolver             = contentTypeResolver;
     _exceptionToHttpStatusCodeParser = exceptionToHttpStatusCodeParser;
 }
Exemple #2
0
 public FilesService(
     IBlobReaderFactory blobReaderFactory,
     IBlobNameResolver blobNameResolver,
     IContentTypeResolver contentTypeResolver)
 {
     _blobReaderFactory   = blobReaderFactory;
     _blobNameResolver    = blobNameResolver;
     _contentTypeResolver = contentTypeResolver;
 }
        public void Register(string extension, IContentTypeResolver resolver)
        {
            if (extension == null) throw new ArgumentNullException("extension");
            if (resolver == null) throw new ArgumentNullException("resolver");

            resolvers[extension] = resolver;

            Tracer.TraceSource.TraceInformation("Registerd ContentTypeResolver '{0}' for '{1}'",
                resolver.GetType().FullName, extension);
        }
Exemple #4
0
        /// <summary>
        /// Adds Contentful services to the IServiceCollection.
        /// </summary>
        /// <param name="services">The IServiceCollection.</param>
        /// <param name="configuration">The IConfiguration used to retrieve configuration from.</param>
        /// <param name="contentTypeResolver">A content type resolver instance for the client to use.</param>
        /// <returns>The IServiceCollection.</returns>
        public static IServiceCollection AddContentful(this IServiceCollection services, IConfiguration configuration, IContentTypeResolver contentTypeResolver)
        {
            services.Configure <ContentfulOptions>(configuration.GetSection("ContentfulOptions"));
            services.AddHttpClient(HttpClientName);
            services.TryAddTransient <IContentfulClient>((sp) =>
            {
                var options    = sp.GetService <IOptions <ContentfulOptions> >()?.Value;
                var factory    = sp.GetService <IHttpClientFactory>();
                var httpClient = factory?.CreateClient(HttpClientName);
                return(new ContentfulClient(httpClient, options)
                {
                    ContentTypeResolver = contentTypeResolver
                });
            });

            return(services);
        }