Esempio n. 1
0
        public static void SetSearchRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, bool searchable, CapabilitiesSearchExpressions unsupported)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (entitySet == null)
            {
                throw new ArgumentNullException("entitySet");
            }

            var target     = entitySet;
            var term       = SearchRestrictionsTerm;
            var name       = new EdmEnumTypeReference(SearchExpressionsType, false).ToStringLiteral((long)unsupported);
            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Searchable", new EdmBooleanConstant(searchable)),
                new EdmPropertyConstructor("UnsupportedExpressions", new EdmEnumMemberReferenceExpression(SearchExpressionsType.Members.Single(m => m.Name == name))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);

            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Esempio n. 2
0
        public static void SetNavigationRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, CapabilitiesNavigationType type, IEnumerable <Tuple <IEdmNavigationProperty, CapabilitiesNavigationType> > properties)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (entitySet == null)
            {
                throw new ArgumentNullException("entitySet");
            }

            if (properties == null)
            {
                properties = new Tuple <IEdmNavigationProperty, CapabilitiesNavigationType> [0];
            }

            var target = entitySet;
            var term   = NavigationRestrictionsTerm;
            // handle type
            var typeLiteral = new EdmEnumTypeReference(NavigationTypeType, false).ToStringLiteral((long)type);
            // handle properties
            var propertiesExpression = properties.Select(p =>
            {
                var name = new EdmEnumTypeReference(NavigationTypeType, false).ToStringLiteral((long)p.Item2);
                return(new EdmRecordExpression(new IEdmPropertyConstructor[]
                {
                    new EdmPropertyConstructor("NavigationProperty", new EdmNavigationPropertyPathExpression(p.Item1.Name)),
                    new EdmPropertyConstructor("Navigability", new EdmEnumMemberReferenceExpression(NavigationTypeType.Members.Single(m => m.Name == name))),
                }));
            });

            var record = new EdmRecordExpression(new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Navigability", new EdmEnumMemberReferenceExpression(NavigationTypeType.Members.Single(m => m.Name == typeLiteral))),
                new EdmPropertyConstructor("RestrictedProperties", new EdmCollectionExpression(propertiesExpression))
            });

            var annotation = new EdmAnnotation(target, term, record);

            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Esempio n. 3
0
        public static void SetSearchRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, bool searchable, CapabilitiesSearchExpressions unsupported)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (entitySet == null) throw new ArgumentNullException("entitySet");

            var target = entitySet;
            var term = SearchRestrictionsTerm;
            var name = new EdmEnumTypeReference(SearchExpressionsType, false).ToStringLiteral((long)unsupported);
            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Searchable", new EdmBooleanConstant(searchable)),
                new EdmPropertyConstructor("UnsupportedExpressions", new EdmEnumMemberReferenceExpression(SearchExpressionsType.Members.Single(m => m.Name == name))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);
            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Esempio n. 4
0
        public static void SetNavigationRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, CapabilitiesNavigationType type, IEnumerable<Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>> properties)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (entitySet == null) throw new ArgumentNullException("entitySet");

            if (properties == null)
            {
                properties = new Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>[0];
            }

            var target = entitySet;
            var term = NavigationRestrictionsTerm;
            // handle type
            var typeLiteral = new EdmEnumTypeReference(NavigationTypeType, false).ToStringLiteral((long)type);
            // handle properties
            var propertiesExpression = properties.Select(p =>
            {
                var name = new EdmEnumTypeReference(NavigationTypeType, false).ToStringLiteral((long)p.Item2);
                return new EdmRecordExpression(new IEdmPropertyConstructor[]
                {
                    new EdmPropertyConstructor("NavigationProperty", new EdmNavigationPropertyPathExpression(p.Item1.Name)),
                    new EdmPropertyConstructor("Navigability", new EdmEnumMemberReferenceExpression(NavigationTypeType.Members.Single(m => m.Name == name))),
                });
            });

            var record = new EdmRecordExpression(new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Navigability", new EdmEnumMemberReferenceExpression(NavigationTypeType.Members.Single(m => m.Name == typeLiteral))),
                new EdmPropertyConstructor("RestrictedProperties", new EdmCollectionExpression(propertiesExpression))
            });

            var annotation = new EdmAnnotation(target, term, record);
            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }