private static void AddLinkInfoToRouteData(TestControllerContext controllerContext, ODataPath odataPath) { KeySegment keyValueSegment = odataPath.Segments.OfType <KeySegment>().First(); controllerContext.AddKeyValueToRouteData(keyValueSegment); KeySegment relatedKeySegment = odataPath.Segments.Last() as KeySegment; if (relatedKeySegment != null) { controllerContext.AddKeyValueToRouteData(relatedKeySegment, ODataRouteConstants.RelatedKey); } }
/// <inheritdoc/> protected override string SelectAction(string requestMethod, ODataPath odataPath, TestControllerContext controllerContext, IList <string> actionList) { if ((odataPath.PathTemplate == "~/entityset/key/navigation") || (odataPath.PathTemplate == "~/entityset/key/cast/navigation")) { NavigationPropertySegment segment = odataPath.Segments.Last <ODataPathSegment>() as NavigationPropertySegment; IEdmNavigationProperty navigationProperty = segment.NavigationProperty; IEdmEntityType declaringType = navigationProperty.DeclaringType as IEdmEntityType; if (declaringType != null) { string prefix = ODataHelper.GetHttpPrefix(requestMethod); if (string.IsNullOrEmpty(prefix)) { return(null); } KeySegment segment2 = odataPath.Segments[1] as KeySegment; controllerContext.AddKeyValueToRouteData(segment2); string key = prefix + navigationProperty.Name + "On" + declaringType.Name; return(actionList.Contains(key) ? key : (prefix + navigationProperty.Name)); } } return(null); }
/// <inheritdoc/> protected override string SelectAction(string requestMethod, ODataPath odataPath, TestControllerContext controllerContext, IList <string> actionList) { if (odataPath.PathTemplate == "~/entityset/key/property" || odataPath.PathTemplate == "~/entityset/key/cast/property") { var segment = odataPath.Segments.Last() as PropertySegment; var property = segment.Property; var declareType = property.DeclaringType as IEdmEntityType; if (declareType != null) { var key = odataPath.Segments[1] as KeySegment; controllerContext.AddKeyValueToRouteData(key); string prefix = ODataHelper.GetHttpPrefix(requestMethod); if (string.IsNullOrEmpty(prefix)) { return(null); } string action = prefix + property.Name + "From" + declareType.Name; return(actionList.Contains(action) ? action : prefix + property.Name); } } return(null); }