Пример #1
0
        /// <summary>
        /// Writes the entity result to the response message.
        /// </summary>
        /// <param name="graph">The entity result to write.</param>
        /// <param name="type">The type of the entity.</param>
        /// <param name="messageWriter">The message writer.</param>
        /// <param name="writeContext">The writing context.</param>
        public override void WriteObject(
            object graph,
            Type type,
            ODataMessageWriter messageWriter,
            ODataSerializerContext writeContext)
        {
            RawResult rawResult = graph as RawResult;

            if (rawResult != null)
            {
                graph = rawResult.Result;
                type  = rawResult.Type;
            }

            if (writeContext != null)
            {
                graph = RestierPrimitiveSerializer.ConvertToPayloadValue(graph, writeContext);
            }

            if (graph == null)
            {
                // This is to make ODataRawValueSerializer happily serialize null value.
                graph = string.Empty;
            }

            base.WriteObject(graph, type, messageWriter, writeContext);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRestierSerializerProvider" /> class.
 /// </summary>
 public DefaultRestierSerializerProvider()
 {
     this.feedSerializer = new RestierFeedSerializer(this);
     this.entityTypeSerializer = new RestierEntityTypeSerializer(this);
     this.primitiveSerializer = new RestierPrimitiveSerializer();
     this.rawSerializer = new RestierRawSerializer();
     this.complexTypeSerializer = new RestierComplexTypeSerializer(this);
     this.collectionSerializer = new RestierCollectionSerializer(this);
     this.enumSerializer = new RestierEnumSerializer();
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRestierSerializerProvider" /> class.
 /// </summary>
 public DefaultRestierSerializerProvider()
 {
     this.feedSerializer        = new RestierFeedSerializer(this);
     this.entityTypeSerializer  = new RestierEntityTypeSerializer(this);
     this.primitiveSerializer   = new RestierPrimitiveSerializer();
     this.rawSerializer         = new RestierRawSerializer();
     this.complexTypeSerializer = new RestierComplexTypeSerializer(this);
     this.collectionSerializer  = new RestierCollectionSerializer(this);
     this.enumSerializer        = new RestierEnumSerializer();
 }
Пример #4
0
        /// <summary>
        /// Writes the entity result to the response message.
        /// </summary>
        /// <param name="graph">The entity result to write.</param>
        /// <param name="type">The type of the entity.</param>
        /// <param name="messageWriter">The message writer.</param>
        /// <param name="writeContext">The writing context.</param>
        public override void WriteObject(
            object graph,
            Type type,
            ODataMessageWriter messageWriter,
            ODataSerializerContext writeContext)
        {
            RawResult rawResult = graph as RawResult;

            if (rawResult != null)
            {
                graph = rawResult.Result;
            }

            if (writeContext != null)
            {
                graph = RestierPrimitiveSerializer.ConvertToPayloadValue(writeContext.Model, graph);
            }

            base.WriteObject(graph, type, messageWriter, writeContext);
        }