Пример #1
0
        private static Expression getExpressionForStrings <T>(
            List <string> standardInputTextValues,
            ParameterExpression parameter)
        {
            return(standardInputTextValues
                   .Select(value =>
            {
                if (value.Equals(TermExtractions.BIRTHDAY))
                {
                    var todayAsBirthday = BirthdayUtils.GetNowAsBirthdayString();
                    return BIRTHDAY_STRING.ToExpression <T>(
                        STRING_EQUALS_METHOD, todayAsBirthday, parameter);
                }

                // For the partial match strings, we search without quotation marks.
                var valueForPartialStrings = value.Replace("\"", "");
                var partialMatches = STRING_PARTIAL.Select(member =>
                                                           member.ToExpression <T>(
                                                               "Contains", valueForPartialStrings, parameter));

                var fullMatches = STRING_FULL_MATCH.Select(
                    member => member.ToExpression <T>(
                        STRING_EQUALS_METHOD, value, parameter));

                return partialMatches.Union(fullMatches)
                .Aggregate(Expression.OrElse);
            }).Aggregate(Expression.AndAlso));
        }
Пример #2
0
        private bool isBirthdayToday()
        {
            var today = DateTime.Today;
            // TODO(Josh): Extract this because it is shared with the queryable extension class.
            var todayDispalayString = String.Format("{0}.{1}",
                                                    today.Day.ToString("D2"),
                                                    today.Month.ToString("D2"));
            var personBirthday = person.BirthdayDisplayString;

            return(personBirthday != null &&
                   person.BirthdayDisplayString
                   .Equals(BirthdayUtils.GetNowAsBirthdayString()));
        }