public Dictionary <ParameterExpression, ParameterInfo> CollectParameterInfos() { var dict = new Dictionary <ParameterExpression, ParameterInfo>(); foreach (var access in PropertyAccesses.OfType <PropertyAccess>()) { if (!IsModelProperty(access.Property)) { continue; } ParameterInfo parameterInfo; if (!dict.TryGetValue(access.Parameter, out parameterInfo)) { parameterInfo = new ParameterInfo(new List <string>(), false); dict.Add(access.Parameter, parameterInfo); } var current = access; var count = 0; while (current != null) { if (!parameterInfo.Properties.Contains(current.PropertyName)) { parameterInfo.Properties.Add(current.PropertyName); } count++; current = current.Base as PropertyAccess; } if (!parameterInfo.NeedsContainment && (count > 1 || !typeof(IModelElement).IsAssignableFrom(access.Property.PropertyType))) { parameterInfo.NeedsContainment = true; dict[access.Parameter] = parameterInfo; } } return(dict); }
private Expression ExtractLambda(MethodCallExpression node, Dictionary <string, ParameterExtraction> extractionsSaved) { parameterextractions = extractionsSaved; var extraction = ExtractParameter(node); PropertyAccesses.Add(new ParameterReference(extraction)); return(extraction); }
protected override bool ResetForCrossReference(Expression targetExpression, PropertyInfo property, bool isCrossReference, out Expression returnValue) { var extract = ExtractParameter(targetExpression); PropertyAccesses.Clear(); PropertyAccesses.Add(new PropertyAccess(new ParameterReference(extract), property, isCrossReference)); returnValue = Expression.MakeMemberAccess(extract, property); return(true); }
public Dictionary <ParameterExpression, ParameterInfo> CollectParameterInfos() { var dict = new Dictionary <ParameterExpression, ParameterInfo>(); foreach (var access in PropertyAccesses.OfType <PropertyAccess>()) { if (!IsModelProperty(access.Property)) { continue; } ParameterInfo parameterInfo; if (!dict.TryGetValue(access.Parameter, out parameterInfo)) { parameterInfo = new ParameterInfo(new List <string>()); dict.Add(access.Parameter, parameterInfo); } var current = access; while (current != null) { if (!parameterInfo.Properties.Contains(current.PropertyName)) { parameterInfo.Properties.Add(current.PropertyName); } if (current.IsCrossReference) { var anchor = current.Anchor; if (anchor != null) { if (current.IsAnchorEffective(anchor)) { if (!parameterInfo.Anchors.Contains(anchor)) { parameterInfo.Anchors.Add(anchor); } } } else { parameterInfo.Anchors.Add(null); } } current = current.Base as PropertyAccess; } } foreach (var info in dict.Values) { if (info.Anchors.Contains(null)) { info.Anchors.Clear(); info.Anchors.Add(typeof(IModelRepository)); } } return(dict); }