forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHbmExtensions.cs
88 lines (83 loc) · 2.21 KB
/
HbmExtensions.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using NHibernate.Engine;
namespace NHibernate.Cfg.MappingSchema
{
public static class HbmExtensions
{
public static Versioning.OptimisticLock ToOptimisticLock(this HbmOptimisticLockMode hbmOptimisticLockMode)
{
switch (hbmOptimisticLockMode)
{
case HbmOptimisticLockMode.None:
return Versioning.OptimisticLock.None;
case HbmOptimisticLockMode.Version:
return Versioning.OptimisticLock.Version;
case HbmOptimisticLockMode.Dirty:
return Versioning.OptimisticLock.Dirty;
case HbmOptimisticLockMode.All:
return Versioning.OptimisticLock.All;
default:
return Versioning.OptimisticLock.Version;
}
}
public static string ToNullValue(this HbmUnsavedValueType unsavedValueType)
{
switch (unsavedValueType)
{
case HbmUnsavedValueType.Undefined:
return "undefined";
case HbmUnsavedValueType.Any:
return "any";
case HbmUnsavedValueType.None:
return "none";
default:
throw new ArgumentOutOfRangeException("unsavedValueType");
}
}
public static string ToCacheConcurrencyStrategy(this HbmCacheUsage cacheUsage)
{
switch (cacheUsage)
{
case HbmCacheUsage.ReadOnly:
return "read-only";
case HbmCacheUsage.ReadWrite:
return "read-write";
case HbmCacheUsage.NonstrictReadWrite:
return "nonstrict-read-write";
case HbmCacheUsage.Transactional:
return "transactional";
case HbmCacheUsage.Never:
return "never";
default:
throw new ArgumentOutOfRangeException("cacheUsage");
}
}
public static CacheMode? ToCacheMode(this HbmCacheMode cacheMode)
{
switch (cacheMode)
{
case HbmCacheMode.Get:
return CacheMode.Get;
case HbmCacheMode.Ignore:
return CacheMode.Ignore;
case HbmCacheMode.Normal:
return CacheMode.Normal;
case HbmCacheMode.Put:
return CacheMode.Put;
case HbmCacheMode.Refresh:
return CacheMode.Refresh;
default:
throw new ArgumentOutOfRangeException("cacheMode");
}
}
public static string JoinString(this string[] source)
{
if (source != null)
{
string result = string.Join(System.Environment.NewLine, source).Trim();
return result.Length == 0 ? null : result;
}
return null;
}
}
}