private bool TryProcessDeltaNestedResource(IEdmProperty nestedProperty, object resource, ODataResourceWrapper resourceWrapper, ODataDeserializerContext readContext) { string nestedPropertyName = EdmLibHelpers.GetClrPropertyName(nestedProperty, readContext.Model); IDelta resourceDelta = resource as IDelta; if (resourceDelta == null) { return(false); } if (resourceWrapper == null) { return(resourceDelta.TrySetPropertyReferencedValue(nestedPropertyName, null)); } if (resourceWrapper.Resource.Properties == null) { return(false); } IEdmStructuredTypeReference structuredType = nestedProperty.Type.AsStructured(); Delta propertyValueDelta = CreateDeltaInstance(readContext, resourceWrapper, structuredType); ApplyResourceProperties(propertyValueDelta, resourceWrapper, structuredType, readContext); return(resourceDelta.TrySetPropertyReferencedValue(nestedPropertyName, propertyValueDelta)); }
private bool TryProcessDeltaNestedResourceSet(IEdmProperty collectionProperty, object resource, ODataResourceSetWrapper resourceSetWrapper, ODataDeserializerContext readContext) { string collectionPropertyName = EdmLibHelpers.GetClrPropertyName(collectionProperty, readContext.Model); IDelta resourceDelta = resource as IDelta; if (resourceDelta == null) { return(false); } if (resourceSetWrapper == null) { return(resourceDelta.TrySetPropertyReferencedValue(collectionPropertyName, null)); } if (resourceSetWrapper.Resources == null) { return(false); } IEdmStructuredTypeReference structuredElementType = collectionProperty.Type.AsCollection().ElementType().AsStructured(); Type clrElementType = EdmLibHelpers.GetClrType(structuredElementType, readContext.Model); Type deltaType = typeof(Delta <>).MakeGenericType(clrElementType); IEnumerable <string> structuralProperties = GetUpdatableProperties(readContext.Model, structuredElementType); IList elementDeltas = new ArrayList(); foreach (ODataResourceWrapper resourceWrapper in resourceSetWrapper.Resources) { Delta elementDelta = (Delta)Activator.CreateInstance(deltaType, clrElementType, structuralProperties); ApplyResourceProperties(elementDelta, resourceWrapper, structuredElementType, readContext); elementDeltas.Add(elementDelta); } return(resourceDelta.TrySetPropertyCollectionValue(collectionPropertyName, elementDeltas)); }