コード例 #1
0
 /// <summary>Writes a deleted resource and performs an action in-between.</summary>
 /// <param name="deletedResource">The deletedresource to write.</param>
 /// <param name="nestedAction">The action to perform in-between the writing.</param>
 /// <returns>This ODataWriter, allowing for chaining operations.</returns>
 public ODataWriter Write(ODataDeletedResource deletedResource, Action nestedAction)
 {
     WriteStart(deletedResource);
     nestedAction();
     WriteEnd();
     return(this);
 }
コード例 #2
0
        /// <summary>Gets an ODataDeltaDeletedEntry representation of the ODataDeletedResource</summary>
        /// <param name="entry">The ODataDeletedResource.</param>
        /// <returns>A returned ODataDeltaDeletedEntry to write.</returns>
        internal static ODataDeltaDeletedEntry GetDeltaDeletedEntry(ODataDeletedResource entry)
        {
            ODataDeltaDeletedEntry deletedEntry = new ODataDeltaDeletedEntry(entry.Id.OriginalString, entry.Reason ?? DeltaDeletedEntryReason.Deleted);

            if (entry.SerializationInfo != null)
            {
                deletedEntry.SetSerializationInfo(entry.SerializationInfo);
            }

            return(deletedEntry);
        }
コード例 #3
0
        /// <summary>
        /// Writes an <see cref="ODataResourceBase"/> as either a resource or a deleted resource.
        /// </summary>
        /// <param name="writer">The <see cref="ODataWriter"/> to use to write the (deleted) resource.</param>
        /// <param name="resource">The resource, or deleted resource, to write.</param>
        private static void WriteStartResource(ODataWriter writer, ODataResourceBase resource)
        {
            ODataDeletedResource deletedResource = resource as ODataDeletedResource;

            if (deletedResource != null)
            {
                writer.WriteStart(deletedResource);
            }
            else
            {
                // will write a null resource if resource is not an ODataResource
                writer.WriteStart(resource as ODataResource);
            }
        }
コード例 #4
0
        /// <summary>Gets an ODataDeletedResource representation of the ODataDeltaDeletedEntry</summary>
        /// <param name="entry">The ODataDeltaDeletedEntry.</param>
        /// <returns>A returned ODataDeletedResource to write.</returns>
        internal static ODataDeletedResource GetDeletedResource(ODataDeltaDeletedEntry entry)
        {
            Uri id = UriUtils.StringToUri(entry.Id);
            ODataDeletedResource deletedResource = new ODataDeletedResource()
            {
                Id     = id,
                Reason = entry.Reason,
            };

            if (entry.SerializationInfo != null)
            {
                deletedResource.SerializationInfo = new ODataResourceSerializationInfo()
                {
                    NavigationSourceName = entry.SerializationInfo == null ? null : entry.SerializationInfo.NavigationSourceName
                };
            }

            return(deletedResource);
        }
コード例 #5
0
 /// <summary>
 /// Asynchronously writing a delta deleted resource.
 /// </summary>
 /// <param name="deletedResource">The deleted resource to write.</param>
 /// <returns>A task instance that represents the asynchronous write operation.</returns>
 public virtual Task WriteStartAsync(ODataDeletedResource deletedResource)
 {
     return(TaskUtils.GetTaskForSynchronousOperation(() => this.WriteStart(deletedResource)));
 }
コード例 #6
0
 /// <summary> Starts writing a deleted resource.</summary>
 /// <param name="deletedResource">The deleted resource to write.</param>
 public virtual void WriteStart(ODataDeletedResource deletedResource)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 /// <summary>Writes a deleted resource.</summary>
 /// <param name="deletedResource">The deleted resource to write.</param>
 /// <returns>This ODataWriter, allowing for chaining operations.</returns>
 public ODataWriter Write(ODataDeletedResource deletedResource)
 {
     WriteStart(deletedResource);
     WriteEnd();
     return(this);
 }