internal void InsertNewMember(MemberType type)
        {
            int fieldCount = CompositeType.FieldCount;

            switch (type)
            {
            case MemberType.Field:
                if (CompositeType.SupportsFields)
                {
                    int  index    = Math.Min(ActiveMemberIndex + 1, fieldCount);
                    bool changing = (index == fieldCount &&
                                     ActiveMember.MemberType != MemberType.Field);

                    CompositeType.InsertMember(MemberType.Field, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Method:
                if (CompositeType.SupportsMethods)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    CompositeType.InsertMember(MemberType.Method, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Constructor:
                if (CompositeType.SupportsConstuctors)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    CompositeType.InsertMember(MemberType.Constructor, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Destructor:
                if (CompositeType.SupportsDestructors)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    CompositeType.InsertMember(MemberType.Destructor, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Property:
                if (CompositeType.SupportsProperties)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    CompositeType.InsertMember(MemberType.Property, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Event:
                if (CompositeType.SupportsEvents)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    CompositeType.InsertMember(MemberType.Event, index);
                    ActiveMemberIndex = index;
                }
                break;
            }
        }
Exemplo n.º 2
0
        internal Member InsertNewMember(MemberType type)
        {
            int    fieldCount = CompositeType.FieldCount;
            Member newMember  = null;

            switch (type)
            {
            case MemberType.Field:
                if (CompositeType.SupportsFields)
                {
                    int index = Math.Min(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Field, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Method:
                if (CompositeType.SupportsMethods)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Method, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Constructor:
                if (CompositeType.SupportsConstuctors)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Constructor, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Destructor:
                if (CompositeType.SupportsDestructors)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Destructor, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Property:
                if (CompositeType.SupportsProperties)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Property, index);
                    ActiveMemberIndex = index;
                }
                break;

            case MemberType.Event:
                if (CompositeType.SupportsEvents)
                {
                    int index = Math.Max(ActiveMemberIndex + 1, fieldCount);
                    newMember         = CompositeType.InsertMember(MemberType.Event, index);
                    ActiveMemberIndex = index;
                }
                break;

            default:
                throw new ArgumentException($"{type.ToString()} is not a valid member type", nameof(type));
            }

            return(newMember);
        }