Skip to content

Commit 4ec4565

Browse files
committed
🐛 Fix class in same executing assembly not been included
1 parent 3accb4a commit 4ec4565

File tree

8 files changed

+73
-8
lines changed

8 files changed

+73
-8
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace Example.Services
4+
{
5+
public class ScopedService
6+
{
7+
private int counter = 0;
8+
public int count
9+
{
10+
get
11+
{
12+
return counter;
13+
}
14+
}
15+
16+
ScopedService()
17+
{
18+
counter += 1;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace Example.Services
4+
{
5+
public class SingletonService
6+
{
7+
private int counter = 0;
8+
public int count
9+
{
10+
get
11+
{
12+
return counter;
13+
}
14+
}
15+
16+
SingletonService()
17+
{
18+
counter += 1;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace Example.Services
4+
{
5+
public class TransientService : ITransientService
6+
{
7+
private int counter = 0;
8+
public int count
9+
{
10+
get
11+
{
12+
return counter;
13+
}
14+
}
15+
16+
TransientService()
17+
{
18+
counter += 1;
19+
}
20+
}
21+
}

Example/AspNetCore/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Startup(IConfiguration configuration)
2727
public void ConfigureServices(IServiceCollection services)
2828
{
2929
services.BatchSingleton("Singleton*");
30-
services.BatchTransient("I*entService");
30+
services.BatchTransient("ITransient*Service");
3131
services.BatchScoped("Scoped*");
3232
services.AddMvc();
3333
}

Example/__services__/ScopedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Example.Services
44
{
5-
public class ScopedService
5+
public class ScopedExService
66
{
77
private int counter = 0;
88
public int count
@@ -13,7 +13,7 @@ public int count
1313
}
1414
}
1515

16-
ScopedService()
16+
ScopedExService()
1717
{
1818
counter += 1;
1919
}

Example/__services__/SingletonService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Example.Services
44
{
5-
public class SingletonService
5+
public class SingletonExService
66
{
77
private int counter = 0;
88
public int count
@@ -13,7 +13,7 @@ public int count
1313
}
1414
}
1515

16-
SingletonService()
16+
SingletonExService()
1717
{
1818
counter += 1;
1919
}

Example/__services__/TransientService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Example.Services
44
{
5-
public class TransientService : ITransientService
5+
public class TransientExService : ITransientService
66
{
77
private int counter = 0;
88
public int count
@@ -13,7 +13,7 @@ public int count
1313
}
1414
}
1515

16-
TransientService()
16+
TransientExService()
1717
{
1818
counter += 1;
1919
}

Library/BatchDI.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public static bool filterHasInterface(string filter)
1919
private static void BatchInjector(Delegate injector, string filter, dynamic blacklist, bool parallel, bool nested)
2020
{
2121
// Filter based on namespace and provided pattern
22-
var types = from a in EntryAssembly.GetReferencedAssemblies().Select(Assembly.Load)
22+
var assemblies = EntryAssembly.GetReferencedAssemblies().Select(Assembly.Load).ToList();
23+
assemblies.Add(EntryAssembly);
24+
var types = from a in assemblies
2325
from t in a.GetTypes()
2426
where containMainNamespace(t.Namespace, t) && filterMatch(t.Name) && notInBlacklist(t.Name)
2527
select t;

0 commit comments

Comments
 (0)