-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathEditorObject.cs
More file actions
68 lines (54 loc) · 1.72 KB
/
Copy pathEditorObject.cs
File metadata and controls
68 lines (54 loc) · 1.72 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
using RPGCore.DataEditor.Manifest;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
namespace RPGCore.DataEditor;
/// <summary>
/// An editable data structure that uses hard-typed fields.
/// </summary>
public class EditorObject : IEditorValue
{
[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 the current instance of the <see cref="EditorObject"/>.
/// </summary>
public TypeName Type { get; }
/// <summary>
/// All <see cref="EditorField"/> contained within this object.
/// </summary>
public EditorFieldCollection Fields { get; }
/// <summary>
/// A collection of <see cref="IEditorFeature"/>s associated with this <see cref="EditorObject"/>.
/// </summary>
public FeatureCollection<EditorObject> Features { get; }
/// <inheritdoc/>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
FeatureCollection IEditorToken.Features => Features;
/// <inheritdoc/>
public event PropertyChangedEventHandler PropertyChanged;
internal EditorObject(EditorSession session, TypeName type)
{
Session = session;
Type = type;
comments = new List<string>();
Fields = new EditorFieldCollection(this);
Features = new FeatureCollection<EditorObject>(this);
PropertyChanged = delegate { };
}
/// <inheritdoc/>
public IEditorValue Duplicate()
{
var editorObject = new EditorObject(Session, Type);
foreach (var field in Fields)
{
editorObject.Fields[field.Name]!.Value.Value = field.Value.Value.Duplicate();
}
return editorObject;
}
}