本文整理汇总了C#中IEdmTypeReference.IsNonEntityODataCollectionTypeKind方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmTypeReference.IsNonEntityODataCollectionTypeKind方法的具体用法?C# IEdmTypeReference.IsNonEntityODataCollectionTypeKind怎么用?C# IEdmTypeReference.IsNonEntityODataCollectionTypeKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmTypeReference
的用法示例。
在下文中一共展示了IEdmTypeReference.IsNonEntityODataCollectionTypeKind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyCollectionComplexItemType
/// <summary>
/// Verifies that in case of collection types, the item type is valid.
/// </summary>
/// <param name="expectedTypeReference">The expected type reference.</param>
/// <param name="payloadType">The payload type.</param>
/// <remarks>
/// This method verifies that item type is not a derived complex type, we want to explicitly disallow that case for possible future enablement.
/// </remarks>
private static void VerifyCollectionComplexItemType(IEdmTypeReference expectedTypeReference, IEdmType payloadType)
{
Debug.Assert(expectedTypeReference != null, "expectedTypeReference != null");
Debug.Assert(payloadType != null, "payloadType != null");
Debug.Assert(expectedTypeReference.IsNonEntityODataCollectionTypeKind(), "This method only works on atomic collections.");
Debug.Assert(payloadType.IsNonEntityODataCollectionTypeKind(), "This method only works on atomic collections.");
IEdmCollectionTypeReference collectionTypeReference = ValidationUtils.ValidateCollectionType(expectedTypeReference);
IEdmTypeReference expectedItemTypeReference = collectionTypeReference.GetCollectionItemType();
if (expectedItemTypeReference != null && expectedItemTypeReference.IsODataComplexTypeKind())
{
IEdmCollectionTypeReference payloadCollectionTypeReference = ValidationUtils.ValidateCollectionType(payloadType.ToTypeReference());
IEdmTypeReference payloadItemTypeReference = payloadCollectionTypeReference.GetCollectionItemType();
if (payloadItemTypeReference != null && payloadItemTypeReference.IsODataComplexTypeKind())
{
// Note that this method is called from both strict and lax code paths, so we must not fail if the types are not related.
// The strict caller will fail if the types are not equal after this method returns. We use this method there to only get
// a more specific error message if the derived complex types are used.
VerifyComplexType(expectedItemTypeReference, payloadItemTypeReference.Definition, /* failIfNotRelated */ false);
}
}
}
示例2: ValidateCollectionType
internal static IEdmCollectionTypeReference ValidateCollectionType(IEdmTypeReference typeReference)
{
IEdmCollectionTypeReference reference = typeReference.AsCollectionOrNull();
if ((reference != null) && !typeReference.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_InvalidCollectionTypeReference(typeReference.TypeKind()));
}
return reference;
}
示例3: ValidateTypeSupported
/// <summary>
/// Validates whether the specified type reference is supported in the current version.
/// </summary>
/// <param name="typeReference">The type reference to check.</param>
/// <param name="version">The version currently used.</param>
internal static void ValidateTypeSupported(IEdmTypeReference typeReference, ODataVersion version)
{
DebugUtils.CheckNoExternalCallers();
if (typeReference != null)
{
if (typeReference.IsNonEntityODataCollectionTypeKind())
{
ODataVersionChecker.CheckCollectionValue(version);
}
else if (typeReference.IsSpatial())
{
ODataVersionChecker.CheckSpatialValue(version);
}
}
}
示例4: ValidateNullValueAllowed
/// <summary>
/// Validates that the specified <paramref name="expectedValueTypeReference"/> allows null values.
/// </summary>
/// <param name="expectedValueTypeReference">The expected type for the value, or null if no such type is available.</param>
/// <param name="validateNullValue">true to validate the null value; otherwise false.</param>
/// <param name="model">The model to use to get the data service version.</param>
private static void ValidateNullValueAllowed(IEdmTypeReference expectedValueTypeReference, bool validateNullValue, IEdmModel model)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(model != null, "For null validation, model is required.");
if (validateNullValue && expectedValueTypeReference != null)
{
Debug.Assert(
expectedValueTypeReference.IsODataPrimitiveTypeKind() ||
expectedValueTypeReference.IsODataComplexTypeKind() ||
expectedValueTypeReference.IsNonEntityODataCollectionTypeKind(),
"Only primitive, complex and collection types are supported by this method.");
if (expectedValueTypeReference.IsODataPrimitiveTypeKind())
{
if (!expectedValueTypeReference.IsNullable)
{
throw new ODataException(Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
}
else if (expectedValueTypeReference.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
else if (expectedValueTypeReference.IsODataComplexTypeKind())
{
if (ValidationUtils.ShouldValidateComplexPropertyNullValue(model))
{
IEdmComplexTypeReference complexTypeReference = expectedValueTypeReference.AsComplex();
if (!complexTypeReference.IsNullable)
{
throw new ODataException(Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
}
}
}
}
示例5: ValidateCollectionType
/// <summary>
/// Validates that the <paramref name="typeReference"/> represents a collection type.
/// </summary>
/// <param name="typeReference">The type reference to validate.</param>
/// <returns>The <see cref="IEdmCollectionTypeReference"/> instance representing the collection passed as <paramref name="typeReference"/>.</returns>
internal static IEdmCollectionTypeReference ValidateCollectionType(IEdmTypeReference typeReference)
{
DebugUtils.CheckNoExternalCallers();
IEdmCollectionTypeReference collectionTypeReference = typeReference.AsCollectionOrNull();
if (collectionTypeReference != null && !typeReference.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(Strings.ValidationUtils_InvalidCollectionTypeReference(typeReference.TypeKind()));
}
return collectionTypeReference;
}
示例6: ValidateNullValueAllowed
private static void ValidateNullValueAllowed(IEdmTypeReference expectedValueTypeReference, bool validateNullValue, IEdmModel model)
{
if (validateNullValue && (expectedValueTypeReference != null))
{
if (expectedValueTypeReference.IsODataPrimitiveTypeKind())
{
if (!expectedValueTypeReference.IsNullable)
{
throw new ODataException(Microsoft.Data.OData.Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
}
else
{
if (expectedValueTypeReference.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(Microsoft.Data.OData.Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
if ((expectedValueTypeReference.IsODataComplexTypeKind() && ValidationUtils.ShouldValidateComplexPropertyNullValue(model)) && !expectedValueTypeReference.AsComplex().IsNullable)
{
throw new ODataException(Microsoft.Data.OData.Strings.ReaderValidationUtils_NullValueForNonNullableType(expectedValueTypeReference.ODataFullName()));
}
}
}
}
示例7: ReadProperty
/// <summary>
/// Reads a property.
/// </summary>
/// <param name="expectedPropertyTypeReference">The expected type reference of the property value.</param>
/// <param name="nullValueReadBehaviorKind">Behavior to use when reading null value for the property.</param>
/// <param name="epmPresent">Whether any EPM mappings exist.</param>
/// <returns>The ODataProperty representing the property in question; if null is returned from this method it means that the property is to be ignored.</returns>
/// <remarks>
/// Pre-Condition: XmlNodeType.Element - The XML element representing the property to read.
/// Note that the method does NOT check for the property name neither it resolves the property against metadata.
/// Post-Condition: Any - The node after the property.
/// </remarks>
private ODataProperty ReadProperty(IEdmTypeReference expectedPropertyTypeReference, ODataNullValueBehaviorKind nullValueReadBehaviorKind, bool epmPresent)
{
Debug.Assert(
expectedPropertyTypeReference == null || expectedPropertyTypeReference.IsODataPrimitiveTypeKind() ||
expectedPropertyTypeReference.IsODataComplexTypeKind() || expectedPropertyTypeReference.IsNonEntityODataCollectionTypeKind(),
"Only primitive, complex and collection types can be read by this method.");
this.AssertXmlCondition(XmlNodeType.Element);
Debug.Assert(this.UseServerFormatBehavior || this.XmlReader.NamespaceEquals(this.XmlReader.ODataNamespace), "Property elements must be in the OData namespace (unless we are running in WCF DS server format mode).");
this.XmlReader.AssertNotBuffering();
ODataProperty property = new ODataProperty();
string propertyName = this.XmlReader.LocalName;
ValidationUtils.ValidatePropertyName(propertyName);
property.Name = propertyName;
object propertyValue = this.ReadNonEntityValueImplementation(
expectedPropertyTypeReference,
/*duplicatePropertyNamesChecker*/ null,
/*collectionValidator*/ null,
nullValueReadBehaviorKind == ODataNullValueBehaviorKind.Default,
epmPresent);
if (nullValueReadBehaviorKind == ODataNullValueBehaviorKind.IgnoreValue && propertyValue == null)
{
property = null;
}
else
{
property.Value = propertyValue;
}
// Read past the end tag of the property or the start tag if the element is empty.
this.XmlReader.Read();
this.XmlReader.AssertNotBuffering();
return property;
}