本文整理汇总了C#中System.Version.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# Version.SelectMany方法的具体用法?C# Version.SelectMany怎么用?C# Version.SelectMany使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Version
的用法示例。
在下文中一共展示了Version.SelectMany方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullPropertyTypeNameTest
public void NullPropertyTypeNameTest()
{
Version[] versions = new Version[] {
null,
new Version(4, 0),
};
var innerComplexType = new EdmComplexType("TestNS", "ComplexType");
innerComplexType.AddStructuralProperty("NumberProperty", EdmCoreModel.Instance.GetInt32(true));
innerComplexType.AddStructuralProperty("StringProperty", EdmCoreModel.Instance.GetString(true));
var outerComplexType = new EdmComplexType("TestNS", "ComplexType");
outerComplexType.AddStructuralProperty("NumberProperty", EdmCoreModel.Instance.GetInt32(true));
outerComplexType.AddStructuralProperty("StringProperty", EdmCoreModel.Instance.GetString(true));
outerComplexType.AddStructuralProperty("InnerComplex", new EdmComplexTypeReference(innerComplexType, true));
var model = new EdmModel();
var complexType = new EdmComplexType("TestNS", "ComplexType");
complexType.AddStructuralProperty("NumberProperty", EdmCoreModel.Instance.GetInt32(true));
complexType.AddStructuralProperty("StringProperty", EdmCoreModel.Instance.GetString(true));
complexType.AddStructuralProperty("InnerComplex", new EdmComplexTypeReference(innerComplexType, true));
model.AddElement(complexType);
var entityType = new EdmEntityType("TestNS", "EntityType", null, false, true);
entityType.AddStructuralProperty("NumberProperty", EdmCoreModel.Instance.GetInt32(true));
entityType.AddStructuralProperty("StringProperty", EdmCoreModel.Instance.GetString(true));
entityType.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(outerComplexType, true));
model.AddElement(entityType);
var container = new EdmEntityContainer("TestNS", "DefaultContainer");
model.AddElement(container);
var testDescriptorSet = versions.SelectMany(dataServiceVersion =>
versions.SelectMany(edmVersion =>
{
model.SetEdmVersion(edmVersion);
// Client only writes type for primitive properties with null value, Server writes it for both primitive and complex.
// Edm.String is never written as the default is Edm.String.
var testCases = new[]
{
new { PropertyName = "NumberProperty", ExpectedServerTypeName = "Edm.Int32", ExpectedClientTypeName = "Edm.Int32" },
new { PropertyName = "StringProperty", ExpectedServerTypeName = (string)null, ExpectedClientTypeName = (string)null },
new { PropertyName = "ComplexProperty", ExpectedServerTypeName = "TestNS.ComplexType", ExpectedClientTypeName = (string)null },
new { PropertyName = "OpenProperty", ExpectedServerTypeName = (string)null, ExpectedClientTypeName = (string)null },
new { PropertyName = "OpenProperty", ExpectedServerTypeName = (string)null, ExpectedClientTypeName = (string)null },
new { PropertyName = "ComplexProperty/NumberProperty", ExpectedServerTypeName = "Edm.Int32", ExpectedClientTypeName = "Edm.Int32" },
new { PropertyName = "ComplexProperty/StringProperty", ExpectedServerTypeName = (string)null, ExpectedClientTypeName = (string)null },
new { PropertyName = "ComplexProperty/InnerComplex", ExpectedServerTypeName = "TestNS.ComplexType", ExpectedClientTypeName = (string)null },
new { PropertyName = "ComplexProperty/InnerComplex/NumberProperty", ExpectedServerTypeName = "Edm.Int32", ExpectedClientTypeName = "Edm.Int32" },
new { PropertyName = "ComplexProperty/InnerComplex/StringProperty", ExpectedServerTypeName = (string)null, ExpectedClientTypeName = (string)null },
};
return testCases.Select(testCase =>
{
string[] propertyPath = testCase.PropertyName.Split('/');
ODataProperty property = new ODataProperty { Name = propertyPath[propertyPath.Length - 1], Value = null };
for (int i = propertyPath.Length - 2; i >= 0; i--)
{
property = new ODataProperty
{
Name = propertyPath[i],
Value = new ODataComplexValue
{
Properties = new[] { property }
}
};
}
Func<XElement, XElement> extractor = (result) =>
{
result = TestAtomUtils.ExtractPropertiesFromEntry(result);
foreach (string name in propertyPath)
{
result = result.Element(TestAtomConstants.ODataXNamespace + name);
}
return result;
};
return new Func<TestODataBehaviorKind, ODataVersion, PayloadWriterTestDescriptor<ODataItem>>(
(behaviorKind, version) =>
{
string expectedTypeName = null;
switch (behaviorKind)
{
case TestODataBehaviorKind.Default:
break;
case TestODataBehaviorKind.WcfDataServicesClient:
expectedTypeName = testCase.ExpectedClientTypeName;
break;
case TestODataBehaviorKind.WcfDataServicesServer:
expectedTypeName = testCase.ExpectedServerTypeName;
break;
}
// Starting with V3, we only support the standard behavior
expectedTypeName = null;
//.........这里部分代码省略.........