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 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 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 IEdmModel ModelWithBadElementAnnotation() { EdmModel model = new EdmModel(); EdmEntityType customer = new EdmEntityType("Westwind", "Customer"); EdmStructuralProperty customerID = customer.AddStructuralProperty("IDC", EdmCoreModel.Instance.GetInt32(false)); customer.AddKeys(customerID); model.AddElement(customer); EdmEntityContainer container = new EdmEntityContainer("Westwind", "Gunk"); model.AddElement(container); EdmEntitySet customers = new EdmEntitySet(container, "Customers", customer); container.AddElement(customers); XElement contacts = new XElement("{http://msn}Contacts", new XElement("{http://msn}Contact", new XElement("{http://msn}Name", "Patrick Hines"), new XElement("{http://msn}Phone", "206-555-0144"), new XElement("{http://msn}Address", new XElement("{http://msn}Street1", "123 Main St"), new XElement("{http://msn}City", "Mercer Island"), new XElement("{http://msn}State", "WA"), new XElement("{http://msn}Postal", "68042") ) ) ); var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), contacts.ToString()); annotation.SetIsSerializedAsElement(model, true); model.SetAnnotationValue(customer, "http://other", "Contacts", annotation); return model; }
private static EdmModel SetNullAnnotationNameModel() { EdmModel model = new EdmModel(); EdmEnumType spicy = new EdmEnumType("DefaultNamespace", "Spicy"); model.AddElement(spicy); 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(spicy, "http://foo", null, annotation); return model; }
public static EdmModel OutOfLineValueAnnotationWithAnnotationModel() { 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); EdmAnnotation valueAnnotation = new EdmAnnotation( 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; }
public static EdmModel ValueTermWithAnnotationModel() { 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 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 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; }
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; }
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 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 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 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; }