Пример #1
0
 protected override void AddChildInternal(BaseConstruct childBC)
 {
     if (childBC is Region)
     {
         regions.Add(childBC as Region);
     }
     else
     {
         throw new ArgumentException("Cannot add child of type " + childBC.GetType() + "to a " + GetType());
     }
 }
Пример #2
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC"></param>
        protected override void AddChildInternal(BaseConstruct childBC)
        {
            if (childBC == null)
                throw new InvalidOperationException("Cannot add null child");

            if (childBC is Attribute)
            {
                singleAttributes.Add((Attribute)childBC);
            }
            else
                throw new InvalidOperationException("Cannot add child of type " + childBC.GetType());
        }
Пример #3
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC"></param>
        protected override void AddChildInternal(BaseConstruct childBC)
        {
            if (childBC == null)
            {
                throw new InvalidOperationException("Cannot add null child");
            }

            if (childBC is Attribute)
            {
                singleAttributes.Add((Attribute)childBC);
            }
            else
            {
                throw new InvalidOperationException("Cannot add child of type " + childBC.GetType());
            }
        }
Пример #4
0
        protected override void RemoveChildObjectInternal(BaseConstruct childBC)
        {
            if (childBC == null)
                throw new InvalidOperationException("Cannot remove null child");

            if (childBC is PropertyAccessor)
            {
                PropertyAccessor accessor = (PropertyAccessor)childBC;
                if (accessor == GetAccessor)
                    GetAccessor = null;
                else if (accessor == SetAccessor)
                    SetAccessor = null;
                else
                    throw new InvalidOperationException("The accessor does not belong to this Property");
            }
            else
                throw new InvalidOperationException("Cannot remove child of type " + childBC.GetType());
        }
Пример #5
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC"></param>
        protected override void AddChildInternal(BaseConstruct childBC)
        {
            if (childBC == null)
                throw new InvalidOperationException("Cannot add null child");

            if (childBC is PropertyAccessor)
            {
                PropertyAccessor newAccessor = (PropertyAccessor)childBC;
                if (newAccessor.AccessorType == PropertyAccessor.AccessorTypes.Get)
                    GetAccessor = newAccessor;
                else
                    SetAccessor = newAccessor;
            }
            else
                throw new InvalidOperationException("Cannot add child of type " + childBC.GetType());
        }
Пример #6
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC"></param>
        protected override void AddChildInternal(BaseConstruct childBC)
        {
            if (childBC == null)
                throw new InvalidOperationException("Cannot add null child");

            if (childBC is EnumMember)
            {
                Members.Add(childBC as EnumMember);
            }
            else
                throw new InvalidOperationException("Cannot add child of type " + childBC.GetType());
        }
Пример #7
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="child">The child object to add.</param>
        protected override void AddChildInternal(BaseConstruct child)
        {
            if(child == null)
                throw new InvalidOperationException("Cannot add null child");

            if (child is InterfaceIndexer)
            {
                Indexers.Add(child as InterfaceIndexer);
            }
            else if (child is InterfaceMethod)
            {
                Methods.Add(child as InterfaceMethod);
            }
            else if (child is InterfaceProperty)
            {
                Properties.Add(child as InterfaceProperty);
            }
            else if (child is InterfaceEvent)
            {
                Events.Add(child as InterfaceEvent);
            }

            else
                throw new InvalidOperationException("Cannot add child of type " + child.GetType());
        }
Пример #8
0
        public BaseConstruct ParseSingleConstruct(string code, BaseConstruct existingConstruct)
        {
            if (existingConstruct is Namespace)
            {
                return ParseSingleConstruct(code, BaseConstructType.NamespaceDeclaration);
            }
            if (existingConstruct is Interface)
            {
                return ParseSingleConstruct(code, BaseConstructType.InterfaceDeclaration);
            }
            if (existingConstruct is Class)
            {
                return ParseSingleConstruct(code, BaseConstructType.ClassDeclaration);
            }
            if (existingConstruct is UsingStatement)
            {
                return ParseSingleConstruct(code, BaseConstructType.UsingDirective);
            }
            if (existingConstruct is Struct)
            {
                return ParseSingleConstruct(code, BaseConstructType.StructureDeclaration);
            }
            if (existingConstruct is Constructor)
            {
                return ParseSingleConstruct(code, BaseConstructType.ConstructorDeclaration);
            }
            if (existingConstruct is Destructor)
            {
                return ParseSingleConstruct(code, BaseConstructType.DestructorDeclaration);
            }
            if (existingConstruct is Delegate)
            {
                return ParseSingleConstruct(code, BaseConstructType.DelegateDeclaration);
            }
            if (existingConstruct is Enumeration)
            {
                return ParseSingleConstruct(code, BaseConstructType.EnumerationDeclaration);
            }
            if (existingConstruct is Event)
            {
                return ParseSingleConstruct(code, BaseConstructType.EventDeclaration);
            }
            if (existingConstruct is Field)
            {
                return ParseSingleConstruct(code, BaseConstructType.FieldDeclaration);
            }
            if (existingConstruct is Function)
            {
                return ParseSingleConstruct(code, BaseConstructType.MethodDeclaration);
            }
            if (existingConstruct is Operator)
            {
                return ParseSingleConstruct(code, BaseConstructType.OperatorDeclaration);
            }
            if (existingConstruct is Property)
            {
                return ParseSingleConstruct(code, BaseConstructType.PropertyDeclaration);
            }
            if (existingConstruct is Enumeration.EnumMember)
            {
                return ParseSingleConstruct(code, BaseConstructType.EnumerationMemberDeclaration);
            }
            if (existingConstruct is InterfaceEvent)
            {
                return ParseSingleConstruct(code, BaseConstructType.InterfaceEventDeclaration);
            }
            if (existingConstruct is InterfaceMethod)
            {
                return ParseSingleConstruct(code, BaseConstructType.InterfaceMethodDeclaration);
            }
            if (existingConstruct is InterfaceProperty)
            {
                return ParseSingleConstruct(code, BaseConstructType.InterfacePropertyDeclaration);
            }

            throw new ArgumentException("Unsupported type: " + existingConstruct.GetType());
        }
Пример #9
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="child">The child object to add.</param>
        protected override void AddChildInternal(BaseConstruct child)
        {
            if (child == null)
                throw new InvalidOperationException("Cannot add null child");

            if (child is Event)
            {
                Events.Add(child as Event);
            }
            else if (child is Class)
            {
                Classes.Add(child as Class);
            }
            else if (child is Struct)
            {
                Structs.Add(child as Struct);
            }
            else if (child is Enumeration)
            {
                Enums.Add(child as Enumeration);
            }
            else if (child is Interface)
            {
                Interfaces.Add(child as Interface);
            }
            else if (child is Delegate)
            {
                Delegates.Add(child as Delegate);
            }
            else if (child is Region)
            {
                Regions.Add(child as Region);
            }
            else if (child is Namespace)
            {
                InnerNamespaces.Add(child as Namespace);
            }
            else if (child is UsingStatement)
            {
                UsingStatements.Add(child as UsingStatement);
            }
            else
                throw new InvalidOperationException("Cannot add child of type " + child.GetType());
        }