/// <summary> /// Cache the property and collection item enumerations needed in EPM mappings. We do this for syndication and custom /// mappings. /// </summary> /// <param name="valueCache">The property value cache to use for caching.</param> /// <param name="segments">The source path segments to cache.</param> /// <param name="properties">The <see cref="ODataProperty"/> values to compute the segments against.</param> private static void CacheEpmSourcePathSegments(EpmValueCache valueCache, List <EpmSourcePathSegment> segments, IEnumerable <ODataProperty> properties) { Debug.Assert(valueCache != null, "valueCache != null"); Debug.Assert(segments != null, "segments != null"); if (properties == null) { return; } foreach (EpmSourcePathSegment segment in segments) { if (segment.EpmInfo == null) { // No EPM info means that this is a complex value (cannot be mapped directly); cache it. ODataComplexValue complexValue; if (TryGetPropertyValue <ODataComplexValue>(properties, segment.PropertyName, out complexValue)) { // Cache the properties of the complex property IEnumerable <ODataProperty> subProperties = valueCache.CacheComplexValueProperties(complexValue); CacheEpmSourcePathSegments(valueCache, segment.SubProperties, subProperties); } } else { // Primitive collection item inside a complex value; nothing to do - we cached the property values already. Debug.Assert(segment.SubProperties.Count == 0, "No sub-segments expected."); } } }
private static void CacheEpmSourcePathSegments(EpmValueCache valueCache, List <EpmSourcePathSegment> segments, IEnumerable <ODataProperty> properties) { if (properties != null) { foreach (EpmSourcePathSegment segment in segments) { ODataComplexValue value2; if ((segment.EpmInfo == null) && TryGetPropertyValue <ODataComplexValue>(properties, segment.PropertyName, out value2)) { IEnumerable <ODataProperty> enumerable = valueCache.CacheComplexValueProperties(value2); CacheEpmSourcePathSegments(valueCache, segment.SubProperties, enumerable); } } } }