コード例 #1
0
        /// <summary>
        /// Writes the given deltaDeletedEntry specified by the parameter graph as a part of an existing OData message using the given
        /// messageWriter and the writeContext.
        /// </summary>
        /// <param name="graph">The object to be written.</param>
        /// <param name="writer">The <see cref="ODataDeltaWriter" /> to be used for writing.</param>
        /// <param name="writeContext">The <see cref="ODataSerializerContext"/>.</param>
        public virtual async Task WriteDeletedResourceAsync(object graph, ODataWriter writer, ODataSerializerContext writeContext)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            EdmDeltaDeletedResourceObject edmDeltaDeletedEntity = graph as EdmDeltaDeletedResourceObject;

            if (edmDeltaDeletedEntity == null)
            {
                throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, graph?.GetType().FullName));
            }

            Uri id = edmDeltaDeletedEntity.Id;
            DeltaDeletedEntryReason reason          = edmDeltaDeletedEntity.Reason ?? DeltaDeletedEntryReason.Deleted;
            ODataDeletedResource    deletedResource = new ODataDeletedResource(id, reason);

            if (edmDeltaDeletedEntity.NavigationSource != null)
            {
                ODataResourceSerializationInfo serializationInfo = new ODataResourceSerializationInfo
                {
                    NavigationSourceName = edmDeltaDeletedEntity.NavigationSource.Name
                };
                deletedResource.SetSerializationInfo(serializationInfo);
            }

            if (deletedResource != null)
            {
                await writer.WriteStartAsync(deletedResource).ConfigureAwait(false);

                await writer.WriteEndAsync().ConfigureAwait(false);
            }
        }
コード例 #2
0
ファイル: ReaderUtils.cs プロジェクト: OpenSilver/odata.net
 /// <summary>
 /// Creates a new <see cref="ODataDeletedResource"/> instance to return to the user.
 /// </summary>
 /// <param name="id">The id of the deleted resource, or null if not yet known.</param>
 /// <param name="reason">The <see cref="DeltaDeletedEntryReason"/> for the deleted resource.</param>
 /// <returns>The newly created deleted resource.</returns>
 /// <remarks>The method populates the Properties property with an empty read only enumeration.</remarks>
 internal static ODataDeletedResource CreateDeletedResource(Uri id, DeltaDeletedEntryReason reason)
 {
     return(new ODataDeletedResource(id, reason)
     {
         Properties = new ReadOnlyEnumerable <ODataProperty>()
     });
 }
コード例 #3
0
        /// <summary>
        /// Initializes a new <see cref="ODataDeletedResource"/>.
        /// </summary>
        /// <param name="id">The id of the deleted entity, which may be absolute or relative.</param>
        /// <param name="reason">The reason of deleted resource.</param>
        public ODataDeletedResource(System.Uri id, DeltaDeletedEntryReason reason)
        {
            if (id != null)
            {
                this.Id = id;
            }

            this.Reason = reason;
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new <see cref="ODataDeltaDeletedEntry"/>.
 /// </summary>
 /// <param name="id">The id of the deleted entity, which may be absolute or relative.</param>
 /// <param name="reason">The reason of deleted entry.</param>
 public ODataDeltaDeletedEntry(string id, DeltaDeletedEntryReason reason)
 {
     this.Id     = id;
     this.Reason = reason;
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new <see cref="ODataDeltaDeletedEntry"/>.
 /// </summary>
 /// <param name="id">The id of the deleted entity, which may be absolute or relative.</param>
 /// <param name="reason">The reason of deleted entry.</param>
 public ODataDeltaDeletedEntry(string id, DeltaDeletedEntryReason reason)
 {
     this.Id = id;
     this.Reason = reason;
 }