Ejemplo n.º 1
0
 /// <summary>
 /// Validates a resource in an expanded link to make sure that the types match.
 /// </summary>
 /// <param name="resourceType">The <see cref="IEdmStructuredType"/> of the resource.</param>
 /// <param name="parentNavigationPropertyType">The type of the parent navigation property or
 /// complex property or complex collection property.</param>
 public virtual void ValidateResourceInNestedResourceInfo(
     IEdmStructuredType resourceType,
     IEdmStructuredType parentNavigationPropertyType)
 {
     if (settings.ThrowIfTypeConflictsWithMetadata)
     {
         WriterValidationUtils.ValidateNestedResource(
             resourceType, parentNavigationPropertyType);
     }
 }
Ejemplo n.º 2
0
        public PropertySerializationInfo GetProperty(string name, string uniqueName, IEdmStructuredType owningType)
        {
            PropertySerializationInfo propertyInfo;

            if (!propertyInfoDictionary.TryGetValue(uniqueName, out propertyInfo))
            {
                WriterValidationUtils.ValidatePropertyName(name);

                propertyInfo = new PropertySerializationInfo(name, owningType);
                propertyInfoDictionary[uniqueName] = propertyInfo;
            }

            return(propertyInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validates that the expected property allows null value.
        /// </summary>
        /// <param name="expectedPropertyTypeReference">The expected property type or null if we
        /// don't have any.</param>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="isTopLevel">true if the property is top-level.</param>
        /// <param name="model">The model used to get the OData version.</param>
        public void ValidateNullPropertyValue(IEdmTypeReference expectedPropertyTypeReference,
                                              string propertyName, bool isTopLevel, IEdmModel model)
        {
            if (settings.ThrowIfTypeConflictsWithMetadata)
            {
                WriterValidationUtils.ValidateNullPropertyValue(expectedPropertyTypeReference, propertyName, model);
            }

            if (isTopLevel && this.settings.LibraryCompatibility >= ODataLibraryCompatibility.Version7)
            {
                // From the spec:
                // 11.2.3 Requesting Individual Properties
                // ...
                // If the property is single-valued and has the null value, the service responds with 204 No Content.
                // ...
                throw new ODataException(Strings.ODataMessageWriter_CannotWriteTopLevelNull);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Validates that the specified nested resource info has cardinality set, i.e., it has the
 /// IsCollection value set.
 /// </summary>
 /// <param name="nestedResourceInfo">The nested resource info to validate.</param>
 public virtual void ValidateNestedResourceInfoHasCardinality(
     ODataNestedResourceInfo nestedResourceInfo)
 {
     WriterValidationUtils.ValidateNestedResourceInfoHasCardinality(nestedResourceInfo);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Validates the input <see cref="IEdmStructuredType"/> meets the derived type constaints on the <see cref="IEdmNavigationSource"/>.
 /// </summary>
 /// <param name="resourceType">The input resource type.</param>
 /// <param name="metadataType">The type from metadata.</param>
 /// <param name="derivedTypeConstraints">The derived type constraints on the nested resource.</param>
 /// <param name="itemKind">The item kind.</param>
 /// <param name="itemName">The item name.</param>
 public void ValidateDerivedTypeConstraint(IEdmStructuredType resourceType,
                                           IEdmStructuredType metadataType, IEnumerable <string> derivedTypeConstraints, string itemKind, string itemName)
 {
     WriterValidationUtils.ValidateDerivedTypeConstraint(resourceType, metadataType, derivedTypeConstraints, itemKind, itemName);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Validates that a property with the specified name exists on a given structured type.
 /// The structured type can be null if no metadata is available.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="owningStructuredType">Hosting type of the property or null if no metadata is
 /// available.</param>
 /// <returns>An <see cref="IEdmProperty"/> instance representing the specified property or
 /// null if no metadata is available.</returns>
 public IEdmProperty ValidatePropertyDefined(string propertyName,
                                             IEdmStructuredType owningStructuredType)
 {
     return(WriterValidationUtils.ValidatePropertyDefined(
                propertyName, owningStructuredType, settings.ThrowOnUndeclaredPropertyForNonOpenType));
 }