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);
        }
            private bool PushPropertySettings(IEdmNavigationProperty navigationProperty)
            {
                OeModelBoundSettings?navigationSettings = _modelBoundProvider.GetSettings(navigationProperty);

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

                _settings.Push(navigationSettings);
                return(true);
            }
Ejemplo n.º 3
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));
        }
        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));
        }
Ejemplo n.º 5
0
        private static void AddPageNextLinkSelectItems(OeModelBoundSettings?settings, SelectExpandClause selectExpandClause, ref List <SelectItem>?selectItems)
        {
            if (settings != null && (settings.PageSize > 0 || settings.NavigationNextLink))
            {
                if (selectItems == null)
                {
                    selectItems = new List <SelectItem>(selectExpandClause.SelectedItems);
                }

                if (settings.PageSize > 0)
                {
                    selectItems.Add(new Parsers.Translators.OePageSelectItem(settings.PageSize));
                }

                if (settings.NavigationNextLink)
                {
                    selectItems.Add(Parsers.Translators.OeNextLinkSelectItem.Instance);
                }
            }
        }
        public bool IsAllowed(OeModelBoundProvider modelBoundProvider, IEdmProperty property, OeModelBoundKind modelBoundKind)
        {
            SelectExpandType?propertySetting = GetPropertySetting(property, modelBoundKind);

            if (propertySetting != null)
            {
                return(propertySetting.Value != SelectExpandType.Disabled);
            }

            if (NavigationProperty != null)
            {
                OeModelBoundSettings?entitySettings = modelBoundProvider.GetSettings((IEdmEntityType)property.DeclaringType);
                if (entitySettings != null && entitySettings.GetPropertySetting(property, modelBoundKind) == SelectExpandType.Disabled)
                {
                    return(false);
                }
            }

            return(true);
        }
        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);
        }
Ejemplo n.º 8
0
        private SelectExpandClause GetSelectItems(SelectExpandClause selectExpandClause, OeModelBoundSettings?settings)
        {
            List <SelectItem>?selectItems = null;
            int i = 0;

            foreach (SelectItem selectItem in selectExpandClause.SelectedItems)
            {
                if (selectItem is ExpandedNavigationSelectItem navigationSelectItem)
                {
                    ExpandedNavigationSelectItem item = Build(navigationSelectItem);
                    if (item != navigationSelectItem)
                    {
                        if (selectItems == null)
                        {
                            selectItems = new List <SelectItem>(selectExpandClause.SelectedItems);
                        }
                        selectItems[i] = item;
                    }
                }
                i++;
            }

            AddPageNextLinkSelectItems(settings, selectExpandClause, ref selectItems);
            return(selectItems == null ? selectExpandClause : new SelectExpandClause(selectItems, selectExpandClause.AllSelected));
        }
        public bool IsTop(long top, IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings?settings = GetSettings(navigationProperty);

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

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

            return(settings != null && settings.NavigationNextLink);
        }
        public bool IsCountable(IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings?settings = GetSettings(navigationProperty);

            return(settings == null || settings.Countable);
        }
        public bool IsCountable(IEdmEntityType entityType)
        {
            OeModelBoundSettings?settings = GetSettings(entityType);

            return(settings == null || settings.Countable);
        }
        public int GetPageSize(IEdmNavigationProperty navigationProperty)
        {
            OeModelBoundSettings?settings = GetSettings(navigationProperty);

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

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