forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchemaAction.cs
57 lines (53 loc) · 1.1 KB
/
SchemaAction.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
using System;
using System.Collections.Generic;
using System.Linq;
namespace NHibernate.Mapping.ByCode
{
[Flags]
public enum SchemaAction
{
None = 0,
Drop = 1,
Update = 2,
Export = 4,
Validate = 8,
All = Drop | Update | Export | Validate
}
public static class SchemaActionConverter
{
public static string ToSchemaActionString(this SchemaAction source)
{
return source == SchemaAction.All ? null : string.Join(",", source.SchemaActionDefinitions().ToArray());
}
public static bool Has(this SchemaAction source, SchemaAction value)
{
return (source & value) == value;
}
private static IEnumerable<string> SchemaActionDefinitions(this SchemaAction source)
{
if (SchemaAction.None.Equals(source))
{
yield return "none";
}
else
{
if (source.Has(SchemaAction.Drop))
{
yield return "drop";
}
if (source.Has(SchemaAction.Update))
{
yield return "update";
}
if (source.Has(SchemaAction.Export))
{
yield return "export";
}
if (source.Has(SchemaAction.Validate))
{
yield return "validate";
}
}
}
}
}