Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs')
-rw-r--r--src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs b/src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs
index 9d1a9853..fece8659 100644
--- a/src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs
+++ b/src/System.Web.Http.OData/OData/Formatter/Deserialization/ODataEntityDeserializer.cs
@@ -48,16 +48,34 @@ namespace System.Web.Http.OData.Formatter.Deserialization
throw Error.Argument("entry", SRResources.ItemMustBeOfType, typeof(ODataEntry).Name);
}
- ODataEntryAnnotation entryAnnotation = entry.GetAnnotation<ODataEntryAnnotation>();
- Contract.Assert(entryAnnotation != null);
+ if (EdmEntityType.FullName() != entry.TypeName)
+ {
+ // received a derived type in a base type deserializer.
+ // delegate it to the appropriate derived type deserializer.
+ IEdmEntityType entityType = EdmModel.FindType(entry.TypeName) as IEdmEntityType;
+ Contract.Assert(entityType != null, "edmlib should have already validated that it knows the edm type and is the same as or derives from EdmEntityType");
- CreateEntityResource(entryAnnotation, EdmEntityType, readContext);
+ if (entityType.IsAbstract)
+ {
+ throw Error.InvalidOperation(SRResources.CannotInstantiateAbstractEntityType, entry.TypeName);
+ }
- RecurseEnter(readContext);
- ApplyEntityProperties(entry, entryAnnotation, readContext);
- RecurseLeave(readContext);
+ ODataEntityDeserializer deserializer = DeserializerProvider.GetODataDeserializer(new EdmEntityTypeReference(entityType, isNullable: false)) as ODataEntityDeserializer;
+ return deserializer.ReadInline(entry, readContext);
+ }
+ else
+ {
+ ODataEntryAnnotation entryAnnotation = entry.GetAnnotation<ODataEntryAnnotation>();
+ Contract.Assert(entryAnnotation != null);
+
+ CreateEntityResource(entryAnnotation, EdmEntityType, readContext);
- return entryAnnotation.EntityResource;
+ RecurseEnter(readContext);
+ ApplyEntityProperties(entry, entryAnnotation, readContext);
+ RecurseLeave(readContext);
+
+ return entryAnnotation.EntityResource;
+ }
}
internal static ODataItem ReadEntryOrFeed(ODataReader odataReader, ODataDeserializerContext readContext)