public static EdmModel NavigationPropertyWithAnnotationModel() { EdmModel model = new EdmModel(); EdmEntityType person = new EdmEntityType("DefaultNamespace", "Person"); EdmStructuralProperty personId = person.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false)); person.AddKeys(personId); model.AddElement(person); EdmNavigationProperty friend = person.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Friends", Target = person, TargetMultiplicity = EdmMultiplicity.One }, new EdmNavigationPropertyInfo() { Name = "Self", TargetMultiplicity = EdmMultiplicity.One }); IEdmNavigationProperty self = friend.Partner; XElement annotationElement = new XElement("{http://foo}Annotation", "1"); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(friend, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel ComplexNamespaceOverlappingModel() { EdmModel model = new EdmModel(); EdmEntityContainer container = new EdmEntityContainer("Default", "Container"); EdmAction simpleOperationAction = new EdmAction("Default", "SimpleFunction", EdmCoreModel.Instance.GetInt32(false)); model.AddElement(simpleOperationAction); EdmActionImport simpleOperation = new EdmActionImport(container, "SimpleFunction", simpleOperationAction); container.AddElement(simpleOperation); model.AddElement(container); XElement annotationElement = new XElement("{http://foo}Annotation", new XElement("{http://foo}Child", new XElement("{http://foo1}GrandChild", new XElement("{http://foo}GreatGrandChild", "1" ) ) ), new XElement("{http://foo1}Child", new XElement("{http://foo}GrandChild", "1" ) ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleOperation, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel NestedXElementWithNoValueModel() { EdmModel model = new EdmModel(); EdmComplexType simpleType = new EdmComplexType("DefaultNamespace", "SimpleType"); EdmStructuralProperty simpleTypeId = simpleType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(true)); model.AddElement(simpleType); XElement annotationElement = new XElement("{http://foo}Annotation", new XElement("{http://foo}Child", new XElement("{http://foo}GrandChild", new XElement("{http://foo}GreatGrandChild", new XElement("{http://foo}GreateGreatGrandChild") ) ) ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleTypeId, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel NestedXElementWithValueModel() { EdmModel model = new EdmModel(); EdmOperation simpleOperation = new EdmFunction("DefaultNamespace", "SimpleFunction", EdmCoreModel.Instance.GetString(true)); model.AddElement(simpleOperation); XElement annotationElement = new XElement("{http://foo}Annotation", "1", new XElement("{http://foo}Child", "2", new XElement("{http://foo}GrandChild", "3", new XElement("{http://foo}GreatGrandChild", "4", new XElement("{http://foo}GreateGreatGrandChild", "5") ) ) ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleOperation, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel DifferentAnnotationNamespaceModel() { EdmModel model = new EdmModel(); EdmEntityType simpleType = new EdmEntityType("DefaultNamespace", "SimpleType"); EdmStructuralProperty simpleTypeId = simpleType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false)); simpleType.AddKeys(simpleTypeId); model.AddElement(simpleType); EdmEntityContainer container = new EdmEntityContainer("DefaultNamespace", "Container"); EdmEntitySet simpleSet = container.AddEntitySet("SimpleSet", simpleType); model.AddElement(container); XElement annotationElement = new XElement("{http://foo}Annotation", new XElement("{http://foo1}Child", new XElement("{http://foo2}GrandChild", "1" ) ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleSet, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel OutOfLineVocabularyAnnotationWithAnnotationModel() { EdmModel model = new EdmModel(); EdmComplexType simpleType = new EdmComplexType("DefaultNamespace", "SimpleType"); simpleType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true)); model.AddElement(simpleType); EdmTerm note = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true)); model.AddElement(note); EdmVocabularyAnnotation valueAnnotation = new EdmVocabularyAnnotation( simpleType, note, new EdmStringConstant("ComplexTypeNote")); valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine); model.AddVocabularyAnnotation(valueAnnotation); XElement annotationElement = new XElement("{http://foo}Annotation", "1"); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(valueAnnotation, "http://foo", "Annotation", annotation); return(model); }
private IEdmValue ComputeValue() { IEdmStringValue value = new EdmStringConstant(new EdmStringTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), false), this.annotation.Value); value.SetIsSerializedAsElement(this.model, !this.annotation.IsAttribute); return(value); }
public void XElementAnnotationTestXElementWithWithoutNamespaceCsdl() { EdmModel model = new EdmModel(); EdmComplexType complexType = new EdmComplexType("DefaultNamespace", "ComplexType"); complexType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true)); model.AddElement(complexType); XElement annotationElement = new XElement("EmptyAnnotation"); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); VerifyThrowsException(typeof(InvalidOperationException), () => annotation.SetIsSerializedAsElement(model, true)); }
public static EdmModel EnumWithAnnotationModel() { EdmModel model = new EdmModel(); EdmEnumType spicy = new EdmEnumType("DefaultNamespace", "Spicy"); model.AddElement(spicy); XElement annotationElement = new XElement("{http://foo}Annotation", "1"); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(spicy, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel TermWithAnnotationModel() { EdmModel model = new EdmModel(); EdmTerm note = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true)); model.AddElement(note); var annotationElement = new XElement("{http://foo}Annotation", 1); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(note, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel AnnotationWithoutChildrenModel() { EdmModel model = new EdmModel(); EdmComplexType complexType = new EdmComplexType("DefaultNamespace", "ComplexType"); complexType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true)); model.AddElement(complexType); XElement annotationElement = new XElement("{http://foo}Annotation"); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(complexType, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel AnnotationWithEntitySetTagInEntityContainerModel() { EdmModel model = new EdmModel(); EdmEntityContainer container = new EdmEntityContainer("Default", "Container"); model.AddElement(container); XElement annotationElement = new XElement("{http://foo}EntitySet", "1" ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(container, "http://foo", "EntitySet", annotation); return(model); }
public static EdmModel AnnotationWithSchemaTagValueModel() { EdmModel model = new EdmModel(); EdmEntityType simpleType = new EdmEntityType("DefaultNamespace", "SimpleType"); EdmStructuralProperty simpleTypeId = simpleType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false)); simpleType.AddKeys(simpleTypeId); model.AddElement(simpleType); XElement annotationElement = new XElement("{http://foo}Annotation", "</Schema>" ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleType, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel AnnotationWithValueModel() { EdmModel model = new EdmModel(); EdmOperation simpleOperation = new EdmFunction("DefaultNamespace", "SimpleFunction", EdmCoreModel.Instance.GetString(true)); EdmOperationParameter simpleOperationId = new EdmOperationParameter(simpleOperation, "Id", EdmCoreModel.Instance.GetInt32(true)); simpleOperation.AddParameter(simpleOperationId); model.AddElement(simpleOperation); XElement annotationElement = new XElement("{http://foo}Annotation", "Value 1.0" ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleOperationId, "http://foo", "Annotation", annotation); return(model); }
public static EdmModel SetChildAnnotationAsAnnotationModel() { EdmModel model = new EdmModel(); EdmTerm note = new EdmTerm("DefaultNamespace", "Note", EdmPrimitiveTypeKind.Int16); model.AddElement(note); XElement annotationElement = new XElement("{http://foo}Annotation", new XElement("{http://foo1}Child", "1" ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(note, "http://foo1", "Child", annotation); return(model); }
internal static IEnumerable <IEdmDirectValueAnnotation> ConvertCustomAnnotations(MetadataProviderEdmModel model, IEnumerable <KeyValuePair <string, object> > customAnnotations) { if (customAnnotations != null) { foreach (KeyValuePair <string, object> iteratorVariable0 in customAnnotations) { object iteratorVariable1 = iteratorVariable0.Value; Type iteratorVariable2 = (iteratorVariable1 == null) ? null : iteratorVariable1.GetType(); bool iteratorVariable3 = iteratorVariable2 == typeof(XElement); int length = iteratorVariable0.Key.LastIndexOf(":", StringComparison.Ordinal); if (length == -1) { if (!iteratorVariable3) { string iteratorVariable5 = ConvertAttributeAnnotationValue(iteratorVariable0.Value); yield return(new EdmDirectValueAnnotation(string.Empty, iteratorVariable0.Key, new EdmStringConstant(EdmCoreModel.Instance.GetString(true), iteratorVariable5))); } } else { string namespaceUri = iteratorVariable0.Key.Substring(0, length); string name = iteratorVariable0.Key.Substring(length + 1); if ((iteratorVariable1 == null) || !iteratorVariable3) { string iteratorVariable8 = ConvertAttributeAnnotationValue(iteratorVariable0.Value); yield return(new EdmDirectValueAnnotation(namespaceUri, name, new EdmStringConstant(EdmCoreModel.Instance.GetString(true), iteratorVariable8))); } else if ((iteratorVariable1 != null) && (iteratorVariable2 == typeof(XElement))) { XElement xmlElement = (XElement)iteratorVariable1; string iteratorVariable10 = CreateElementAnnotationStringRepresentation(xmlElement); EdmStringConstant iteratorVariable11 = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), iteratorVariable10); iteratorVariable11.SetIsSerializedAsElement(model, true); yield return(new EdmDirectValueAnnotation(namespaceUri, name, iteratorVariable11)); } } } } }
public static EdmModel OperationImportParameterWithAnnotationModel() { EdmModel model = new EdmModel(); EdmEntityContainer container = new EdmEntityContainer("Default", "Container"); EdmAction simpleOperationAction = new EdmAction("Default", "SimpleFunction", EdmCoreModel.Instance.GetInt32(false)); EdmOperationParameter simpleOperationName = new EdmOperationParameter(simpleOperationAction, "Name", EdmCoreModel.Instance.GetString(true)); simpleOperationAction.AddParameter(simpleOperationName); model.AddElement(simpleOperationAction); EdmOperationImport simpleOperation = new EdmActionImport(container, "SimpleFunction", simpleOperationAction); container.AddElement(simpleOperation); model.AddElement(container); var annotationElement = new XElement("{http://foo}Annotation", 1); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(simpleOperationName, "http://foo", "Annotation", annotation); return(model); }