Repository navigation
Expand file tree
/
Copy pathEditorScalarValue.cs
More file actions
102 lines (83 loc) · 2.42 KB
/
Copy pathEditorScalarValue.cs
File metadata and controls
102 lines (83 loc) · 2.42 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using RPGCore.DataEditor.Manifest;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
namespace RPGCore.DataEditor;
/// <summary>
/// An editable value.
/// </summary>
public class EditorScalarValue<T> : EditorScalarValue
{
/// <summary>
/// A <typeparamref name="T"/> representing the value of this <see cref="EditorScalarValue"/>.
/// </summary>
public new T? Value
{
get => base.Value == null ? default : (T)base.Value;
set => base.Value = value;
}
internal EditorScalarValue(EditorSession session, TypeName type) : base(session, type, default(T))
{
}
internal EditorScalarValue(EditorSession session, TypeName type, T? value) : base(session, type, value)
{
}
}
/// <summary>
/// An editable value.
/// </summary>
public class EditorScalarValue : IEditorValue
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private object? internalValue;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly List<string> comments;
/// <inheritdoc/>
public IList<string> Comments => comments;
/// <inheritdoc/>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public EditorSession Session { get; }
/// <summary>
/// The type of this <see cref="EditorScalarValue"/>.
/// </summary>
public TypeName Type { get; }
/// <summary>
/// An <see cref="object"/> representing the value of this <see cref="EditorScalarValue"/>.
/// </summary>
public object? Value
{
get => internalValue;
set
{
internalValue = value;
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Value)));
}
}
/// <summary>
/// A collection of <see cref="IEditorFeature"/>s associated with this <see cref="EditorScalarValue"/>.
/// </summary>
public FeatureCollection<EditorScalarValue> Features { get; }
/// <inheritdoc/>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
FeatureCollection IEditorToken.Features => Features;
/// <inheritdoc/>
public event PropertyChangedEventHandler PropertyChanged;
internal EditorScalarValue(EditorSession session, TypeName type)
{
Session = session;
comments = new List<string>();
Features = new FeatureCollection<EditorScalarValue>(this);
Type = type;
PropertyChanged = delegate { };
}
internal EditorScalarValue(EditorSession session, TypeName type, object? value)
: this(session, type)
{
Value = value;
}
/// <inheritdoc/>
public IEditorValue Duplicate()
{
return new EditorScalarValue(Session, Type, Value);
}
}