public void FieldExpressions_Add_SameKey()
        {
            // Prepare test data
            FieldExpressions expressions = new FieldExpressions();
            FieldExpression  expression  = new FieldExpression(source, "Table", "Field");

            // Perform the test operation
            string a = expressions.Add(expression);
            string b = expressions.Add(expression);

            // Check test result
            Assert.AreEqual(a, b);
        }
Exemple #2
0
        private ISetRuleBuilder <TDestination, TSource> RegisterFieldExpression(string destination, Expression expression)
        {
            if (FieldExpressions.ContainsKey(destination))
            {
                FieldExpressions[destination] = expression;
            }
            else
            {
                FieldExpressions.Add(destination, expression);
            }

            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Performs call to MatchMaker if AutoMatchMembres is True
        /// </summary>
        public void FinalizeRules()
        {
            if (AutoMatchMembers)
            {
                if (MatchMaker == null)
                {
                    throw new NullReferenceException(nameof(MatchMaker));
                }

                var unmappedDestinations = DestinationFields.Where(x => !FieldExpressions.Keys.Contains(x.Key) &&
                                                                   !FieldSkips.Contains(x.Key))
                                           .Select(x => x.Value)
                                           .ToList();

                var matchedPairs = MatchMaker.FindMemberPairs(unmappedDestinations, SourceFields.Values);
                foreach (var pair in matchedPairs)
                {
                    var expression = ExpressionBuilder.GetMapExpression <TSource>(pair.DestinationMember, pair.SourceMember);
                    FieldExpressions.Add(pair.DestinationMember.Name, expression);
                }
            }

            IsFinalized = true;
        }
        public void FieldExpressions_Add_Exception()
        {
            FieldExpressions expressions = new FieldExpressions();

            expressions.Add(null);
        }