/// <summary>
        /// Configure this mapper to map the previously-specified set of enum members to the given
        /// <paramref name="secondEnumMembers"/>.
        /// </summary>
        /// <typeparam name="TSecondEnum">The type of the second enum being paired.</typeparam>
        /// <param name="secondEnumMembers">The second set of enum members in the pairs.</param>
        public void With <TSecondEnum>(params TSecondEnum[] secondEnumMembers) where TSecondEnum : struct
        {
            ThrowIfNotEnumType <TSecondEnum>();
            ThrowIfSameTypes <TSecondEnum>();
            ThrowIfEmpty(secondEnumMembers);
            ThrowIfDifferingNumbers(secondEnumMembers);

            for (var i = 0; i < _firstEnumMembers.Length; i++)
            {
                var firstEnumMember  = _firstEnumMembers[i];
                var secondEnumMember = secondEnumMembers[i];

                ThrowIfAlreadyPaired(firstEnumMember, secondEnumMember);

                var firstToSecondPairing = EnumMemberPair.For(firstEnumMember, secondEnumMember);
                var secondToFirstPairing = EnumMemberPair.For(secondEnumMember, firstEnumMember);

                _configInfo.MapperContext.ValueConverters.Add(firstToSecondPairing.ValueConverter);
                _configInfo.MapperContext.ValueConverters.Add(secondToFirstPairing.ValueConverter);

                _configInfo.MapperContext.UserConfigurations.Add(firstToSecondPairing);
                _configInfo.MapperContext.UserConfigurations.Add(secondToFirstPairing);
            }
        }
Example #2
0
        private void ConfigureEnumPair <TPairing, TPaired>(TPairing pairingEnumMember, TPaired pairedEnumMember)
        {
            var pairing = EnumMemberPair.For(pairingEnumMember, pairedEnumMember);

            MapperContext.UserConfigurations.Add(pairing);
        }