-
Notifications
You must be signed in to change notification settings - Fork 9
/
Enums.cs
71 lines (65 loc) · 2.14 KB
/
Enums.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lucene.Net.Documents;
namespace LukeMapper
{
public enum Store
{
YES,
NO,
COMPRESS
}
public enum Index
{
ANALYZED,
ANALYZED_NO_NORMS,
NO,
NOT_ANALYZED,
NOT_ANALYZED_NO_NORMS
}
public static class EnumExtensions
{
public static Field.Store ToFieldStore(this Store store)
{
switch (store)
{
case Store.NO: return Field.Store.NO;
case Store.COMPRESS: return Field.Store.COMPRESS;
default: return Field.Store.YES;
}
}
public static System.Reflection.FieldInfo ToFieldInfo(this Store store)
{
switch (store)
{
case Store.NO: return typeof(Field.Store).GetField("NO");
case Store.COMPRESS: return typeof(Field.Store).GetField("COMPRESS");
default: return typeof(Field.Store).GetField("YES");
}
}
public static Field.Index ToFieldIndex(this Index store)
{
switch (store)
{
case Index.NO: return Field.Index.NO;
case Index.ANALYZED: return Field.Index.ANALYZED;
case Index.ANALYZED_NO_NORMS: return Field.Index.ANALYZED_NO_NORMS;
case Index.NOT_ANALYZED: return Field.Index.NOT_ANALYZED;
default: return Field.Index.NOT_ANALYZED_NO_NORMS;
}
}
public static System.Reflection.FieldInfo ToFieldInfo(this Index store)
{
switch (store)
{
case Index.NO: return typeof(Field.Index).GetField("NO");
case Index.ANALYZED: return typeof(Field.Index).GetField("ANALYZED");
case Index.ANALYZED_NO_NORMS: return typeof(Field.Index).GetField("ANALYZED_NO_NORMS");
case Index.NOT_ANALYZED: return typeof(Field.Index).GetField("NOT_ANALYZED");
default: return typeof(Field.Index).GetField("NOT_ANALYZED_NO_NORMS");
}
}
}
}