-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathMongoDbConfigRepositoryFactory.cs
More file actions
52 lines (43 loc) · 1.96 KB
/
Copy pathMongoDbConfigRepositoryFactory.cs
File metadata and controls
52 lines (43 loc) · 1.96 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
using System;
using System.Security.Authentication;
using MongoDB.Driver;
using SharpRepository.Repository;
using SharpRepository.Repository.Configuration;
namespace SharpRepository.MongoDbRepository
{
public class MongoDbConfigRepositoryFactory : ConfigRepositoryFactory
{
public MongoDbConfigRepositoryFactory(IRepositoryConfiguration config)
: base(config)
{
}
public override IRepository<T> GetInstance<T>()
{
throw new NotImplementedException("MongoDbRepository does not support using IRepository<T> directly to reference a IRepository<T, string>");
}
public override IRepository<T, TKey> GetInstance<T, TKey>()
{
// check for required parameters
if (String.IsNullOrEmpty(RepositoryConfiguration["connectionString"]))
{
throw new ConfigurationErrorsException("The connectionString attribute is required in order to use the MongoDbRepository via the configuration file.");
}
SslSettings sslSettings = null;
if (!String.IsNullOrEmpty(RepositoryConfiguration["sslEnabled"]) && Boolean.Parse(RepositoryConfiguration["sslEnabled"]))
sslSettings = new SslSettings() { EnabledSslProtocols = (SslProtocols)Enum.Parse(typeof(SslProtocols), RepositoryConfiguration["sslProtocol"]) };
return new MongoDbRepository<T, TKey>(RepositoryConfiguration["connectionString"], sslSettings);
}
public override ICompoundKeyRepository<T, TKey, TKey2> GetInstance<T, TKey, TKey2>()
{
throw new NotImplementedException();
}
public override ICompoundKeyRepository<T, TKey, TKey2, TKey3> GetInstance<T, TKey, TKey2, TKey3>()
{
throw new NotImplementedException();
}
public override ICompoundKeyRepository<T> GetCompoundKeyInstance<T>()
{
throw new NotImplementedException();
}
}
}