Skip to content

Commit 17fb4d2

Browse files
committed
DependencyReslover renamed to ServiceLocator
1 parent 5a2eaed commit 17fb4d2

13 files changed

+46
-46
lines changed

src/JQDT.MVC/ApplicationMvc.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ internal class ApplicationMvc<T> : ApplicationBase<T>
1818
/// Initializes a new instance of the <see cref="ApplicationMvc{T}"/> class.
1919
/// </summary>
2020
/// <param name="filterContext">The filter context.</param>
21-
/// <param name="dependencyResolver">The dependency resolver.</param>
22-
public ApplicationMvc(ActionExecutedContext filterContext, DI.IDependencyResolver dependencyResolver)
23-
: base(dependencyResolver)
21+
/// <param name="serviceLocator">The service locator.</param>
22+
public ApplicationMvc(ActionExecutedContext filterContext, DI.IServiceLocator serviceLocator)
23+
: base(serviceLocator)
2424
{
2525
this.filterContext = filterContext;
2626
}

src/JQDT.MVC/JQDataTableAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ public virtual void OnPagingDataProcessed(ref object data, RequestInfoModel requ
158158
private void PerformOnActionExecuted(ActionExecutedContext filterContext)
159159
{
160160
var dataCollectionType = filterContext.Controller.ViewData.Model.GetType();
161-
var dependencyResolver = new DI.DependencyResolver();
161+
var serviceLocator = new DI.ServiceLocator();
162162
var applicationInitizlizationFunction = ExecuteFunctionProvider<ActionExecutedContext>.GetAppInicializationFunc(dataCollectionType, typeof(ApplicationMvc<>));
163-
var mvcApplication = applicationInitizlizationFunction(filterContext, dependencyResolver);
163+
var mvcApplication = applicationInitizlizationFunction(filterContext, serviceLocator);
164164
this.SubscribeToEvents(mvcApplication);
165165
var result = (ResultModel)mvcApplication.Execute();
166166

src/JQDT.WebAPI/ApplicationWebApi.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ internal class ApplicationWebApi<T> : ApplicationBase<T>
2121
/// Initializes a new instance of the <see cref="ApplicationWebApi{T}"/> class.
2222
/// </summary>
2323
/// <param name="actionExecutedContext">The action executed context.</param>
24-
/// <param name="dependencyResolver">The dependency resolver.</param>
25-
public ApplicationWebApi(HttpActionExecutedContext actionExecutedContext, IDependencyResolver dependencyResolver)
26-
: base(dependencyResolver)
24+
/// <param name="serviceLocator">The dependency resolver.</param>
25+
public ApplicationWebApi(HttpActionExecutedContext actionExecutedContext, IServiceLocator serviceLocator)
26+
: base(serviceLocator)
2727
{
2828
this.actionExecutedContext = actionExecutedContext;
2929
}

src/JQDT.WebAPI/JQDataTableAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ private void PerformOnActionExecuted(HttpActionExecutedContext actionExecutedCon
4646
{
4747
var modelType = ((System.Net.Http.ObjectContent)actionExecutedContext.Response.Content).ObjectType;
4848
var applicationInitizlizationFunction = ExecuteFunctionProvider<HttpActionExecutedContext>.GetAppInicializationFunc(modelType, typeof(ApplicationWebApi<>));
49-
var dependencyResolver = new DI.DependencyResolver();
50-
var webApiApplication = applicationInitizlizationFunction(actionExecutedContext, dependencyResolver);
49+
var serviceLocator = new DI.ServiceLocator();
50+
var webApiApplication = applicationInitizlizationFunction(actionExecutedContext, serviceLocator);
5151
this.SubscribeToEvents(webApiApplication);
5252
var result = (ResultModel)webApiApplication.Execute();
5353
var formattedObjectResult = this.GetObjectResult(result);

src/JQDT/Application/ApplicationBase.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
/// <typeparam name="T">Data Collection Generic Type</typeparam>
1818
public abstract class ApplicationBase<T> : IApplicationBase
1919
{
20-
private readonly IDependencyResolver dependencyResolver;
20+
private readonly IServiceLocator serviceLocator;
2121

2222
/// <summary>
2323
/// Initializes a new instance of the <see cref="ApplicationBase{T}"/> class.
2424
/// </summary>
25-
/// <param name="dependencyResolver">The dependency resolver.</param>
26-
public ApplicationBase(IDependencyResolver dependencyResolver)
25+
/// <param name="sreviceLocator">The service locator.</param>
26+
public ApplicationBase(IServiceLocator sreviceLocator)
2727
{
28-
this.dependencyResolver = dependencyResolver;
28+
this.serviceLocator = sreviceLocator;
2929
}
3030

3131
public event DataProcessorEventHandler OnDataProcessingEvent = delegate { };
@@ -173,27 +173,27 @@ private IDataProcess<T> GetDataProcessChain(Type dataCollectionType)
173173
{
174174
var dataProcessChain = new DataProcessChain<T>();
175175

176-
var searchDataProcessor = this.dependencyResolver.GetSearchDataProcessor<T>();
176+
var searchDataProcessor = this.serviceLocator.GetSearchDataProcessor<T>();
177177
((DataProcessBase<T>)searchDataProcessor).OnDataProcessingEvent += this.OnSearchDataProcessingEvent;
178178
((DataProcessBase<T>)searchDataProcessor).OnDataProcessedEvent += this.OnSearchDataProcessedEvent;
179179
dataProcessChain.AddDataProcessor(searchDataProcessor);
180180

181-
var customFiltersDataProcessor = this.dependencyResolver.GetCustomFiltersDataProcessor<T>();
181+
var customFiltersDataProcessor = this.serviceLocator.GetCustomFiltersDataProcessor<T>();
182182
((DataProcessBase<T>)customFiltersDataProcessor).OnDataProcessingEvent += this.OnCustomFiltersDataProcessingEvent;
183183
((DataProcessBase<T>)customFiltersDataProcessor).OnDataProcessedEvent += this.OnCustomFiltersDataProcessedEvent;
184184
dataProcessChain.AddDataProcessor(customFiltersDataProcessor);
185185

186-
var columnsFilterDataProcessor = this.dependencyResolver.GetColumnsFilterDataProcessor<T>();
186+
var columnsFilterDataProcessor = this.serviceLocator.GetColumnsFilterDataProcessor<T>();
187187
((DataProcessBase<T>)columnsFilterDataProcessor).OnDataProcessingEvent += this.OnColumnsFilterDataProcessingEvent;
188188
((DataProcessBase<T>)columnsFilterDataProcessor).OnDataProcessedEvent += this.OnColumnsFilterDataProcessedEvent;
189189
dataProcessChain.AddDataProcessor(columnsFilterDataProcessor);
190190

191-
var sortDataProcessor = this.dependencyResolver.GetSortDataProcessor<T>();
191+
var sortDataProcessor = this.serviceLocator.GetSortDataProcessor<T>();
192192
((DataProcessBase<T>)sortDataProcessor).OnDataProcessingEvent += this.OnSortDataProcessingEvent;
193193
((DataProcessBase<T>)sortDataProcessor).OnDataProcessedEvent += this.OnSortDataProcessedEvent;
194194
dataProcessChain.AddDataProcessor(sortDataProcessor);
195195

196-
var pagingDataProcessor = this.dependencyResolver.GetPagingDataProcessor<T>();
196+
var pagingDataProcessor = this.serviceLocator.GetPagingDataProcessor<T>();
197197
((DataProcessBase<T>)pagingDataProcessor).OnDataProcessingEvent += this.OnPagingDataProcessingEvent;
198198
((DataProcessBase<T>)pagingDataProcessor).OnDataProcessedEvent += this.OnPagingDataProcessedEvent;
199199
dataProcessChain.AddDataProcessor(pagingDataProcessor);

src/JQDT/Application/ExecuteFunctionProvider.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@
1111
/// <typeparam name="TContext">The type of the request context.</typeparam>
1212
public static class ExecuteFunctionProvider<TContext>
1313
{
14-
private static ConcurrentDictionary<Type, Func<TContext, DI.IDependencyResolver, object>> executionFunctionsCache = new ConcurrentDictionary<Type, Func<TContext, DI.IDependencyResolver, object>>();
15-
private static ConcurrentDictionary<Type, Func<TContext, DI.IDependencyResolver, IApplicationBase>> appInitFunctionsCache = new ConcurrentDictionary<Type, Func<TContext, DI.IDependencyResolver, IApplicationBase>>();
14+
private static ConcurrentDictionary<Type, Func<TContext, DI.IServiceLocator, object>> executionFunctionsCache = new ConcurrentDictionary<Type, Func<TContext, DI.IServiceLocator, object>>();
15+
private static ConcurrentDictionary<Type, Func<TContext, DI.IServiceLocator, IApplicationBase>> appInitFunctionsCache = new ConcurrentDictionary<Type, Func<TContext, DI.IServiceLocator, IApplicationBase>>();
1616

1717
/// <summary>
1818
/// Gets the execute function.
1919
/// </summary>
2020
/// <param name="dataCollectionType">The type of the data collection.</param>
2121
/// <param name="appType">Type of the application.</param>
2222
/// <returns>Application execute function.</returns>
23-
public static Func<TContext, DI.IDependencyResolver, object> GetExecuteFunction(Type dataCollectionType, Type appType)
23+
public static Func<TContext, DI.IServiceLocator, object> GetExecuteFunction(Type dataCollectionType, Type appType)
2424
{
25-
Func<TContext, DI.IDependencyResolver, object> executeFunc = null;
25+
Func<TContext, DI.IServiceLocator, object> executeFunc = null;
2626

2727
if (!executionFunctionsCache.TryGetValue(dataCollectionType, out executeFunc))
2828
{
2929
Type[] typeArgs = { dataCollectionType.GenericTypeArguments.First() };
3030
var genericAppType = appType.MakeGenericType(typeArgs);
3131

3232
var contextExpr = Expression.Parameter(typeof(TContext), "context");
33-
var dependencyResolverExpr = Expression.Parameter(typeof(DI.IDependencyResolver));
33+
var serviceLocatorExpr = Expression.Parameter(typeof(DI.IServiceLocator));
3434
var appConstructorInfo = genericAppType.GetConstructors().First();
35-
var newAppExpr = Expression.New(appConstructorInfo, contextExpr, dependencyResolverExpr);
35+
var newAppExpr = Expression.New(appConstructorInfo, contextExpr, serviceLocatorExpr);
3636
var executeMethodInfo = genericAppType.GetMethod("Execute");
3737
var executeCallExpr = Expression.Call(newAppExpr, executeMethodInfo);
38-
var lambda = Expression.Lambda(executeCallExpr, contextExpr, dependencyResolverExpr);
38+
var lambda = Expression.Lambda(executeCallExpr, contextExpr, serviceLocatorExpr);
3939

40-
executeFunc = (Func<TContext, DI.IDependencyResolver, object>)lambda.Compile();
40+
executeFunc = (Func<TContext, DI.IServiceLocator, object>)lambda.Compile();
4141
executionFunctionsCache.TryAdd(dataCollectionType, executeFunc);
4242
}
4343

@@ -50,22 +50,22 @@ public static class ExecuteFunctionProvider<TContext>
5050
/// <param name="dataCollectionType">Type of the data collection.</param>
5151
/// <param name="appType">Type of the application.</param>
5252
/// <returns><see cref="Func{T, TResult}"/> that return new <see cref="IApplicationBase"/> instance</returns>
53-
public static Func<TContext, DI.IDependencyResolver, IApplicationBase> GetAppInicializationFunc(Type dataCollectionType, Type appType)
53+
public static Func<TContext, DI.IServiceLocator, IApplicationBase> GetAppInicializationFunc(Type dataCollectionType, Type appType)
5454
{
55-
Func<TContext, DI.IDependencyResolver, IApplicationBase> executeFunc = null;
55+
Func<TContext, DI.IServiceLocator, IApplicationBase> executeFunc = null;
5656

5757
if (!appInitFunctionsCache.TryGetValue(dataCollectionType, out executeFunc))
5858
{
5959
Type[] typeArgs = { dataCollectionType.GenericTypeArguments.First() };
6060
var genericAppType = appType.MakeGenericType(typeArgs);
6161

6262
var contextExpr = Expression.Parameter(typeof(TContext), "context");
63-
var dependencyResolverExpr = Expression.Parameter(typeof(DI.IDependencyResolver));
63+
var srviceLocatorExpr = Expression.Parameter(typeof(DI.IServiceLocator));
6464
var appConstructorInfo = genericAppType.GetConstructors().First();
65-
var newAppExpr = Expression.New(appConstructorInfo, contextExpr, dependencyResolverExpr);
66-
var lambda = Expression.Lambda(newAppExpr, contextExpr, dependencyResolverExpr);
65+
var newAppExpr = Expression.New(appConstructorInfo, contextExpr, srviceLocatorExpr);
66+
var lambda = Expression.Lambda(newAppExpr, contextExpr, srviceLocatorExpr);
6767

68-
executeFunc = (Func<TContext, DI.IDependencyResolver, IApplicationBase>)lambda.Compile();
68+
executeFunc = (Func<TContext, DI.IServiceLocator, IApplicationBase>)lambda.Compile();
6969
executionFunctionsCache.TryAdd(dataCollectionType, executeFunc);
7070
}
7171

src/JQDT/DI/IDependencyResolver.cs renamed to src/JQDT/DI/IServiceLocator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using JQDT.DataProcessing;
44

55
/// <summary>
6-
/// Dependency Resolver
6+
/// Service Locator Interface
77
/// </summary>
8-
/// <seealso cref="JQDT.DI.IDependencyResolver" />
9-
public interface IDependencyResolver
8+
/// <seealso cref="JQDT.DI.IServiceLocator" />
9+
public interface IServiceLocator
1010
{
1111
/// <summary>
1212
/// Gets the columns filter data processor.

src/JQDT/DI/DependencyResolver.cs renamed to src/JQDT/DI/ServiceLocator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
using JQDT.DataProcessing.SortDataProcessing;
1010

1111
/// <summary>
12-
/// Dependency Resolver
12+
/// Service Locator
1313
/// </summary>
14-
/// <seealso cref="JQDT.DI.IDependencyResolver" />
15-
public class DependencyResolver : IDependencyResolver
14+
/// <seealso cref="JQDT.DI.IServiceLocator" />
15+
public class ServiceLocator : IServiceLocator
1616
{
1717
/// <summary>
1818
/// Gets the search data processor.

src/JQDT/JQDT.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
<Compile Include="DataProcessing\SortDataProcessing\SortDataProcessor.cs" />
8282
<Compile Include="DataProcessing\PagingDataProcessing\PagingDataProcessor.cs" />
8383
<Compile Include="Delegates\DataProcessorEventHandler.cs" />
84-
<Compile Include="DI\DependencyResolver.cs" />
85-
<Compile Include="DI\IDependencyResolver.cs" />
84+
<Compile Include="DI\ServiceLocator.cs" />
85+
<Compile Include="DI\IServiceLocator.cs" />
8686
<Compile Include="Enumerations\OperationTypesEnum.cs" />
8787
<Compile Include="Exceptions\InvalidTypeForOperationException.cs" />
8888
<Compile Include="Exceptions\JQDataTablesException.cs" />

src/Tests/UnitTests/Tests.UnitTests/ColumnsFilterDataProcessorUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class ColumnsFilterDataProcessorUnitTests
2424
[SetUp]
2525
public void SetUp()
2626
{
27-
var resolver = new DependencyResolver();
27+
var resolver = new ServiceLocator();
2828
this.filterSimpleModelProcessor = resolver.GetColumnsFilterDataProcessor<AllTypesModel>();
2929
this.filterComplexModelProcessor = resolver.GetColumnsFilterDataProcessor<ComplexModel>();
3030
this.simpleData = new List<AllTypesModel>().AsQueryable();

src/Tests/UnitTests/Tests.UnitTests/CustomFiltersDataProcessorUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class CustomFiltersDataProcessorUnitTests
2222
[SetUp]
2323
public void SetUp()
2424
{
25-
var resolver = new DependencyResolver();
25+
var resolver = new ServiceLocator();
2626
this.filter = resolver.GetCustomFiltersDataProcessor<AllTypesModel>();
2727
this.data = DataGenerator.GenerateSimpleData(5000, RangeConstant);
2828
}

src/Tests/UnitTests/Tests.UnitTests/SearchDataProcessorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void SetUp()
2323
[Test]
2424
public void GlobalSearch_SearchWithTwoSearchableProperties()
2525
{
26-
var filterProc = new DependencyResolver().GetSearchDataProcessor<AllTypesModel>();
26+
var filterProc = new ServiceLocator().GetSearchDataProcessor<AllTypesModel>();
2727
var data = new List<AllTypesModel>()
2828
{
2929
new AllTypesModel
@@ -286,7 +286,7 @@ public void GlobalSearchShouldIgnoreNonStringProperties()
286286

287287
private IDataProcess<T> GetFilterDataProcessor<T>()
288288
{
289-
var filterProc = new DependencyResolver().GetSearchDataProcessor<T>();
289+
var filterProc = new ServiceLocator().GetSearchDataProcessor<T>();
290290

291291
return filterProc;
292292
}

src/Tests/UnitTests/Tests.UnitTests/SortDataProcessorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class SortDataProcessorTests
2323
[SetUp]
2424
public void SetUp()
2525
{
26-
var resolver = new DependencyResolver();
26+
var resolver = new ServiceLocator();
2727
this.filter = resolver.GetSortDataProcessor<AllTypesModel>();
2828
this.complexFilter = new SortDataProcessor<ComplexModel>();
2929
this.data = DataGenerator.GenerateSimpleData(500, 500);

0 commit comments

Comments
 (0)