private static IEdmAction GetAction(ODataPath odataPath) { ODataPathSegment odataSegment = odataPath.Segments.Last(); IEdmAction action = null; BoundActionPathSegment actionSegment = odataSegment as BoundActionPathSegment; if (actionSegment != null) { action = actionSegment.Action; } return(action); }
internal static IEdmAction GetAction(ODataDeserializerContext readContext) { if (readContext == null) { throw Error.ArgumentNull("readContext"); } ODataPath path = readContext.Path; if (path == null || path.Segments.Count == 0) { throw new SerializationException(SRResources.ODataPathMissing); } IEdmAction action = null; if (path.PathTemplate == "~/unboundaction") { // only one segment, it may be an unbound action UnboundActionPathSegment unboundActionSegment = path.Segments.Last() as UnboundActionPathSegment; if (unboundActionSegment != null) { action = unboundActionSegment.Action.Action; } } else { // otherwise, it may be a bound action BoundActionPathSegment actionSegment = path.Segments.Last() as BoundActionPathSegment; if (actionSegment != null) { action = actionSegment.Action; } } if (action == null) { string message = Error.Format(SRResources.RequestNotActionInvocation, path.ToString()); throw new SerializationException(message); } return(action); }
private static string GetRootElementName(ODataPath path) { if (path != null) { ODataPathSegment lastSegment = path.Segments.LastOrDefault(); if (lastSegment != null) { BoundActionPathSegment actionSegment = lastSegment as BoundActionPathSegment; if (actionSegment != null) { return(actionSegment.Action.Name); } PropertyAccessPathSegment propertyAccessSegment = lastSegment as PropertyAccessPathSegment; if (propertyAccessSegment != null) { return(propertyAccessSegment.Property.Name); } } } return(null); }