Skip to content

Commit 821616c

Browse files
Revert type parameter changes
1 parent bcb8fed commit 821616c

1 file changed

Lines changed: 59 additions & 58 deletions

File tree

src/ImageSharp.Web/DependencyInjection/ImageSharpBuilderExtensions.cs

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public static class ImageSharpBuilderExtensions
2222
/// <summary>
2323
/// Sets the given <see cref="IRequestParser"/> adding it to the service collection.
2424
/// </summary>
25-
/// <typeparam name="T">The type of class implementing <see cref="IRequestParser"/> to add.</typeparam>
25+
/// <typeparam name="TParser">The type of class implementing <see cref="IRequestParser"/> to add.</typeparam>
2626
/// <param name="builder">The core builder.</param>
2727
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
28-
public static IImageSharpBuilder SetRequestParser<T>(this IImageSharpBuilder builder)
29-
where T : class, IRequestParser
28+
public static IImageSharpBuilder SetRequestParser<TParser>(this IImageSharpBuilder builder)
29+
where TParser : class, IRequestParser
3030
{
31-
builder.Services.Replace(ServiceDescriptor.Singleton<IRequestParser, T>());
31+
builder.Services.Replace(ServiceDescriptor.Singleton<IRequestParser, TParser>());
3232

3333
return builder;
3434
}
@@ -49,13 +49,13 @@ public static IImageSharpBuilder SetRequestParser(this IImageSharpBuilder builde
4949
/// <summary>
5050
/// Sets the given <see cref="IImageCache"/> adding it to the service collection.
5151
/// </summary>
52-
/// <typeparam name="T">The type of class implementing <see cref="IImageCache"/> to add.</typeparam>
52+
/// <typeparam name="TCache">The type of class implementing <see cref="IImageCache"/> to add.</typeparam>
5353
/// <param name="builder">The core builder.</param>
5454
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
55-
public static IImageSharpBuilder SetCache<T>(this IImageSharpBuilder builder)
56-
where T : class, IImageCache
55+
public static IImageSharpBuilder SetCache<TCache>(this IImageSharpBuilder builder)
56+
where TCache : class, IImageCache
5757
{
58-
builder.Services.Replace(ServiceDescriptor.Singleton<IImageCache, T>());
58+
builder.Services.Replace(ServiceDescriptor.Singleton<IImageCache, TCache>());
5959

6060
return builder;
6161
}
@@ -76,13 +76,13 @@ public static IImageSharpBuilder SetCache(this IImageSharpBuilder builder, Func<
7676
/// <summary>
7777
/// Sets the given <see cref="ICacheKey"/> adding it to the service collection.
7878
/// </summary>
79-
/// <typeparam name="T">The type of class implementing <see cref="ICacheKey"/> to add.</typeparam>
79+
/// <typeparam name="TCacheKey">The type of class implementing <see cref="ICacheKey"/> to add.</typeparam>
8080
/// <param name="builder">The core builder.</param>
8181
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
82-
public static IImageSharpBuilder SetCacheKey<T>(this IImageSharpBuilder builder)
83-
where T : class, ICacheKey
82+
public static IImageSharpBuilder SetCacheKey<TCacheKey>(this IImageSharpBuilder builder)
83+
where TCacheKey : class, ICacheKey
8484
{
85-
builder.Services.Replace(ServiceDescriptor.Singleton<ICacheKey, T>());
85+
builder.Services.Replace(ServiceDescriptor.Singleton<ICacheKey, TCacheKey>());
8686

8787
return builder;
8888
}
@@ -103,13 +103,13 @@ public static IImageSharpBuilder SetCacheKey(this IImageSharpBuilder builder, Fu
103103
/// <summary>
104104
/// Sets the given <see cref="ICacheHash"/> adding it to the service collection.
105105
/// </summary>
106-
/// <typeparam name="T">The type of class implementing <see cref="ICacheHash"/> to add.</typeparam>
106+
/// <typeparam name="TCacheHash">The type of class implementing <see cref="ICacheHash"/> to add.</typeparam>
107107
/// <param name="builder">The core builder.</param>
108108
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
109-
public static IImageSharpBuilder SetCacheHash<T>(this IImageSharpBuilder builder)
110-
where T : class, ICacheHash
109+
public static IImageSharpBuilder SetCacheHash<TCacheHash>(this IImageSharpBuilder builder)
110+
where TCacheHash : class, ICacheHash
111111
{
112-
builder.Services.Replace(ServiceDescriptor.Singleton<ICacheHash, T>());
112+
builder.Services.Replace(ServiceDescriptor.Singleton<ICacheHash, TCacheHash>());
113113

114114
return builder;
115115
}
@@ -144,12 +144,12 @@ public static IImageSharpBuilder AddProvider<T>(this IImageSharpBuilder builder)
144144
/// <summary>
145145
/// Adds the given <see cref="IImageProvider"/> to the provider collection within the service collection.
146146
/// </summary>
147-
/// <typeparam name="T">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
147+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
148148
/// <param name="builder">The core builder.</param>
149149
/// <param name="implementationFactory">The factory method for returning a <see cref="IImageProvider"/>.</param>
150150
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
151-
public static IImageSharpBuilder AddProvider<T>(this IImageSharpBuilder builder, Func<IServiceProvider, T> implementationFactory)
152-
where T : class, IImageProvider
151+
public static IImageSharpBuilder AddProvider<TProvider>(this IImageSharpBuilder builder, Func<IServiceProvider, TProvider> implementationFactory)
152+
where TProvider : class, IImageProvider
153153
{
154154
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IImageProvider>(implementationFactory));
155155

@@ -159,16 +159,16 @@ public static IImageSharpBuilder AddProvider<T>(this IImageSharpBuilder builder,
159159
/// <summary>
160160
/// Inserts the given <see cref="IImageProvider"/> at the give index into to the provider collection within the service collection.
161161
/// </summary>
162-
/// <typeparam name="T">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
162+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
163163
/// <param name="builder">The core builder.</param>
164164
/// <param name="index">The zero-based index at which the provider should be inserted.</param>
165165
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
166-
public static IImageSharpBuilder InsertProvider<T>(this IImageSharpBuilder builder, int index)
167-
where T : class, IImageProvider
166+
public static IImageSharpBuilder InsertProvider<TProvider>(this IImageSharpBuilder builder, int index)
167+
where TProvider : class, IImageProvider
168168
{
169169
var descriptors = builder.Services.Where(x => x.ServiceType == typeof(IImageProvider)).ToList();
170-
descriptors.RemoveAll(x => x.GetImplementationType() == typeof(T));
171-
descriptors.Insert(index, ServiceDescriptor.Singleton<IImageProvider, T>());
170+
descriptors.RemoveAll(x => x.GetImplementationType() == typeof(TProvider));
171+
descriptors.Insert(index, ServiceDescriptor.Singleton<IImageProvider, TProvider>());
172172

173173
builder.ClearProviders();
174174
builder.Services.TryAddEnumerable(descriptors);
@@ -179,16 +179,16 @@ public static IImageSharpBuilder InsertProvider<T>(this IImageSharpBuilder build
179179
/// <summary>
180180
/// Inserts the given <see cref="IImageProvider"/> at the give index into the provider collection within the service collection.
181181
/// </summary>
182-
/// <typeparam name="T">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
182+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
183183
/// <param name="builder">The core builder.</param>
184184
/// <param name="index">The zero-based index at which the provider should be inserted.</param>
185185
/// <param name="implementationFactory">The factory method for returning a <see cref="IImageProvider"/>.</param>
186186
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
187-
public static IImageSharpBuilder InsertProvider<T>(this IImageSharpBuilder builder, int index, Func<IServiceProvider, T> implementationFactory)
188-
where T : class, IImageProvider
187+
public static IImageSharpBuilder InsertProvider<TProvider>(this IImageSharpBuilder builder, int index, Func<IServiceProvider, TProvider> implementationFactory)
188+
where TProvider : class, IImageProvider
189189
{
190190
var descriptors = builder.Services.Where(x => x.ServiceType == typeof(IImageProvider)).ToList();
191-
descriptors.RemoveAll(x => x.GetImplementationType() == typeof(T));
191+
descriptors.RemoveAll(x => x.GetImplementationType() == typeof(TProvider));
192192
descriptors.Insert(index, ServiceDescriptor.Singleton<IImageProvider>(implementationFactory));
193193

194194
builder.ClearProviders();
@@ -200,13 +200,13 @@ public static IImageSharpBuilder InsertProvider<T>(this IImageSharpBuilder build
200200
/// <summary>
201201
/// Removes the given <see cref="IImageProvider"/> from the provider collection within the service collection.
202202
/// </summary>
203-
/// <typeparam name="T">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
203+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
204204
/// <param name="builder">The core builder.</param>
205205
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
206-
public static IImageSharpBuilder RemoveProvider<T>(this IImageSharpBuilder builder)
207-
where T : class, IImageProvider
206+
public static IImageSharpBuilder RemoveProvider<TProvider>(this IImageSharpBuilder builder)
207+
where TProvider : class, IImageProvider
208208
{
209-
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(IImageProvider) && x.GetImplementationType() == typeof(T));
209+
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(IImageProvider) && x.GetImplementationType() == typeof(TProvider));
210210
if (descriptor != null)
211211
{
212212
builder.Services.Remove(descriptor);
@@ -244,12 +244,12 @@ public static IImageSharpBuilder AddProcessor<T>(this IImageSharpBuilder builder
244244
/// <summary>
245245
/// Adds the given <see cref="IImageWebProcessor"/> to the processor collection within the service collection.
246246
/// </summary>
247-
/// <typeparam name="T">The type of class implementing <see cref="IImageWebProcessor"/> to add.</typeparam>
247+
/// <typeparam name="TProcessor">The type of class implementing <see cref="IImageWebProcessor"/> to add.</typeparam>
248248
/// <param name="builder">The core builder.</param>
249249
/// <param name="implementationFactory">The factory method for returning a <see cref="IImageProvider"/>.</param>
250250
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
251-
public static IImageSharpBuilder AddProcessor<T>(this IImageSharpBuilder builder, Func<IServiceProvider, T> implementationFactory)
252-
where T : class, IImageWebProcessor
251+
public static IImageSharpBuilder AddProcessor<TProcessor>(this IImageSharpBuilder builder, Func<IServiceProvider, TProcessor> implementationFactory)
252+
where TProcessor : class, IImageWebProcessor
253253
{
254254
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IImageWebProcessor>(implementationFactory));
255255

@@ -259,13 +259,13 @@ public static IImageSharpBuilder AddProcessor<T>(this IImageSharpBuilder builder
259259
/// <summary>
260260
/// Removes the given <see cref="IImageWebProcessor"/> from the processor collection within the service collection.
261261
/// </summary>
262-
/// <typeparam name="T">The type of class implementing <see cref="IImageWebProcessor"/> to add.</typeparam>
262+
/// <typeparam name="TProcessor">The type of class implementing <see cref="IImageWebProcessor"/> to add.</typeparam>
263263
/// <param name="builder">The core builder.</param>
264264
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
265-
public static IImageSharpBuilder RemoveProcessor<T>(this IImageSharpBuilder builder)
266-
where T : class, IImageWebProcessor
265+
public static IImageSharpBuilder RemoveProcessor<TProcessor>(this IImageSharpBuilder builder)
266+
where TProcessor : class, IImageWebProcessor
267267
{
268-
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(IImageWebProcessor) && x.GetImplementationType() == typeof(T));
268+
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(IImageWebProcessor) && x.GetImplementationType() == typeof(TProcessor));
269269
if (descriptor != null)
270270
{
271271
builder.Services.Remove(descriptor);
@@ -289,26 +289,26 @@ public static IImageSharpBuilder ClearProcessors(this IImageSharpBuilder builder
289289
/// <summary>
290290
/// Adds the given <see cref="ICommandConverter"/> to the converter collection within the service collection.
291291
/// </summary>
292-
/// <typeparam name="T">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
292+
/// <typeparam name="TConverter">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
293293
/// <param name="builder">The core builder.</param>
294294
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
295-
public static IImageSharpBuilder AddConverter<T>(this IImageSharpBuilder builder)
296-
where T : class, ICommandConverter
295+
public static IImageSharpBuilder AddConverter<TConverter>(this IImageSharpBuilder builder)
296+
where TConverter : class, ICommandConverter
297297
{
298-
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ICommandConverter, T>());
298+
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ICommandConverter, TConverter>());
299299

300300
return builder;
301301
}
302302

303303
/// <summary>
304304
/// Adds the given <see cref="ICommandConverter"/> to the converter collection within the service collection.
305305
/// </summary>
306-
/// <typeparam name="T">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
306+
/// <typeparam name="TConverter">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
307307
/// <param name="builder">The core builder.</param>
308308
/// <param name="implementationFactory">The factory method for returning a <see cref="ICommandConverter"/>.</param>
309309
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
310-
public static IImageSharpBuilder AddConverter<T>(this IImageSharpBuilder builder, Func<IServiceProvider, T> implementationFactory)
311-
where T : class, ICommandConverter
310+
public static IImageSharpBuilder AddConverter<TConverter>(this IImageSharpBuilder builder, Func<IServiceProvider, TConverter> implementationFactory)
311+
where TConverter : class, ICommandConverter
312312
{
313313
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ICommandConverter>(implementationFactory));
314314

@@ -318,13 +318,13 @@ public static IImageSharpBuilder AddConverter<T>(this IImageSharpBuilder builder
318318
/// <summary>
319319
/// Removes the given <see cref="ICommandConverter"/> from the converter collection within the service collection.
320320
/// </summary>
321-
/// <typeparam name="T">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
321+
/// <typeparam name="TConverter">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
322322
/// <param name="builder">The core builder.</param>
323323
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
324-
public static IImageSharpBuilder RemoveConverter<T>(this IImageSharpBuilder builder)
325-
where T : class, ICommandConverter
324+
public static IImageSharpBuilder RemoveConverter<TConverter>(this IImageSharpBuilder builder)
325+
where TConverter : class, ICommandConverter
326326
{
327-
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(ICommandConverter) && x.GetImplementationType() == typeof(T));
327+
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(ICommandConverter) && x.GetImplementationType() == typeof(TConverter));
328328
if (descriptor != null)
329329
{
330330
builder.Services.Remove(descriptor);
@@ -348,35 +348,36 @@ public static IImageSharpBuilder ClearConverters(this IImageSharpBuilder builder
348348
/// <summary>
349349
/// Registers an action used to configure a particular type of options.
350350
/// </summary>
351-
/// <typeparam name="T">The options type to be configured.</typeparam>
351+
/// <typeparam name="TOptions">The options type to be configured.</typeparam>
352352
/// <param name="builder">The core builder.</param>
353353
/// <param name="config">The configuration being bound.</param>
354354
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
355-
public static IImageSharpBuilder Configure<T>(this IImageSharpBuilder builder, IConfiguration config)
356-
where T : class
355+
public static IImageSharpBuilder Configure<TOptions>(this IImageSharpBuilder builder, IConfiguration config)
356+
where TOptions : class
357357
{
358-
builder.Services.Configure<T>(config);
358+
builder.Services.Configure<TOptions>(config);
359359

360360
return builder;
361361
}
362362

363363
/// <summary>
364364
/// Registers an action used to configure a particular type of options.
365365
/// </summary>
366-
/// <typeparam name="T">The options type to be configured.</typeparam>
366+
/// <typeparam name="TOptions">The options type to be configured.</typeparam>
367367
/// <param name="builder">The core builder.</param>
368368
/// <param name="configureOptions">The action used to configure the options.</param>
369369
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
370-
public static IImageSharpBuilder Configure<T>(this IImageSharpBuilder builder, Action<T> configureOptions)
371-
where T : class
370+
public static IImageSharpBuilder Configure<TOptions>(this IImageSharpBuilder builder, Action<TOptions> configureOptions)
371+
where TOptions : class
372372
{
373373
builder.Services.Configure(configureOptions);
374374

375375
return builder;
376376
}
377377

378378
/// <summary>
379-
/// Registers an action used to configure a particular type of options. Note: These are run after all <see cref="Configure{T}(IImageSharpBuilder, Action{T})"/>.
379+
/// Registers an action used to configure a particular type of options.
380+
/// Note: These are run after all <see cref="Configure{T}(IImageSharpBuilder, Action{T})"/>.
380381
/// </summary>
381382
/// <typeparam name="T">The options type to be configured.</typeparam>
382383
/// <param name="builder">The core builder.</param>

0 commit comments

Comments
 (0)