/
LiteralExpression.cs
50 lines (41 loc) · 1.28 KB
/
LiteralExpression.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
using System;
using StructureMap.Graph;
namespace StructureMap.Configuration.DSL
{
/// <summary>
/// Small helper class to represent an object to be plugged into a PluginType as is
/// </summary>
/// <typeparam name="T"></typeparam>
public class LiteralExpression<T> : MementoBuilder<LiteralExpression<T>>
{
private readonly T _target;
private LiteralMemento _memento;
public LiteralExpression(T target) : base(typeof (T))
{
_target = target;
}
protected override InstanceMemento memento
{
get { return _memento; }
}
protected override LiteralExpression<T> thisInstance
{
get { return this; }
}
protected override void configureMemento(PluginFamily family)
{
_memento.Instance = _target;
}
protected override void validate()
{
}
protected override void buildMemento()
{
_memento = new LiteralMemento(null);
}
public override void ValidatePluggability(Type pluginType)
{
ExpressionValidator.ValidatePluggabilityOf(_target.GetType()).IntoPluginType(pluginType);
}
}
}