21 lines
694 B
C#
21 lines
694 B
C#
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);
|
|
}
|
|
}
|
|
}
|