Esempio n. 1
0
        /// <summary>
        /// Returns whether or not the uri refers to a WebInvoke service operation call
        /// </summary>
        /// <param name="uri">The uri to extend</param>
        /// <returns>whether or not the uri refers to a WebInvoke service operation call</returns>
        public static bool IsWebInvokeServiceOperation(this ODataUri uri)
        {
            if (uri.IsServiceOperation())
            {
                ODataUriSegment functionSegment = uri.Segments.First(s => s is FunctionSegment);
                return(functionSegment.CheckSegment <FunctionSegment>(f => f.Function.Annotations.OfType <LegacyServiceOperationAnnotation>().Single().Method == Http.HttpVerb.Post));
            }

            return(false);
        }
Esempio n. 2
0
        private static bool CheckSegment <TSegment>(this ODataUriSegment segment, Func <TSegment, bool> check) where TSegment : ODataUriSegment
        {
            var afterCast = segment as TSegment;

            if (afterCast == null)
            {
                return(false);
            }

            return(check(afterCast));
        }
Esempio n. 3
0
        /// <summary>
        /// Returns whether or not the uri refers to a service operation call
        /// </summary>
        /// <param name="uri">The uri to extend</param>
        /// <returns>whether or not the uri refers to a service operation call</returns>
        public static bool IsServiceOperation(this ODataUri uri)
        {
            ODataUriSegment functionSegment = uri.Segments.LastOrDefault(s => s is FunctionSegment);

            if (functionSegment != null)
            {
                return(functionSegment.CheckSegment <FunctionSegment>(f => f.Function.IsServiceOperation()));
            }

            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// Returns whether or not the segment refers to a member property
 /// </summary>
 /// <param name="segment">The segment to extend</param>
 /// <returns>whether or not the segment refers to a primitive, complex, or multivalue property</returns>
 public static bool IsProperty(this ODataUriSegment segment)
 {
     return(segment.SegmentType == ODataUriSegmentType.PrimitiveProperty ||
            segment.SegmentType == ODataUriSegmentType.ComplexProperty ||
            segment.SegmentType == ODataUriSegmentType.MultiValueProperty);
 }
        /// <summary>
        /// Find out whehter the given segment is select-all-function-segment (ContainerName.*)
        /// </summary>
        /// <param name="selectSegment">The segment</param>
        /// <returns>Whether segment is select-all-function-segment</returns>
        private bool IsSelectAllFunctionSegment(ODataUriSegment selectSegment)
        {
            UnrecognizedSegment selectAllFunctionSegment = selectSegment as UnrecognizedSegment;
            if (selectAllFunctionSegment != null && selectAllFunctionSegment.Value == this.model.GetDefaultEntityContainer().Name + ".*")
            {
                return true;
            }

            return false;
        }
        /// <summary>
        /// Find out whether action matches with the ODataUri select function segment
        /// </summary>
        /// <param name="action">The action</param>
        /// <param name="selectSegment">The segment</param>
        /// <returns>Whether action matches with the function segment</returns>
        private bool FuctionMatchWithSelectFunctionSegment(Function action, ODataUriSegment selectSegment)
        {
            FunctionSegment selectFunctionSegment = selectSegment as FunctionSegment;
            if (selectFunctionSegment != null && selectFunctionSegment.Function == action)
            {
                return true;
            }

            // Sometimes the $select segment is an UnrecognizedSegment
            UnrecognizedSegment otherTypeOfSelectSegment = selectSegment as UnrecognizedSegment;
            if (otherTypeOfSelectSegment != null && selectFunctionSegment == null)
            {
                string actionName = action.Name;

                // Determine the if selction segment was <Action Name> or <EntityContainer>.<Action Name>
                if (otherTypeOfSelectSegment.Value.Contains('.'))
                {
                    actionName = string.Concat(action.Model.GetDefaultEntityContainer().Name, ".", actionName);    
                }

                if (otherTypeOfSelectSegment.Value.Equals(actionName, System.StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }