Skip to content

Commit cb53f01

Browse files
Merge pull request #468 from johelvisguzman/issue467
Allowed ioc containers to register read-only wrappers for repositories and services
2 parents a79fce4 + 1ff3da8 commit cb53f01

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

src/DotNetToolkit.Repository.Extensions.Microsoft.DependencyInjection/ServiceCollectionExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public static IServiceCollection AddRepositories([NotNull] this IServiceCollecti
5252
typeof(IRepository<,>),
5353
typeof(IRepository<,,>),
5454
typeof(IRepository<,,,>),
55+
typeof(IReadOnlyService<>),
56+
typeof(IReadOnlyService<,>),
57+
typeof(IReadOnlyService<,,>),
58+
typeof(IReadOnlyService<,,,>),
59+
typeof(IReadOnlyRepository<>),
60+
typeof(IReadOnlyRepository<,>),
61+
typeof(IReadOnlyRepository<,,>),
62+
typeof(IReadOnlyRepository<,,,>),
5563
typeof(IRepositoryInterceptor)
5664
};
5765

src/DotNetToolkit.Repository.Extensions.Unity/UnityContainerExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public static void RegisterRepositories([NotNull] this IUnityContainer container
5151
typeof(IRepository<,>),
5252
typeof(IRepository<,,>),
5353
typeof(IRepository<,,,>),
54+
typeof(IReadOnlyService<>),
55+
typeof(IReadOnlyService<,>),
56+
typeof(IReadOnlyService<,,>),
57+
typeof(IReadOnlyService<,,,>),
58+
typeof(IReadOnlyRepository<>),
59+
typeof(IReadOnlyRepository<,>),
60+
typeof(IReadOnlyRepository<,,>),
61+
typeof(IReadOnlyRepository<,,,>),
5462
typeof(IRepositoryInterceptor)
5563
};
5664

test/DotNetToolkit.Repository.Integration.Test/DependencyInjectionTests.Microsoft.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ public void DependencyInjectionCanConfigureRepositoriesServices()
4141
Assert.NotNull(provider.GetService<IRepository<Customer, int>>());
4242
Assert.NotNull(provider.GetService<IRepository<CustomerWithTwoCompositePrimaryKey, int, string>>());
4343
Assert.NotNull(provider.GetService<IRepository<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
44+
Assert.NotNull(provider.GetService<IReadOnlyRepository<Customer>>());
45+
Assert.NotNull(provider.GetService<IReadOnlyRepository<Customer, int>>());
46+
Assert.NotNull(provider.GetService<IReadOnlyRepository<CustomerWithTwoCompositePrimaryKey, int, string>>());
47+
Assert.NotNull(provider.GetService<IReadOnlyRepository<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
4448
Assert.NotNull(provider.GetService<ITestCustomerRepository>());
4549
Assert.NotNull(provider.GetService<IService<Customer>>());
4650
Assert.NotNull(provider.GetService<IService<Customer, int>>());
4751
Assert.NotNull(provider.GetService<IService<CustomerWithTwoCompositePrimaryKey, int, string>>());
4852
Assert.NotNull(provider.GetService<IService<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
53+
Assert.NotNull(provider.GetService<IReadOnlyService<Customer>>());
54+
Assert.NotNull(provider.GetService<IReadOnlyService<Customer, int>>());
55+
Assert.NotNull(provider.GetService<IReadOnlyService<CustomerWithTwoCompositePrimaryKey, int, string>>());
56+
Assert.NotNull(provider.GetService<IReadOnlyService<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
4957
Assert.NotNull(provider.GetService<ITestCustomerService>());
5058
Assert.NotNull(provider.GetService<IRepositoryFactory>());
5159
Assert.NotNull(provider.GetService<IRepositoryOptions>());

test/DotNetToolkit.Repository.Integration.Test/DependencyInjectionTests.Unity.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ public void DependencyInjectionCanConfigureRepositoriesServices()
4040
Assert.NotNull(container.Resolve<IRepository<Customer, int>>());
4141
Assert.NotNull(container.Resolve<IRepository<CustomerWithTwoCompositePrimaryKey, int, string>>());
4242
Assert.NotNull(container.Resolve<IRepository<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
43+
Assert.NotNull(container.Resolve<IReadOnlyRepository<Customer>>());
44+
Assert.NotNull(container.Resolve<IReadOnlyRepository<Customer, int>>());
45+
Assert.NotNull(container.Resolve<IReadOnlyRepository<CustomerWithTwoCompositePrimaryKey, int, string>>());
46+
Assert.NotNull(container.Resolve<IReadOnlyRepository<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
4347
Assert.NotNull(container.Resolve<ITestCustomerRepository>());
4448
Assert.NotNull(container.Resolve<IService<Customer>>());
4549
Assert.NotNull(container.Resolve<IService<Customer, int>>());
4650
Assert.NotNull(container.Resolve<IService<CustomerWithTwoCompositePrimaryKey, int, string>>());
4751
Assert.NotNull(container.Resolve<IService<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
52+
Assert.NotNull(container.Resolve<IReadOnlyService<Customer>>());
53+
Assert.NotNull(container.Resolve<IReadOnlyService<Customer, int>>());
54+
Assert.NotNull(container.Resolve<IReadOnlyService<CustomerWithTwoCompositePrimaryKey, int, string>>());
55+
Assert.NotNull(container.Resolve<IReadOnlyService<CustomerWithThreeCompositePrimaryKey, int, string, int>>());
4856
Assert.NotNull(container.Resolve<ITestCustomerService>());
4957
Assert.NotNull(container.Resolve<IRepositoryFactory>());
5058
Assert.NotNull(container.Resolve<IRepositoryOptions>());

0 commit comments

Comments
 (0)