-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReference.cs
More file actions
51 lines (43 loc) · 954 Bytes
/
Reference.cs
File metadata and controls
51 lines (43 loc) · 954 Bytes
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
using System;
/// <summary>
/// Reference Class.
/// </summary>
[Serializable]
public abstract class Reference
{
}
/// <summary>
/// Reference Class.
/// </summary>
[Serializable]
public class Reference<T, G> : Reference where G : Variable<T>
{
public bool UseConstant = true;
public T ConstantValue;
public G Variable;
public Reference() { }
public Reference(T value)
{
UseConstant = true;
ConstantValue = value;
}
public T Value
{
get { return UseConstant ? ConstantValue : Variable.Value; }
set
{
if (UseConstant)
ConstantValue = value;
else
Variable.Value = value;
}
}
public static implicit operator T(Reference<T, G> Reference)
{
return Reference.Value;
}
public static implicit operator Reference<T, G>(T Value)
{
return new Reference<T, G>(Value);
}
}