Skip to content

Commit c5745b5

Browse files
committed
✏️ Change param includeNestedClass to nested
- Release 1.2.0 🔖
1 parent 6f59414 commit c5745b5

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

Framework/AspNetCore/IServiceCollectionExtensions.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,68 @@ public static class IServiceCollectionExtensions
99
{
1010
public static IServiceCollection BatchInject(
1111
this IServiceCollection services, Action<Type, Type> injector, dynamic filter,
12-
dynamic blacklist = null, bool parallel = false, bool includeNestedClass = true)
12+
dynamic blacklist = null, bool parallel = false, bool nested = true)
1313
{
14-
BatchDI.BatchInject(injector, filter, blacklist, parallel, includeNestedClass);
14+
BatchDI.BatchInject(injector, filter, blacklist, parallel, nested);
1515
return services;
1616
}
1717

1818
public static IServiceCollection BatchInject(
1919
this IServiceCollection services, Action<Type> injector, dynamic filter,
20-
dynamic blacklist = null, bool parallel = false, bool includeNestedClass = true)
20+
dynamic blacklist = null, bool parallel = false, bool nested = true)
2121
{
22-
BatchDI.BatchInject(injector, filter, blacklist, parallel, includeNestedClass);
22+
BatchDI.BatchInject(injector, filter, blacklist, parallel, nested);
2323
return services;
2424
}
2525

2626
public static IServiceCollection BatchSingleton(
2727
this IServiceCollection services, dynamic filter,
28-
dynamic blacklist = null, bool parallel = false, bool includeNestedClass = true)
28+
dynamic blacklist = null, bool parallel = false, bool nested = true)
2929
{
3030

3131
if (BatchDI.filterHasInterface(filter))
3232
{
3333
Action<Type, Type> caller = (_interface, _implementation) => services.AddSingleton(_interface, _implementation);
34-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
34+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
3535
}
3636
else
3737
{
3838
Action<Type> caller = (_implementation) => services.AddSingleton(_implementation);
39-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
39+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
4040
}
4141
return services;
4242
}
4343

4444
public static IServiceCollection BatchTransient(
4545
this IServiceCollection services, string filter,
46-
dynamic blacklist = null, bool parallel = false, bool includeNestedClass = true)
46+
dynamic blacklist = null, bool parallel = false, bool nested = true)
4747
{
4848
if (BatchDI.filterHasInterface(filter))
4949
{
5050
Action<Type, Type> caller = (_interface, _implementation) => services.AddTransient(_interface, _implementation);
51-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
51+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
5252
}
5353
else
5454
{
5555
Action<Type> caller = (_implementation) => services.AddTransient(_implementation);
56-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
56+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
5757
}
5858
return services;
5959
}
6060

6161
public static IServiceCollection BatchScoped(
6262
this IServiceCollection services, string filter,
63-
dynamic blacklist = null, bool parallel = false, bool includeNestedClass = true)
63+
dynamic blacklist = null, bool parallel = false, bool nested = true)
6464
{
6565
if (BatchDI.filterHasInterface(filter))
6666
{
6767
Action<Type, Type> caller = (_interface, _implementation) => services.AddScoped(_interface, _implementation);
68-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
68+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
6969
}
7070
else
7171
{
7272
Action<Type> caller = (_implementation) => services.AddScoped(_implementation);
73-
BatchDI.BatchInject(caller, filter, blacklist, parallel, includeNestedClass);
73+
BatchDI.BatchInject(caller, filter, blacklist, parallel, nested);
7474
}
7575
return services;
7676
}

Library/BatchDI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static bool filterHasInterface(string filter)
1616
(filter.StartsWith("*") && filter.EndsWith("*"));
1717
}
1818

19-
private static void BatchInjector(Delegate injector, string filter, dynamic blacklist, bool parallel, bool includeNestedClass)
19+
private static void BatchInjector(Delegate injector, string filter, dynamic blacklist, bool parallel, bool nested)
2020
{
2121
// Filter based on namespace and provided pattern
2222
var types = from a in EntryAssembly.GetReferencedAssemblies().Select(Assembly.Load)
@@ -62,7 +62,7 @@ void invoke(Type implementation)
6262
#region Helper
6363
void nestedInvoke(Type i) // WARN: recursive function
6464
{
65-
if (i.GetNestedTypes().Length < 1 && !includeNestedClass) return; // stop if empty
65+
if (i.GetNestedTypes().Length < 1 && !nested) return; // stop if empty
6666
void invoke(Type g)
6767
{
6868
injector.DynamicInvoke(g);

Library/BatchDI_API.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ public partial class BatchDI
99
public static void BatchInject(Action<Type, Type> injector, dynamic filter,
1010
dynamic blacklist = null,
1111
bool parallel = false,
12-
bool includeNestedClass = true
12+
bool nested = true
1313
)
1414
{
15-
inject(injector, filter, blacklist, parallel, includeNestedClass);
15+
inject(injector, filter, blacklist, parallel, nested);
1616
}
1717

1818
// only class
1919
public static void BatchInject(Action<Type> injector, dynamic filter,
2020
dynamic blacklist = null,
2121
bool parallel = false,
22-
bool includeNestedClass = true
22+
bool nested = true
2323
)
2424
{
25-
inject(injector, filter, blacklist, parallel, includeNestedClass);
25+
inject(injector, filter, blacklist, parallel, nested);
2626
}
2727

2828
public static void SetEntryAssembly(Assembly assembly) => EntryAssembly = assembly;
2929

30-
private static void inject(dynamic caller, dynamic filter, dynamic blacklist, bool parallel, bool includeNestedClass)
30+
private static void inject(dynamic caller, dynamic filter, dynamic blacklist, bool parallel, bool nested)
3131
{
32-
if (filter is string) BatchInjector(caller, filter, blacklist, parallel, includeNestedClass);
33-
else if (filter is string[]) foreach (var f in filter) BatchInjector(caller, f, blacklist, parallel, includeNestedClass);
32+
if (filter is string) BatchInjector(caller, filter, blacklist, parallel, nested);
33+
else if (filter is string[]) foreach (var f in filter) BatchInjector(caller, f, blacklist, parallel, nested);
3434
else throw new System.ArgumentException($"{nameof(filter)} must be `string` or `string[]`");
3535
}
3636
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ _server = new TestServer(new WebHostBuilder().SetBatchDIEntryPoint<Startup>().Us
196196
| `filter` | list or glob pattern for specify which class name to inject | `string`, <br>`string[]` |
197197
| `blacklist` (optional) | list or glob pattern for specify which class name **not** to be injected | `string`, <br>`string[]` |
198198
| `parallel` (optional) | if the startup time become slower, try to set this `true` | `bool` | `false` |
199-
| `includeNestedClass` (optional) | choose if also to inject nested class | `bool` | `true` |
199+
| `nested` (optional) | choose if also to inject nested class | `bool` | `true` |
200200

201201
</details>
202202

203203
### BatchDI
204204

205205
| Method | Description | Return |
206206
| -------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------ |
207-
| `BatchInject(injector =>{}, filter, blacklist?, parallel?, includeNestedClass?)` | implement custom dependency injection based on filter pattern and blacklist |
207+
| `BatchInject(injector =>{}, filter, blacklist?, parallel?, nested?)` | implement custom dependency injection based on filter pattern and blacklist |
208208
| `SetEntryAssembly(Assembly assembly)` | Try to set this this in case there is an error |
209209

210210
### BatchDI.AspNetCore
@@ -213,9 +213,9 @@ This library extend `IServiceCollection` usage by adding additional method for b
213213

214214
| Method | Description | Return |
215215
| -------------------------------------------------------------------- | ------------------------------------------- | -------------------- |
216-
| `BatchSingleton(filter, blacklist?, parallel?, includeNestedClass?)` | Batch/MultipleAdd version of `AddSingleton` | `IServiceCollection` |
217-
| `BatchTransient(filter, blacklist?, parallel?, includeNestedClass?)` | Batch/MultipleAdd version of `AddTransient` | `IServiceCollection` |
218-
| `BatchScoped(filter, blacklist?, parallel?, includeNestedClass?)` | Batch/MultipleAdd version of `AddScoped` | `IServiceCollection` |
216+
| `BatchSingleton(filter, blacklist?, parallel?, nested?)` | Batch/MultipleAdd version of `AddSingleton` | `IServiceCollection` |
217+
| `BatchTransient(filter, blacklist?, parallel?, nested?)` | Batch/MultipleAdd version of `AddTransient` | `IServiceCollection` |
218+
| `BatchScoped(filter, blacklist?, parallel?, nested?)` | Batch/MultipleAdd version of `AddScoped` | `IServiceCollection` |
219219

220220
---
221221

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 1.1.{build}
1+
version: 1.2.{build}
22

33
# NOTE .NET Core SDK is already installed in the build worker image Visual Studio 2017
44
# so the `install` section is not required

0 commit comments

Comments
 (0)