예제 #1
0
        /// <summary>
        /// Adds an enum member to this enum type.
        /// </summary>
        /// <param name="member">The member being added.</param>
        /// <returns>The <see cref="EnumMemberConfiguration"/> so that the member can be configured further.</returns>
        public EnumMemberConfiguration AddMember(Enum member)
        {
            if (member == null)
            {
                throw Error.ArgumentNull("member");
            }

            if (member.GetType() != ClrType)
            {
                throw Error.Argument("member", SRResources.PropertyDoesNotBelongToType, member.ToString(), ClrType.FullName);
            }

            // Remove from the ignored members
            if (RemovedMembers.Contains(member))
            {
                RemovedMembers.Remove(member);
            }

            EnumMemberConfiguration memberConfiguration;

            if (ExplicitMembers.ContainsKey(member))
            {
                memberConfiguration = ExplicitMembers[member];
            }
            else
            {
                memberConfiguration     = new EnumMemberConfiguration(member, this);
                ExplicitMembers[member] = memberConfiguration;
            }

            return(memberConfiguration);
        }
예제 #2
0
        /// <summary>
        /// Removes the given member.
        /// </summary>
        /// <param name="member">The member being removed.</param>
        public void RemoveMember(Enum member)
        {
            if (member == null)
            {
                throw Error.ArgumentNull("member");
            }

            if (member.GetType() != ClrType)
            {
                throw Error.Argument("member", SRResources.PropertyDoesNotBelongToType, member.ToString(), ClrType.FullName);
            }

            if (ExplicitMembers.ContainsKey(member))
            {
                ExplicitMembers.Remove(member);
            }

            if (!RemovedMembers.Contains(member))
            {
                RemovedMembers.Add(member);
            }
        }