示例#1
0
        public bool IsOrderable(OrderByClause orderByClause, OeModelBoundSettings entitySettings)
        {
            while (orderByClause != null)
            {
                var propertyNode = (SingleValuePropertyAccessNode)orderByClause.Expression;
                if (!IsAllowed(propertyNode.Property, entitySettings, OeModelBoundKind.OrderBy))
                {
                    return(false);
                }

                if (propertyNode.Source is SingleNavigationNode navigationNode)
                {
                    do
                    {
                        if (!IsAllowed(navigationNode.NavigationProperty, null, OeModelBoundKind.OrderBy))
                        {
                            return(false);
                        }
                    }while ((navigationNode = navigationNode.Source as SingleNavigationNode) != null);
                }

                orderByClause = orderByClause.ThenBy;
            }

            return(true);
        }
示例#2
0
            public FilterableVisitor(OeModelBoundProvider modelBoundProvider, OeModelBoundSettings settings)
            {
                _modelBoundProvider = modelBoundProvider;
                _settings           = new Stack <OeModelBoundSettings>();

                IsFilterable = true;
                _settings.Push(settings);
            }
示例#3
0
        public bool IsFilterable(FilterClause filterClause, OeModelBoundSettings settings)
        {
            if (settings != null)
            {
                var filterableVisitor = new FilterableVisitor(this, settings);
                filterClause.Expression.Accept(filterableVisitor);
                return(filterableVisitor.IsFilterable);
            }

            return(true);
        }
示例#4
0
            private bool PushPropertySettings(IEdmNavigationProperty navigationProperty)
            {
                OeModelBoundSettings navigationSettings = _modelBoundProvider.GetSettings(navigationProperty);

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

                _settings.Push(navigationSettings);
                return(true);
            }
示例#5
0
        private bool IsAllowed(IEdmProperty property, OeModelBoundSettings entitySettings, OeModelBoundKind modelBoundKind)
        {
            if (entitySettings == null)
            {
                entitySettings = GetSettings((IEdmEntityType)property.DeclaringType);
                if (entitySettings == null)
                {
                    return(true);
                }
            }

            return(entitySettings.IsAllowed(this, property, modelBoundKind));
        }
示例#6
0
        private bool IsSelectable(ODataPath path, OeModelBoundSettings entitySettings)
        {
            IEdmProperty property;

            if (path.LastSegment is NavigationPropertySegment navigationPropertySegment)
            {
                property = navigationPropertySegment.NavigationProperty;
            }
            else if (path.LastSegment is PropertySegment propertySegment)
            {
                property = propertySegment.Property;
            }
            else
            {
                return(false);
            }

            return(IsAllowed(property, entitySettings, OeModelBoundKind.Select));
        }
示例#7
0
        public bool IsOrderable(OrderByClause orderByClause, OeModelBoundSettings entitySettings)
        {
            while (orderByClause != null)
            {
                if (orderByClause.Expression is SingleValuePropertyAccessNode propertyNode)
                {
                    if (!IsAllowed(propertyNode.Property, entitySettings, OeModelBoundKind.OrderBy))
                    {
                        return(false);
                    }

                    if (propertyNode.Source is SingleNavigationNode navigationNode)
                    {
                        for (; ;)
                        {
                            if (!IsAllowed(navigationNode.NavigationProperty, null, OeModelBoundKind.OrderBy))
                            {
                                return(false);
                            }

                            if (navigationNode.Source is SingleNavigationNode navigationNode2)
                            {
                                navigationNode = navigationNode2;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }

                orderByClause = orderByClause.ThenBy;
            }

            return(true);
        }
示例#8
0
        public bool IsTop(long top, IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings settings = GetSettings(navigationProperty);

            return(top <= (settings == null || settings.MaxTop == 0 ? Int32.MaxValue : settings.MaxTop));
        }
示例#9
0
        public bool IsTop(long top, IEdmEntityType entityType)
        {
            OeModelBoundSettings settings = GetSettings(entityType);

            return(top <= (settings == null || settings.MaxTop == 0 ? Int32.MaxValue : settings.MaxTop));
        }
示例#10
0
        public bool IsNavigationNextLink(IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings settings = GetSettings(navigationProperty);

            return(settings == null ? false : settings.NavigationNextLink);
        }
示例#11
0
        public bool IsCountable(IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings settings = GetSettings(navigationProperty);

            return(settings == null ? true : settings.Countable);
        }
示例#12
0
        public bool IsCountable(IEdmEntityType entityType)
        {
            OeModelBoundSettings settings = GetSettings(entityType);

            return(settings == null ? true : settings.Countable);
        }
示例#13
0
        public int GetPageSize(IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings settings = GetSettings(navigationProperty);

            return(settings == null ? 0 : settings.PageSize);
        }
示例#14
0
        public int GetPageSize(IEdmEntityType entityType)
        {
            OeModelBoundSettings settings = GetSettings(entityType);

            return(settings == null ? 0 : settings.PageSize);
        }