public static void SetISOCurrencyMeasuresAnnotation(this EdmModel model, IEdmProperty property, string isoCurrency) { if (model == null) throw new ArgumentNullException("model"); if (property == null) throw new ArgumentNullException("property"); var target = property; var term = ISOCurrencyTerm; var expression = new EdmStringConstant(isoCurrency); var annotation = new EdmAnnotation(target, term, expression); annotation.SetSerializationLocation(model, property.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
public static void SetScaleMeasuresAnnotation(this EdmModel model, IEdmProperty property, byte scale) { if (model == null) throw new ArgumentNullException("model"); if (property == null) throw new ArgumentNullException("property"); var target = property; var term = ScaleTerm; var expression = new EdmIntegerConstant(scale); var annotation = new EdmAnnotation(target, term, expression); annotation.SetSerializationLocation(model, property.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
private static void SetCapabilitiesAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IEdmValueTerm term, bool value) { var expression = new EdmBooleanConstant(value); var annotation = new EdmAnnotation(target, term, expression); annotation.SetSerializationLocation(model, target.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
public static void SetConformanceLevelCapabilitiesAnnotation(this EdmModel model, IEdmEntityContainer container, CapabilitiesConformanceLevelType level) { if (model == null) throw new ArgumentNullException("model"); if (container == null) throw new ArgumentNullException("container"); var target = container; var term = ConformanceLevelTerm; var name = new EdmEnumTypeReference(ConformanceLevelTypeType, false).ToStringLiteral((long)level); var expression = new EdmEnumMemberReferenceExpression(ConformanceLevelTypeType.Members.Single(m => m.Name == name)); var annotation = new EdmAnnotation(target, term, expression); annotation.SetSerializationLocation(model, container.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
private static void SetCapabilitiesAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IEdmValueTerm term, IEnumerable<string> values) { if (values == null) { values = new string[0]; } var expression = new EdmCollectionExpression(values.Select(function => new EdmStringConstant(function))); var annotation = new EdmAnnotation(target, term, expression); annotation.SetSerializationLocation(model, target.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
private static void SetCapabilitiesAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IEdmValueTerm term, bool value, IEnumerable<IEdmNavigationProperty> navigationProperties, string name1, string name2) { if (navigationProperties == null) { navigationProperties = new IEdmNavigationProperty[0]; } var properties = new IEdmPropertyConstructor[] { new EdmPropertyConstructor(name1, new EdmBooleanConstant(value)), new EdmPropertyConstructor(name2, new EdmCollectionExpression(navigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)))), }; var record = new EdmRecordExpression(properties); var annotation = new EdmAnnotation(target, term, record); annotation.SetSerializationLocation(model, target.ToSerializationLocation()); model.AddVocabularyAnnotation(annotation); }
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); }
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); }
private static void SetCoreChangeTrackingAnnotation(this EdmModel model, EdmEntitySet entitySet, IEdmStructuralProperty[] filterableProperties, IEdmNavigationProperty[] expandableProperties) { IEdmModel termModel = ReadTermModel("CoreCapabilities.csdl"); IEdmValueTerm changeTracking = termModel.FindDeclaredValueTerm("Core.ChangeTracking"); var exp = new EdmRecordExpression( new EdmPropertyConstructor("Supported", new EdmBooleanConstant(true)), new EdmPropertyConstructor("FilterableProperties", new EdmCollectionExpression(filterableProperties.Select(p => new EdmPropertyPathExpression(p.Name)))), new EdmPropertyConstructor("ExpandableProperties", new EdmCollectionExpression(expandableProperties.Select(p => new EdmPropertyPathExpression(p.Name))))); EdmAnnotation annotation = new EdmAnnotation(entitySet, changeTracking, exp); annotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.Inline); model.AddVocabularyAnnotation(annotation); }