/// <summary> /// Decodes an expansion segment. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="segments">The segments.</param> /// <param name="currentNodeIndex">The current node index in the segments list.</param> /// <param name="entityType">Type of the entity.</param> private void DecodeSegment(PathEdgeNode parentNode, IList <ExpandSegment> segments, int currentNodeIndex, Type entityType) { if (currentNodeIndex >= segments.Count) { return; } var navigatorProperty = entityType.GetProperty(segments[currentNodeIndex].Name); if (navigatorProperty == null) { return; } Type navigatorEntityType = typeof(IEntityCore).IsAssignableFrom(navigatorProperty.PropertyType) ? navigatorProperty.PropertyType : navigatorProperty.PropertyType.BaseType.GetGenericArguments()[0]; PropertyInfo prefetchPathProperty = entityType.GetProperty("PrefetchPath" + segments[currentNodeIndex].Name, BindingFlags.Static | BindingFlags.Public); IPrefetchPathElementCore prefetchPathElement = prefetchPathProperty.GetValue(null, null) as IPrefetchPathElementCore; AddSegment(parentNode, segments, currentNodeIndex, prefetchPathElement, navigatorEntityType); }
/// <summary> /// Initializes a new instance of the <see cref="PathEdgeNode"/> class. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="pathElement">The path element.</param> /// <param name="segment">The segment.</param> internal PathEdgeNode(Type entityType, IPrefetchPathElementCore pathElement, ExpandSegment segment) { _pathElement = pathElement; _segment = segment; _entityType = entityType; }
/// <summary> /// Adds the segment as pathedgenode /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="segments">The segments.</param> /// <param name="currentNodeIndex">The current node index in the segments list.</param> /// <param name="pathElement">The path element.</param> /// <param name="entityType">Type of the entity.</param> /// <remarks>Declared public to avoid medium trust reflection issues.</remarks> public void AddSegment(PathEdgeNode parentNode, IList <ExpandSegment> segments, int currentNodeIndex, IPrefetchPathElementCore pathElement, Type entityType) { if (currentNodeIndex >= segments.Count) { return; } ExpandSegment segment = segments[currentNodeIndex]; PathEdgeNode childNode = null; if (!parentNode.ChildPathEdgeNodes.TryGetValue(segment.Name, out childNode)) { childNode = new PathEdgeNode(entityType, pathElement, segment); parentNode.ChildPathEdgeNodes.Add(segment.Name, childNode); } DecodeSegment(childNode, segments, ++currentNodeIndex, entityType); }