Push project
This commit is contained in:
20
Sorting/SortingService.cs
Normal file
20
Sorting/SortingService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using SortingModel.SortingAlgorithms;
|
||||
using SortingModel.SortingAlgorithms.Interfaces;
|
||||
|
||||
namespace SortingModel
|
||||
{
|
||||
public class SortingService : ISortingService
|
||||
{
|
||||
private readonly ISortingAlgorithmFactory _factory;
|
||||
|
||||
public SortingService(ISortingAlgorithmFactory? factory = null) => this._factory = factory ?? new SortingAlgorithmFactory();
|
||||
|
||||
public IEnumerable<string> GetAvailableAlgorithmNames() => this._factory.GetAvailableAlgorithmNames();
|
||||
|
||||
public string SortText(string inputText, string strategy)
|
||||
{
|
||||
ISortingAlgorithm algorithm = this._factory.Create(strategy);
|
||||
return algorithm.Sort(inputText);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user