示例#1
0
        public override void AddChild(ModelNodeDefinition child)
        {
            if (!(child is EnumeratorDefinition))
            {
                throw new NotSupportedException("Enum can only contain enumerators");
            }

            base.AddChild(child);
        }
示例#2
0
        public virtual void AddChild(ModelNodeDefinition child)
        {
            AssertNoHierarchyCycle(child);

            if (child.Parent != null)
            {
                child.Parent.RemoveChild(child);
            }

            child.Parent = this;
            Children.Add(child);
        }
示例#3
0
        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");
 }
示例#6
0
 public virtual void RemoveChild(ModelNodeDefinition child)
 {
     Children.Remove(child);
     child.Parent = null;
 }