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

            base.AddChild(child);
        }
Esempio n. 2
0
        public virtual void AddChild(ModelNodeDefinition child)
        {
            AssertNoHierarchyCycle(child);

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

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