本文整理汇总了C#中EdmVersion类的典型用法代码示例。如果您正苦于以下问题:C# EdmVersion类的具体用法?C# EdmVersion怎么用?C# EdmVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmVersion类属于命名空间,在下文中一共展示了EdmVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CsdlXElementComparer
private void CsdlXElementComparer(IEnumerable<XElement> expectedCsdls, IEnumerable<XElement> actualCsdls, EdmVersion version)
{
var updatedExpectedCsdls = ModelBuilderHelpers.ReplaceCsdlNamespacesForEdmVersion(expectedCsdls.ToArray(), version);
var updatedActualCsdls = ModelBuilderHelpers.ReplaceCsdlNamespacesForEdmVersion(actualCsdls.ToArray(), version);
new ConstructiveApiCsdlXElementComparer().Compare(updatedExpectedCsdls.ToList(), updatedActualCsdls.ToList());
}
示例2: InvalidEntitySetNameReference
public static XElement[] InvalidEntitySetNameReference(EdmVersion edmVersion)
{
const string csdl =
@"<?xml version=""1.0"" encoding=""utf-16""?>
<Schema Namespace=""Bork"" Alias=""Self"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
<EntityType Name=""Entity1"">
<Key>
<PropertyRef Name=""Id"" />
</Key>
<Property Name=""Id"" Type=""Int32"" Nullable=""false""/>
<Property Name=""OtherId"" Type=""Int32"" />
<NavigationProperty Name=""Navigation"" Type=""Bork.Entity2"" Nullable=""false"" Partner=""Navigation"" />
</EntityType>
<EntityType Name=""Entity2"">
<Key>
<PropertyRef Name=""Id"" />
</Key>
<Property Name=""Id"" Type=""Int32"" Nullable=""false""/>
<Property Name=""OtherId"" Type=""Int32"" Nullable=""false""/>
<NavigationProperty Name=""Navigation"" Type=""Collection(Bork.Entity1)"" Partner=""Navigation"" />
</EntityType>
<EntityContainer Name=""Container"">
<EntitySet Name=""Entity1_a"" EntityType=""Bork.Entity1"">
<NavigationPropertyBinding Path=""Navigation"" Target=""Entity2_b"" />
</EntitySet>
<EntitySet Name=""Entity2_a"" EntityType=""Bork.Entity2"">
<NavigationPropertyBinding Path=""Navigation"" Target=""Entity1_b"" />
</EntitySet>
</EntityContainer>
</Schema>";
return FixUpWithEdmVersion(csdl, edmVersion);
}
示例3: Serialize
/// <summary>
/// Serializes the <paramref name="schema"/> in the specified <paramref name="csdlVersion"/> and returns it.
/// </summary>
/// <param name="csdlVersion">The CSDL version to use for serializing the entity model schema.</param>
/// <param name="schema">The schema to serialize.</param>
/// <returns>The serialized <paramref name="schema"/>.</returns>
public IEnumerable<FileContents<XElement>> Serialize(EdmVersion csdlVersion, EntityModelSchema schema)
{
ExceptionUtilities.Assert(schema != null, "schema != null");
// TODO: Can we inherit from the default implemenation of the CSDL content generator instead of doing this in a separate step?
schema = this.ODataAnnotationConverter.ConvertToProductAnnotations(schema);
return this.BaseEntityModelSchemaSerializer.Generate(csdlVersion, schema);
}
示例4: ParserSimpleIdentifierTypeReferenceCsdlSchemaCompliantTest
public void ParserSimpleIdentifierTypeReferenceCsdlSchemaCompliantTest()
{
var edmVersions = new EdmVersion[] { EdmVersion.V40 };
foreach (var edmVersion in edmVersions)
{
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.ConcurrencyModeTypes(edmVersion), edmVersion);
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.CollectionTypeTypeRefSimpleTypeCanHaveFacets(edmVersion), edmVersion);
}
}
示例5: ParserOpenTypeSupportCsdlSchemaCompliantTest
public void ParserOpenTypeSupportCsdlSchemaCompliantTest()
{
var edmVersions = new EdmVersion[] { EdmVersion.V40 };
foreach (var edmVersion in edmVersions)
{
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.OpenTypeSupportInV40(edmVersion), edmVersion);
this.BasicXsdValidationTestForParserInputCsdl(ODataTestModelBuilder.ODataTestModelWithOpenType, edmVersion);
}
}
示例6: OperationsWithReturnTypeOfPrimitiveDataTypeSchemasEdm
public static IEdmModel OperationsWithReturnTypeOfPrimitiveDataTypeSchemasEdm(EdmVersion edmVersion)
{
var model = new EdmModel();
foreach (var function in OperationTestModelBuilder.EdmFunctionsWithReturnTypePrimitiveDataType(edmVersion))
{
model.AddElement(function);
}
return model;
}
示例7: AllPrimitiveEdmTypes
public static IEnumerable<IEdmPrimitiveTypeReference> AllPrimitiveEdmTypes(EdmVersion edmVersion, bool isNullable)
{
IEnumerable<IEdmPrimitiveTypeReference> primitiveTypes = AllNonSpatialPrimitiveEdmTypes(isNullable);
if (edmVersion >= EdmVersion.V40)
{
primitiveTypes = primitiveTypes.Concat(AllSpatialEdmTypes(isNullable));
}
return primitiveTypes;
}
示例8: OperationsWith2ParametersSchemasEdm
public static IEdmModel OperationsWith2ParametersSchemasEdm(EdmVersion edmVersion)
{
var model = new EdmModel();
foreach (var operation in OperationTestModelBuilder.EdmOperationsWith2Parameters(edmVersion))
{
model.AddElement(operation);
}
return model;
}
示例9: ParserComplexTypeWithBaseTypeAbstractCsdlSchemaCompliantTest
public void ParserComplexTypeWithBaseTypeAbstractCsdlSchemaCompliantTest()
{
var edmVersions = new EdmVersion[] { EdmVersion.V40 };
foreach (var edmVersion in edmVersions)
{
this.BasicXsdValidationTestForParserInputCsdl(ModelBuilder.ComplexTypeWithBaseType(edmVersion), edmVersion);
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.ComplexTypeBaseTypeSupportInV11(edmVersion), edmVersion);
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.EdmComplexTypeInvalidIsPolymorphic(edmVersion), edmVersion);
this.BasicXsdValidationTestForParserInputCsdl(ValidationTestModelBuilder.ComplexTypeIsAbstractSupportInV40(edmVersion), edmVersion);
}
}
示例10: GetCsdlFullNamespace
public static XNamespace GetCsdlFullNamespace(EdmVersion csdlVersion)
{
if (csdlVersion == EdmVersion.V40)
{
return EdmConstants.EdmOasisNamespace;
}
else
{
throw new ArgumentOutOfRangeException("CSDL Schema Version is not supported: " + csdlVersion.ToString());
}
}
示例11: ReplaceCsdlNamespacesForEdmVersion
public static IEnumerable<XElement> ReplaceCsdlNamespacesForEdmVersion(XElement[] csdls, EdmVersion edmVersion)
{
var edmNamespace = EdmLibCsdlContentGenerator.GetCsdlFullNamespace(edmVersion);
for (int i = 0; i < csdls.Count(); ++i)
{
if (edmNamespace != csdls[i].Name.Namespace)
{
csdls[i] = XElement.Parse(csdls[i].ToString().Replace(csdls[i].Name.Namespace.NamespaceName, edmNamespace.NamespaceName));
}
}
return csdls;
}
示例12: GetEdmVersion
public static EdmVersion GetEdmVersion(XNamespace edmNamespace)
{
var edmVersions = new EdmVersion[] { EdmVersion.V40 };
foreach (var edmVersion in edmVersions)
{
if (GetCsdlFullNamespace(edmVersion) == edmNamespace)
{
return edmVersion;
}
}
throw new ArgumentOutOfRangeException("The namespace is not a EDM namespace " + edmNamespace.NamespaceName);
}
示例13: SystemNamespace
public static XElement[] SystemNamespace(EdmVersion edmVersion)
{
const string csdl =
@"<?xml version=""1.0"" encoding=""utf-16""?>
<Schema Namespace=""Edm"" Alias=""Self"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
<EntityType Name=""Clod"">
<Key>
<PropertyRef Name=""Id"" />
</Key>
<Property Name=""Id"" Type=""Int32"" Nullable=""false""/>
<Property Name=""Bar"" Type=""Int32"" />
</EntityType>
</Schema>";
return FixUpWithEdmVersion(csdl, edmVersion);
}
示例14: GenerateContentsWithoutDefinition
private void GenerateContentsWithoutDefinition(EdmVersion edmVersion, IEdmModel definitionModel)
{
IEnumerable<EdmError> errors;
var contentsWithoutDefinition = this.GetSerializerResult(definitionModel, edmVersion, out errors).Select(XElement.Parse);
var stripTheseElements = new[] { "Term", "Annotations", "Annotation"};
foreach (var contents in contentsWithoutDefinition)
{
contents.Descendants().Where(e => stripTheseElements.Contains(e.Name.LocalName)).Remove();
string namespaceName = contents.Attribute("Namespace").Value;
this.namespaceToContents.Add(namespaceName, contents);
}
}
示例15: ReplaceCsdlNamespaceForEdmVersion
public static string ReplaceCsdlNamespaceForEdmVersion(string csdl, EdmVersion edmVersion)
{
var edmNamespace = EdmLibCsdlContentGenerator.GetCsdlFullNamespace(edmVersion);
var xmlReader = XmlReader.Create(new StringReader(csdl));
while (xmlReader.Read())
{
if (xmlReader.Name == "Schema")
{
break;
}
}
if (xmlReader.EOF)
{
throw new ArgumentException("{0} is not a well formed CSDL.");
}
return csdl.Replace(xmlReader.NamespaceURI, edmNamespace.NamespaceName);
}