-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidationAlgorithmEngine.cs
More file actions
32 lines (27 loc) · 934 Bytes
/
Copy pathValidationAlgorithmEngine.cs
File metadata and controls
32 lines (27 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.Algorithms
{
public class ValidationAlgorithmEngine : IValidationAlgorithmEngine
{
private readonly List<IValidationAlgorithm> _algorithms;
public ValidationAlgorithmEngine()
{
_algorithms = new List<IValidationAlgorithm>();
_algorithms.Add(new FiscalNo());
_algorithms.Add(new Mod_97_10());
_algorithms.Add(new Mod10());
}
public bool isValid(string barcode, AlgorithmType type)
{
return _algorithms.First(r => r.isMatch(type)).isValid(barcode.Trim());
}
public bool isValid(string barcode, string validationAlgorithm)
{
return _algorithms.First(r => r.isMatch(validationAlgorithm)).isValid(barcode.Trim());
}
}
}