コード例 #1
0
        public bool TryGetAffectableEntityInfo(string targetValueName, out AffectableEntityInfo info)
        {
            var rtn = new List <AffectableEntityInfo>();

            foreach (var entityInfo in _affectableCache.Values)
            {
                var result = entityInfo.PropertyExpressions.Values.FirstOrDefault(
                    _ => _.TargetValueNames.Any(v => v == targetValueName));
                if (result != null)
                {
                    rtn.Add(entityInfo);
                }
            }
            if (rtn.Count == 1)
            {
                info = rtn[0];
                return(true);
            }
            if (rtn.Count == 0)
            {
                info = null;
                return(false);
            }
            throw new ArgumentException("duplicate targetValueName.");
        }
コード例 #2
0
 public ValuePropertyContainer(AffectableEntityInfo entityInfo, string targetName,
                               Tuple <ParameterExpression, ParameterExpression> parameters)
 {
     EntityInfo   = entityInfo;
     Properties   = entityInfo.GetValueProperty(targetName);
     Parameter    = parameters.Item1;
     NewParameter = parameters.Item2;
 }
コード例 #3
0
        private static ParserWithContainer <Expression, KeyPropertyContainer> CallKeyTerm(AffectableEntityInfo info,
                                                                                          ParameterExpression parameter, int index)
        {
            GetSetProperty prop;

            if (!info.TryGetKeyProperty(index, out prop))
            {
                return(new ParserWithContainer <Expression, KeyPropertyContainer>(
                           AlwaysFailure(), null));
            }
            var container = new KeyPropertyContainer(prop, parameter);

            return(new ParserWithContainer <Expression, KeyPropertyContainer>(
                       KeyTerm(container).Parser, container));
        }
コード例 #4
0
        private Expression BuildMain(ExpressionResult[] expressionResults, ParameterCache paramCache, AffectableEntityInfo info,
                                     ParameterExpression parameter, ParameterExpression newParameter)
        {
            var newAffectableEntity = Expression.Property(newParameter, info.PropertyInfo);

            if (expressionResults.Length == 0)
            {
                return(newParameter);
            }

            var affectableEntity = Expression.Property(parameter, info.PropertyInfo);
            var selectParam      = paramCache.Get(expressionResults[0].FunctionName);
            var lambda           = Expression.Lambda(BuildIfThenElseSection(expressionResults, selectParam, info.ReturnLabel),
                                                     selectParam.Item1);
            var selectExpr = SelectExpression(selectParam.Item1.Type, affectableEntity, lambda);

            return(Expression.Assign(newAffectableEntity, selectExpr));
        }