public override void AddChild(ModelNodeDefinition child) { if (!(child is EnumeratorDefinition)) { throw new NotSupportedException("Enum can only contain enumerators"); } base.AddChild(child); }
public virtual void AddChild(ModelNodeDefinition child) { AssertNoHierarchyCycle(child); if (child.Parent != null) { child.Parent.RemoveChild(child); } child.Parent = this; Children.Add(child); }
private void AssertNoHierarchyCycle(ModelNodeDefinition nodeToAdd) { var parent = this; while (parent != null) { if (parent == nodeToAdd) { throw new InvalidOperationException("Cannot create node hierarchy cycle"); } parent = parent.Parent; } }
public override void AddChild(ModelNodeDefinition child) { if (child is NamespaceDefinition) { throw new ArgumentException("Cannot add namespace to class", nameof(child)); } var method = child as MethodDefinition; if (method != null) { method.Header = Header; } base.AddChild(child); }
public override void AddChild(ModelNodeDefinition child) { throw new NotSupportedException("Method cannot have children"); }
public virtual void RemoveChild(ModelNodeDefinition child) { Children.Remove(child); child.Parent = null; }