-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactory.cs
More file actions
49 lines (39 loc) · 1.79 KB
/
Factory.cs
File metadata and controls
49 lines (39 loc) · 1.79 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
This code is provided "as is" and for educational or experimental purposes only. The author makes no warranties regarding the functionality, reliability, or safety of the code. It is not guaranteed to be production-ready, secure, or free from defects or bugs. Users should use this code at their own risk. The author disclaims any liability for damages resulting from using, modifying, or distributing this code. Before using in a production environment, thorough testing and validation are recommended.
*/
using System;
namespace ikatic.StringMetrics
{
/// <summary>
/// Factory class to use to create instances of specific string metric types.
/// </summary>
public static class Factory
{
/// <summary>
/// Returns a new instance of a string metric specifed, e.g. Jaro-Winkler;
/// </summary>
/// <returns></returns>
public static IMetric Create(Metrics m)
{
switch (m)
{
case Metrics.DamerauLevenshtein:
return new DamerauLevenshtein() as IMetric;
case Metrics.Dice:
return new Dice() as IMetric;
case Metrics.Hamming:
return new Hamming() as IMetric;
case Metrics.Jaro:
return new Jaro() as IMetric;
case Metrics.JaroWinkler:
return new JaroWinkler() as IMetric;
case Metrics.Levenshtein:
return new Levenshtein() as IMetric;
case Metrics.Soundex:
return new Soundex() as IMetric;
default:
throw new Exception("0x00001 - Unrecognized string metric.");
}
}
}
}