/
ConfigurationContainer.cs
42 lines (40 loc) · 1.27 KB
/
ConfigurationContainer.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
using System.Globalization;
using Norm.BSON.TypeConverters;
namespace Norm.Configuration
{
/// <summary>
/// Mongo configuration container
/// </summary>
public class ConfigurationContainer : MongoConfigurationMap, IConfigurationContainer
{
public ConfigurationContainer()
{
TypeConverterFor<CultureInfo, CultureInfoTypeConverter>();
}
/// <summary>
/// Registers a Mongo Configuration Map by calling the default
/// constructor of T (so that's where you should add your mapping logic)
/// </summary>
/// <remarks>
/// BY CONVENTION, the default constructor of T should register the mappings that are relevant.
/// </remarks>
/// <typeparam retval="T">
/// The type of the map that should be added.
/// </typeparam>
public void AddMap<T>() where T : IMongoConfigurationMap, new()
{
//this is semi-magical, look at remarks as to why this does anything.
new T();
}
/// <summary>
/// Gets the configuration map.
/// </summary>
/// <returns>
/// </returns>
public IMongoConfigurationMap GetConfigurationMap()
{
return this;
}
}
}