-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfiguration.cs
More file actions
78 lines (65 loc) · 2.11 KB
/
Configuration.cs
File metadata and controls
78 lines (65 loc) · 2.11 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
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
using System;
using System.Collections.Generic;
using Poco.Sql.NetCore.Interfaces;
namespace Poco.Sql.NetCore
{
public class Configuration
{
private static Object _lock = new Object();
private static bool _initialized;
private static Dictionary<string, object> _mappings = new Dictionary<string, object>();
internal static bool IsPluralizeTableNames { get; private set; }
internal static bool FullGraphSelecttion { get; private set; }
internal static bool ValuesInQueies { get; private set; }
internal static bool CachingDisabled { get; private set; }
internal static bool Comment { get; private set; }
internal static string StoredProceduresPrefix { get; private set; }
internal static Dictionary<string, object> Mappings = new Dictionary<string, object>();
public static void Initialize(Action<Configuration> config)
{
if (_initialized) return;
lock (_lock)
{
if (_initialized) return;
config.Invoke(new Configuration());
_initialized = true;
}
}
public void PluralizeTableNames()
{
IsPluralizeTableNames = true;
}
public void SelectFullGraph()
{
FullGraphSelecttion = true;
}
public void InjectValuesInQueies()
{
ValuesInQueies = true;
}
public void DisableCache()
{
CachingDisabled = true;
}
public void ShowComments()
{
Comment = true;
}
public void SetStoreProcedurePrefix(string prefix)
{
StoredProceduresPrefix = prefix;
}
public void AddMap<T>(PocoSqlMapping<T> mapping)
{
_mappings.Add(typeof(T).FullName, mapping);
}
internal static bool HasMap(string key)
{
return _mappings.ContainsKey(key);
}
internal static IPocoSqlMapping GetMap(string key)
{
return (IPocoSqlMapping)_mappings[key];
}
}
}