Beispiel #1
0
        public Method AddDestructor()
        {
            Destructor destructor = new Destructor(this);

            OperationList.Add(destructor);
            return(destructor);
        }
Beispiel #2
0
        /// <exception cref="InvalidOperationException">
        /// The type does not support the given kind of member.
        /// </exception>
        public void InsertMember(MemberType type, int index)
        {
            if (type == MemberType.Field)
            {
                if (index > FieldCount)
                {
                    index = FieldCount;
                }
            }
            else
            {
                index -= FieldCount;
                if (index > OperationCount)
                {
                    index = OperationCount;
                }
            }

            if (index < 0)
            {
                index = 0;
            }

            switch (type)
            {
            case MemberType.Field:
                Field field = AddField();
                FieldList.RemoveAt(FieldCount - 1);
                FieldList.Insert(index, field);
                break;

            case MemberType.Method:
                Method method = AddMethod();
                OperationList.RemoveAt(OperationCount - 1);
                OperationList.Insert(index, method);
                break;

            case MemberType.Constructor:
                Constructor constructor = AddConstructor();
                OperationList.RemoveAt(OperationCount - 1);
                OperationList.Insert(index, constructor);
                break;

            case MemberType.Destructor:
                Destructor destructor = AddDestructor();
                OperationList.RemoveAt(OperationCount - 1);
                OperationList.Insert(index, destructor);
                break;

            case MemberType.Property:
                Property property = AddProperty();
                OperationList.RemoveAt(OperationCount - 1);
                OperationList.Insert(index, property);
                break;

            case MemberType.Event:
                Event _event = AddEvent();
                OperationList.RemoveAt(OperationCount - 1);
                OperationList.Insert(index, _event);
                break;
            }
        }