public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
        {
            // We don't need to check if v3 because output formatter does that for us
            IEdmTypeReference edmType = writeContext.GetEdmType(graph, type);

            if (!edmType.IsStructured())
            {
                throw new ArgumentException("type");
            }

            messageWriter.PreemptivelyTranslateResponseStream(
                edmType,
                (writer) => base.WriteObject(graph, type, writer, writeContext));
        }
Ejemplo n.º 2
0
        public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
        {
            if (messageWriter == null)
            {
                throw new ArgumentNullException(nameof(messageWriter));
            }

            if (writeContext == null)
            {
                throw new ArgumentNullException(nameof(writeContext));
            }

            IEdmTypeReference resourceSetType = writeContext.GetEdmType(graph, type);

            messageWriter.PreemptivelyTranslateResponseStream(
                resourceSetType,
                (writer) => base.WriteObject(graph, type, writer, writeContext));
        }
        public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
        {
            if (messageWriter == null)
            {
                throw new ArgumentNullException(nameof(messageWriter));
            }

            if (writeContext == null)
            {
                throw new ArgumentNullException(nameof(writeContext));
            }

            IEdmTypeReference collectionType = writeContext.GetEdmType(graph, type);

            // Translate types in response stream according to expected collection type
            messageWriter.PreemptivelyTranslateResponseStream(
                collectionType,
                (writer) => base.WriteObject(graph, type, writer, writeContext));
        }