forked from cschladetsch/Flow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreate.cs
78 lines (66 loc) · 1.69 KB
/
Create.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
// (C) 2012 Christian Schladetsch. See http://www.schladetsch.net/flow/license.txt for Licensing information.
using System;
namespace Flow
{
/// <summary>
/// Bootstrapper for the flow library using default implementations
/// </summary>
public static class Create
{
/// <summary>
/// Create a new Kernel and Factory
/// </summary>
/// <returns>
/// The kernel.
/// </returns>
public static IKernel NewKernel()
{
return NewFactory().Kernel;
}
/// <summary>
/// Create a new Kernel and Factory that use a custom time frame
/// </summary>
/// <returns>
/// The kernel.
/// </returns>
public static IKernel NewKernel(ITimeFrame timeFrame)
{
return NewFactory(timeFrame).Kernel;
}
/// <summary>
/// Create a new Kernel and Factory
/// </summary>
/// <returns>
/// The factory.
/// </returns>
public static IFactory NewFactory()
{
return NewFactoryInternal(new TimeFrame());
}
/// <summary>
/// Create a new Kernel and Factory that use a custom time frame
/// </summary>
/// <returns>
/// The factory.
/// </returns>
public static IFactory NewFactory(ITimeFrame timeFrame)
{
return NewFactoryInternal(timeFrame);
}
private static IFactory NewFactoryInternal(ITimeFrame timeFrame)
{
var kernel = new Kernel(timeFrame);
var factory = new Factory();
kernel.Factory = factory;
factory.Kernel = kernel;
kernel.Root = new Node { Kernel = kernel };
return factory;
}
}
}
// Christian: This was added to support Unity 3.x I believe. It produces a warning but I don't want to remove it yet.
#pragma warning disable 1685
namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute { }
}