-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathIFactory.cs
More file actions
50 lines (43 loc) · 1.02 KB
/
Copy pathIFactory.cs
File metadata and controls
50 lines (43 loc) · 1.02 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SharpQuant.Common
{
/// <summary>
/// Lifetime is managed within the client
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IFactory<T>
{
T CreateInstance();
}
interface IFactoryT<T> where T : class
{
T Create(string qualifiedName);
T Create(string qualifiedName, string settings);
T Create(Type t, SettingsDictionary settings);
}
public class DefaultFactory<T> : IFactory<T>
{
public DefaultFactory()
{
}
public T CreateInstance()
{
return Activator.CreateInstance<T>();
}
}
public class ResolverFactory<T> : IFactory<T>
{
IResolver _resolver;
public ResolverFactory(IResolver resolver)
{
_resolver = resolver;
}
public T CreateInstance()
{
return _resolver.Resolve<T>();
}
}
}