internal static ProjectionInfo BuildProjections(MemberMappingDescriptor desc, XmlNodeList projections) { if (projections.Count < 1) { return(new ProjectionInfo()); } List <ProjectionItem> projectionItems = new List <ProjectionItem>(3); foreach (XmlNode node in projections) { // no check for existance, that is done with schema string to = GetAttributeValue(node.Attributes["to"]); if (to == string.Empty) { string message = ErrorBuilder.EmptyToAttributeInXmlError(desc, node.InnerXml); throw new OtisException(message); } // if 'from' is missing, it is assumed to be same as 'to' string from = GetAttributeValue(node.Attributes["from"], to); projectionItems.Add( new ProjectionItem( ExpressionParser.NormalizeExpression(from), ExpressionParser.NormalizeExpression(to))); } return(ProjectionBuilder.Build(desc, projectionItems)); }
internal static ProjectionInfo GetProjections(MemberMappingDescriptor desc, string projection) { string normalizedProjection = ExpressionParser.NormalizeExpression(projection); normalizedProjection = normalizedProjection.Trim(';', ' '); if (!ExpressionParser.IsProjectionExpression(normalizedProjection)) { // use original string in message to make it easier to find the attribute string message = ErrorBuilder.InvalidProjectionStringError(desc, projection); throw new OtisException(message); } IList <ProjectionItem> projectionItems = SplitProjectionItems(normalizedProjection); return(ProjectionBuilder.Build(desc, projectionItems)); }