4 using System.Collections.Generic;
7 using SiliconStudio.Quantum.Contents;
9 namespace SiliconStudio.Quantum
16 private readonly List<IModelNode> children =
new List<IModelNode>();
17 private readonly List<INodeCommand> commands =
new List<INodeCommand>();
19 private bool isSealed;
29 if (name == null)
throw new ArgumentNullException(
"name");
30 if (content == null)
throw new ArgumentNullException(
"content");
31 if (guid == Guid.Empty)
throw new ArgumentException(
@"The guid must be differ from Guid.Empty.",
"content");
32 this.content = content;
38 public string Name {
get;
private set; }
41 public Guid Guid {
get;
private set; }
44 public virtual IContent Content {
get {
return content; } set { content = value; } }
50 public IReadOnlyCollection<IModelNode> Children {
get {
return children; } }
53 public IReadOnlyCollection<INodeCommand>
Commands {
get {
return commands; } }
62 throw new InvalidOperationException(
"Unable to add a child to a ModelNode that has been sealed");
65 throw new ArgumentException(
@"This node has already been registered to a different parent",
"child");
67 if (Content.Reference != null)
68 throw new InvalidOperationException(
"A ModelNode cannot have children when its content hold a reference.");
81 throw new InvalidOperationException(
"Unable to add a command to a ModelNode that has been sealed");
83 commands.Add(command);
93 throw new InvalidOperationException(
"Unable to add a child to a ModelNode that has been sealed");
95 commands.Remove(command);
109 return string.Format(
"{0}: [{1}]", Name, Content.Value);
virtual IModelNode Parent
This class is the default implementation of the IModelNode.
override string ToString()
Base interface for node commands.
void RemoveCommand(INodeCommand command)
Remove a command from this node. The node must not have been sealed yet.
void AddCommand(INodeCommand command)
Add a command to this node. The node must not have been sealed yet.
The IModelNode interface represents a node in a model object. A model object is represented by a grap...
void Seal()
Seal the node, indicating its construction is finished and that no more children or commands will be ...
void AddChild(ModelNode child)
Add a child to this node. The node must not have been sealed yet.