예제 #1
0
        public static bool Compare(ODataPath odataPath1, ODataPath odataPath2)
        {
            if (odataPath1.Count != odataPath2.Count)
            {
                return(false);
            }

            ODataPathComparer comparer = null;

            try
            {
                comparer = new ODataPathComparer(odataPath1);
                foreach (bool result in odataPath2.WalkWith(comparer))
                {
                    if (!result)
                    {
                        return(false);
                    }
                }
            }
            finally
            {
                if (comparer != null && comparer._segments != null)
                {
                    comparer._segments.Dispose();
                }
            }
            return(true);
        }
예제 #2
0
        private bool CompareSelectItem(SelectItem selectItem1, SelectItem selectItem2, ODataPath path)
        {
            if (selectItem1.GetType() != selectItem2.GetType())
            {
                return(false);
            }

            if (selectItem1 is ExpandedNavigationSelectItem)
            {
                var expand1 = selectItem1 as ExpandedNavigationSelectItem;
                var expand2 = selectItem2 as ExpandedNavigationSelectItem;

                if (!CompareLevelsClause(expand1.LevelsOption, expand2.LevelsOption))
                {
                    return(false);
                }

                if (expand1.CountOption != expand2.CountOption)
                {
                    return(false);
                }

                if (expand1.NavigationSource != expand2.NavigationSource)
                {
                    return(false);
                }

                if (!CompareFilter(expand1.FilterOption, expand2.FilterOption))
                {
                    return(false);
                }

                if (!CompareOrderBy(expand1.OrderByOption, expand2.OrderByOption))
                {
                    return(false);
                }

                if (!ODataPathComparer.Compare(expand1.PathToNavigationProperty, expand2.PathToNavigationProperty))
                {
                    return(false);
                }

                path = new ODataPath(path.Union(expand2.PathToNavigationProperty));
                return(CompareSkip(expand1.SkipOption, expand2.SkipOption, path) &&
                       CompareTop(expand1.TopOption, expand2.TopOption, path) &&
                       CompareSelectAndExpand(expand1.SelectAndExpand, expand2.SelectAndExpand, path));
            }
            else if (selectItem1 is PathSelectItem)
            {
                var path1 = selectItem1 as PathSelectItem;
                var path2 = selectItem2 as PathSelectItem;
                return(ODataPathComparer.Compare(path1.SelectedPath, path2.SelectedPath));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
예제 #3
0
        public bool Compare(OeParseUriContext parseUriContext1, OeParseUriContext parseUriContext2)
        {
            if (parseUriContext1.EntitySet != parseUriContext2.EntitySet)
            {
                return(false);
            }

            ODataUri uri1 = parseUriContext1.ODataUri;
            ODataUri uri2 = parseUriContext2.ODataUri;

            if (!ODataPathComparer.Compare(uri1.Path, uri2.Path))
            {
                return(false);
            }

            if (!CompareParseNavigationSegments(parseUriContext1.ParseNavigationSegments, parseUriContext2.ParseNavigationSegments))
            {
                return(false);
            }

            if (!CompareApply(uri1.Apply, uri2.Apply))
            {
                return(false);
            }

            if (!CompareFilter(uri1.Filter, uri2.Filter))
            {
                return(false);
            }

            if (!CompareSelectAndExpand(uri1.SelectAndExpand, uri2.SelectAndExpand, uri1.Path))
            {
                return(false);
            }

            if (!CompareOrderBy(uri1.OrderBy, uri2.OrderBy))
            {
                return(false);
            }

            if (!CompareSkip(uri1.Skip, uri2.Skip, uri1.Path))
            {
                return(false);
            }

            if (!CompareTop(uri1.Top, uri2.Top, uri1.Path))
            {
                return(false);
            }

            if (!CompareHeaders(parseUriContext1.Headers, parseUriContext2.Headers))
            {
                return(false);
            }

            return(true);
        }
        public bool Compare(OeCacheContext cacheContext1, OeCacheContext cacheContext2)
        {
            if (cacheContext1.EntitySet != cacheContext2.EntitySet)
            {
                return(false);
            }

            if (cacheContext1.NavigationNextLink != cacheContext2.NavigationNextLink)
            {
                return(false);
            }

            if (cacheContext1.MetadataLevel != cacheContext2.MetadataLevel)
            {
                return(false);
            }

            ODataUri uri1 = cacheContext1.ODataUri;
            ODataUri uri2 = cacheContext2.ODataUri;

            if (!ODataPathComparer.Compare(uri1.Path, uri2.Path))
            {
                return(false);
            }

            if (!CompareParseNavigationSegments(cacheContext1.ParseNavigationSegments, cacheContext2.ParseNavigationSegments))
            {
                return(false);
            }

            if (!CompareApply(uri1.Apply, uri2.Apply))
            {
                return(false);
            }

            if (!CompareFilter(uri1.Filter, uri2.Filter, false))
            {
                return(false);
            }

            if (!CompareSelectAndExpand(uri1.SelectAndExpand, uri2.SelectAndExpand, uri1.Path))
            {
                return(false);
            }

            if (!CompareOrderBy(uri1.OrderBy, uri2.OrderBy, false))
            {
                return(false);
            }

            if (!CompareSkip(uri1.Skip, uri2.Skip, uri1.Path))
            {
                return(false);
            }

            if (!CompareTop(uri1.Top, uri2.Top, uri1.Path))
            {
                return(false);
            }

            if (!CompareSkipToken(uri1.SkipToken, uri2.SkipToken, cacheContext1.SkipTokenParser))
            {
                return(false);
            }

            return(true);
        }