コード例 #1
0
        private List <PersonsPairWithAgeDifference> GetPersonPairsWithAgeDifference()
        {
            var personPairs = new List <PersonsPairWithAgeDifference>();

            for (var i = 0; i < _persons.Count - 1; i++)
            {
                for (var j = i + 1; j < _persons.Count; j++)
                {
                    var pair = new PersonsPairWithAgeDifference();
                    if (_persons[i].BirthDate < _persons[j].BirthDate)
                    {
                        pair.YoungerPerson = _persons[i];
                        pair.OlderPerson   = _persons[j];
                    }
                    else
                    {
                        pair.YoungerPerson = _persons[j];
                        pair.OlderPerson   = _persons[i];
                    }

                    pair.AgeDifference = pair.OlderPerson.BirthDate - pair.YoungerPerson.BirthDate;

                    personPairs.Add(pair);
                }
            }

            return(personPairs);
        }
コード例 #2
0
        public PersonsPairWithAgeDifference FindBy(PairingCriteria pairingCriteria)
        {
            var personPairs = GetPersonPairsWithAgeDifference();

            var targetPair = new PersonsPairWithAgeDifference();

            if (personPairs.Any())
            {
                targetPair = FindPairByCriteria(personPairs, pairingCriteria);
            }

            return(targetPair);
        }