forked from samus/mongodb-csharp
/
ConventionProfile.cs
199 lines (176 loc) · 6.77 KB
/
ConventionProfile.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
namespace MongoDB.Configuration.Mapping.Conventions
{
/// <summary>
///
/// </summary>
public class ConventionProfile
{
private IAliasConvention _aliasConvention;
private ICollectionAdapterConvention _collectionAdapterConvention;
private ICollectionNameConvention _collectionNameConvention;
private IDefaultValueConvention _defaultValueConvention;
private IDiscriminatorConvention _discriminatorConvention;
private IDiscriminatorAliasConvention _discriminatorAliasConvention;
private IExtendedPropertiesConvention _extendedPropertiesConvention;
private IIdConvention _idConvention;
private IIdGeneratorConvention _idGeneratorConvention;
private IIdUnsavedValueConvention _idUnsavedValueConvention;
/// <summary>
/// Gets or sets the alias convention.
/// </summary>
/// <value>The alias convention.</value>
public IAliasConvention AliasConvention
{
get { return _aliasConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_aliasConvention = value;
}
}
/// <summary>
/// Gets or sets the collection adapter convention.
/// </summary>
/// <value>The collection adapter convention.</value>
public ICollectionAdapterConvention CollectionAdapterConvention
{
get { return _collectionAdapterConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_collectionAdapterConvention = value;
}
}
/// <summary>
/// Gets or sets the collection name convention.
/// </summary>
/// <value>The collection name convention.</value>
public ICollectionNameConvention CollectionNameConvention
{
get { return _collectionNameConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_collectionNameConvention = value;
}
}
/// <summary>
/// Gets or sets the default value convention.
/// </summary>
/// <value>The default value convention.</value>
public IDefaultValueConvention DefaultValueConvention
{
get { return _defaultValueConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_defaultValueConvention = value;
}
}
/// <summary>
/// Gets or sets the discriminator convention.
/// </summary>
/// <value>The discriminator convention.</value>
public IDiscriminatorConvention DiscriminatorConvention
{
get { return _discriminatorConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_discriminatorConvention = value;
}
}
/// <summary>
/// Gets or sets the discriminator alias convention.
/// </summary>
/// <value>The discriminator alias convention.</value>
public IDiscriminatorAliasConvention DiscriminatorAliasConvention
{
get { return _discriminatorAliasConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_discriminatorAliasConvention = value;
}
}
/// <summary>
/// Gets or sets the extended properties convention.
/// </summary>
/// <value>The extended properties convention.</value>
public IExtendedPropertiesConvention ExtendedPropertiesConvention
{
get { return this._extendedPropertiesConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_extendedPropertiesConvention = value;
}
}
/// <summary>
/// Gets or sets the id convention.
/// </summary>
/// <value>The id convention.</value>
public IIdConvention IdConvention
{
get { return _idConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_idConvention = value;
}
}
/// <summary>
/// Gets or sets the id generator convention.
/// </summary>
/// <value>The id generator convention.</value>
public IIdGeneratorConvention IdGeneratorConvention
{
get { return _idGeneratorConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_idGeneratorConvention = value;
}
}
/// <summary>
/// Gets or sets the id unsaved value convention.
/// </summary>
/// <value>The id unsaved value convention.</value>
public IIdUnsavedValueConvention IdUnsavedValueConvention
{
get { return _idUnsavedValueConvention; }
set
{
if (value == null)
throw new ArgumentNullException("value");
_idUnsavedValueConvention = value;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="ConventionProfile"/> class.
/// </summary>
public ConventionProfile()
{
_aliasConvention = new DelegateAliasConvention(m => m.Name);
_collectionNameConvention = new DelegateCollectionNameConvention(t => t.Name);
_collectionAdapterConvention = DefaultCollectionAdapterConvention.Instance;
_defaultValueConvention = DefaultDefaultValueConvention.Instance;
_discriminatorConvention = new DelegateDiscriminatorConvention(t => t.Name);
_discriminatorAliasConvention = new DelegateDiscriminatorAliasConvention(t => "_t");
_extendedPropertiesConvention = new DelegateExtendedPropertiesConvention(m => m.Name == "ExtendedProperties");
_idConvention = new DelegateIdConvention(m => m.Name == "Id");
_idGeneratorConvention = DefaultIdGeneratorConvention.Instance;
_idUnsavedValueConvention = DefaultIdUnsavedValueConvention.Instance;
}
}
}