-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathRepositoryConfiguration.cs
More file actions
85 lines (65 loc) · 2.71 KB
/
Copy pathRepositoryConfiguration.cs
File metadata and controls
85 lines (65 loc) · 2.71 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
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
namespace SharpRepository.Repository.Configuration
{
public class RepositoryConfiguration : IRepositoryConfiguration
{
public RepositoryConfiguration()
{
Attributes = new Dictionary<string, string>();
}
public RepositoryConfiguration(string name)
{
Name = name;
Attributes = new Dictionary<string, string>();
}
public string Name { get; set; }
private Type _factory;
public Type Factory
{
get { return _factory; }
set
{
ConfigurationHelper.CheckForInterface(value, typeof(IConfigRepositoryFactory));
_factory = value;
}
}
public string CachingStrategy { get; set; }
public string CachingProvider { get; set; }
public IDictionary<string, string> Attributes { get; set; }
public virtual IRepository<T> GetInstance<T>() where T : class, new()
{
// load up the factory if it exists and use it
var factory = (IConfigRepositoryFactory)Activator.CreateInstance(Factory, this);
return factory.GetInstance<T>();
}
public virtual IRepository<T, TKey> GetInstance<T, TKey>() where T : class, new()
{
// load up the factory if it exists and use it
var factory = (IConfigRepositoryFactory)Activator.CreateInstance(Factory, this);
return factory.GetInstance<T, TKey>();
}
public virtual ICompoundKeyRepository<T, TKey, TKey2> GetInstance<T, TKey, TKey2>() where T : class, new()
{
// load up the factory if it exists and use it
var factory = (IConfigRepositoryFactory)Activator.CreateInstance(Factory, this);
return factory.GetInstance<T, TKey, TKey2>();
}
public virtual ICompoundKeyRepository<T, TKey, TKey2, TKey3> GetInstance<T, TKey, TKey2, TKey3>() where T : class, new()
{
// load up the factory if it exists and use it
var factory = (IConfigRepositoryFactory)Activator.CreateInstance(Factory, this);
return factory.GetInstance<T, TKey, TKey2, TKey3>();
}
public virtual ICompoundKeyRepository<T> GetCompoundKeyInstance<T>() where T : class, new()
{
// load up the factory if it exists and use it
var factory = (IConfigRepositoryFactory)Activator.CreateInstance(Factory, this);
return factory.GetCompoundKeyInstance<T>();
}
public string this[string key]
{
get { return Attributes.ContainsKey(key) ? Attributes[key] : null; }
}
}
}