Exemplo n.º 1
0
        void FollowUp(FlagStatus status)
        {
            switch (status)
            {
            case FlagStatus.Today: SelectedItem.DueDate = DateTime.Today;
                break;

            case FlagStatus.Tomorrow: SelectedItem.DueDate = DateTime.Today.AddDays(1);
                break;

            case FlagStatus.ThisWeek: SelectedItem.DueDate = EvalHelpers.GetWeekStart(DateTime.Today).AddDays(5);
                break;

            case FlagStatus.NextWeek: SelectedItem.DueDate = EvalHelpers.GetWeekStart(DateTime.Today).AddDays(12);
                break;

            case FlagStatus.NoDate: SelectedItem.DueDate = null;
                break;

            case FlagStatus.Custom:
                var model = CustomFlagViewModel.Create(SelectedItem.StartDate, SelectedItem.DueDate);
                if (this.GetService <IDialogService>().ShowDialog(MessageButton.OKCancel, "Custom", "CustomFlagView", model) == MessageResult.OK)
                {
                    SelectedItem.StartDate = model.StartDate;
                    SelectedItem.DueDate   = model.DueDate;
                }
                break;
            }
            SelectedItem.Complete = false;
        }
Exemplo n.º 2
0
        static Expression MakeLinq(ICriteriaToExpressionConverter converter, Expression vExpr, Expression pExpr)
        {
            if (pExpr.NodeType == ExpressionType.Constant)
            {
                object boxedVal = ((ConstantExpression)pExpr).Value;
                string pattern  = boxedVal != null?boxedVal.ToString() : null;

                if (pattern == null)
                {
                    return(Expression.Constant(false));
                }
                string body        = pattern;
                bool   lastPercent = body.EndsWith("%");
                if (lastPercent)
                {
                    body = body.Substring(0, body.Length - 1);
                }
                bool firstPercent = body.StartsWith("%");
                if (firstPercent)
                {
                    body = body.Substring(1);
                }
                if (!body.Contains('%') && !body.Contains('_') && !body.Contains('[') && (lastPercent || firstPercent))
                {
                    var stringExpr = EvalHelpers.SafeToString(vExpr);
                    {
                        var maybeIifConverter = converter as CriteriaToExpressionConverterInternal;
                        if (maybeIifConverter != null && maybeIifConverter.ForceIifForInstance)
                        {
                            Expression <Func <string, bool> > method;
                            if (!firstPercent)
                            {
                                method = s => s != null?s.StartsWith(body) : false;
                            }
                            else if (!lastPercent)
                            {
                                method = s => s != null?s.EndsWith(body) : false;
                            }
                            else
                            {
                                method = s => s != null?s.Contains(body) : false;
                            }
                            return(Expression.Invoke(Expression.Constant(method), stringExpr));
                        }
                    }
                    string methodName;
                    if (!firstPercent)
                    {
                        methodName = "StartsWith";
                    }
                    else if (!lastPercent)
                    {
                        methodName = "EndsWith";
                    }
                    else
                    {
                        methodName = "Contains";
                    }
                    return(Expression.Call(stringExpr, methodName, null, Expression.Constant(body)));
                }
            }
            return(((ICustomFunctionOperatorConvertibleToExpression)LikeFunction.Original).Convert(converter, vExpr, pExpr));
        }