Exemplo n.º 1
0
        /// <summary>
        /// Returns the new XmlWriter to cache the payload for firing WritingEntity event.
        /// </summary>
        /// <param name="entry">ODataEntry instance that is currently getting serialized.</param>
        /// <param name="entryWriter">XmlWriter that is used to write the payload.</param>
        /// <returns>XmlWriter instance that needs to be used to write the payload for the given odataentry.</returns>
        private static XmlWriter StartEntryXmlCustomizer(ODataEntry entry, XmlWriter entryWriter)
        {
            WritingEntityInfo writingEntityInfo = entry.GetAnnotation <WritingEntityInfo>();

            Debug.Assert(writingEntityInfo.RequestInfo.HasWritingEventHandlers, "this.requestInfo.HasWritingEventHandlers");
            return(writingEntityInfo.EntryPayload.CreateWriter());
        }
Exemplo n.º 2
0
        private static void EndEntryXmlCustomizer(ODataEntry entry, XmlWriter entryWriter, XmlWriter parentWriter)
        {
            WritingEntityInfo annotation = entry.GetAnnotation <WritingEntityInfo>();

            entryWriter.Close();
            annotation.RequestInfo.FireWritingEntityEvent(annotation.Entity, annotation.EntryPayload.Root, null);
            annotation.EntryPayload.Root.WriteTo(parentWriter);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fires the WritingEntity event, and then copies the payload into the parent writer.
        /// </summary>
        /// <param name="entry">ODataEntry that is currently getting serialized.</param>
        /// <param name="entryWriter">XmlWriter writer instance that got returned by StartEntryXmlCustomizer method.</param>
        /// <param name="parentWriter">Parent writer to which the payload needs to get copied to, after firing the event.</param>
        private static void EndEntryXmlCustomizer(ODataEntry entry, XmlWriter entryWriter, XmlWriter parentWriter)
        {
            WritingEntityInfo writingEntityInfo = entry.GetAnnotation <WritingEntityInfo>();

            Debug.Assert(writingEntityInfo.RequestInfo.HasWritingEventHandlers, "this.requestInfo.HasWritingEventHandlers");
#if PORTABLELIB
            entryWriter.Dispose();
#else
            entryWriter.Close();
#endif
            writingEntityInfo.RequestInfo.FireWritingEntityEvent(writingEntityInfo.Entity, (XElement)writingEntityInfo.EntryPayload.Root, null);
            writingEntityInfo.EntryPayload.Root.WriteTo(parentWriter);
        }