public HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {
            if (request == null)
            {
                throw Error.ArgumentNull("request");
            }

            IHttpRouteData routeData = request.GetRouteData();
            if (routeData == null)
            {
                return _innerSelector.SelectController(request);
            }

            ODataPath odataPath = request.GetODataPath();
            if (odataPath == null)
            {
                return _innerSelector.SelectController(request);
            }

            foreach (IODataRoutingConvention routingConvention in _routingConventions)
            {
                string controllerName = routingConvention.SelectController(odataPath, request);
                if (controllerName != null)
                {
                    routeData.Values.Add(ODataRouteConstants.Controller, controllerName);
                    return _innerSelector.SelectController(request);
                }
            }

            throw new HttpResponseException(request.CreateErrorResponse(
                HttpStatusCode.NotFound,
                Error.Format(SRResources.NoMatchingResource, request.RequestUri),
                Error.Format(SRResources.NoRoutingHandlerToSelectController, odataPath.PathTemplate)));
        }
 private static PropertyAccessPathSegment GetProperty(HttpRequestMessage request)
 {
     ODataPath odataPath = request.GetODataPath();
     if (odataPath == null || odataPath.Segments.Count < 2)
     {
         return null;
     }
     return odataPath.Segments[odataPath.Segments.Count - 2] as PropertyAccessPathSegment;
 }
        private static IEdmNavigationProperty GetNavigationPropertyOrDefault(HttpRequestMessage request)
        {
            if (request == null)
            {
                throw new SerializationException(SRResources.RequestMissingDuringSerialization);
            }

            ODataPath path = request.GetODataPath();

            if (path == null)
            {
                throw Error.InvalidOperation(SRResources.RequestNotODataPath, request.RequestUri);
            }

            Contract.Assert(path.Segments != null);
            NavigationPathSegment navigationSegment = path.Segments.LastOrDefault() as NavigationPathSegment;

            if (navigationSegment == null)
            {
                return null;
            }

            return navigationSegment.NavigationProperty;
        }
 private static bool IsRawValueRequest(HttpRequestMessage request)
 {
     ODataPath path = request.GetODataPath();
     return path != null && path.Segments.LastOrDefault() is ValuePathSegment;
 }