Ejemplo n.º 1
0
        protected string GetHttpMethod(EntityStates state, ref Version requestVersion)
        {
            EntityStates states = state;

            if (states == EntityStates.Added)
            {
                return("POST");
            }
            if (states != EntityStates.Deleted)
            {
                if (states != EntityStates.Modified)
                {
                    throw System.Data.Services.Client.Error.InternalError(InternalError.UnvalidatedEntityState);
                }
            }
            else
            {
                return("DELETE");
            }
            if (Util.IsFlagSet(this.Options, SaveChangesOptions.ReplaceOnUpdate))
            {
                return("PUT");
            }
            if (Util.IsFlagSet(this.Options, SaveChangesOptions.PatchOnUpdate))
            {
                WebUtil.RaiseVersion(ref requestVersion, Util.DataServiceVersion3);
                return("PATCH");
            }
            return("MERGE");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// checks whether the batch flag with independent Operation per change set is set
        /// </summary>
        /// <param name="options">options as specified by the user.</param>
        /// <returns>true if the given flag is set, otherwise false.</returns>
        internal static bool IsBatchWithIndependentOperations(SaveChangesOptions options)
        {
            if (Util.IsFlagSet(options, SaveChangesOptions.BatchWithIndependentOperations))
            {
                Debug.Assert(!Util.IsFlagSet(options, SaveChangesOptions.Batch), "!Util.IsFlagSet(options, SaveChangesOptions.Batch)");
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
 private void CheckContinueOnError()
 {
     if (!Util.IsFlagSet(base.Options, SaveChangesOptions.ContinueOnError))
     {
         base.SetCompleted();
     }
     else
     {
         base.streamRequestKind = BaseSaveResult.StreamRequestKind.None;
         base.ChangedEntries[base.entryIndex].ContentGeneratedForSave = true;
     }
 }
Ejemplo n.º 4
0
        protected void HandleOperationResponseHeaders(HttpStatusCode statusCode, Dictionary <string, string> headers)
        {
            Descriptor descriptor = this.ChangedEntries[this.entryIndex];

            if (descriptor.DescriptorKind == DescriptorKind.Entity)
            {
                EntityDescriptor descriptor2 = (EntityDescriptor)descriptor;
                if ((((descriptor.State == EntityStates.Added) || (this.streamRequestKind == StreamRequestKind.PostMediaResource)) || Util.IsFlagSet(this.Options, SaveChangesOptions.PatchOnUpdate)) && WebUtil.SuccessStatusCode(statusCode))
                {
                    string str;
                    string str2;
                    Uri    editLink = null;
                    headers.TryGetValue("Location", out str);
                    headers.TryGetValue("DataServiceId", out str2);
                    if (str != null)
                    {
                        editLink = WebUtil.ValidateLocationHeader(str);
                    }
                    else if ((descriptor.State == EntityStates.Added) || (this.streamRequestKind == StreamRequestKind.PostMediaResource))
                    {
                        throw System.Data.Services.Client.Error.NotSupported(System.Data.Services.Client.Strings.Deserialize_NoLocationHeader);
                    }
                    if (str2 != null)
                    {
                        if (str == null)
                        {
                            throw System.Data.Services.Client.Error.NotSupported(System.Data.Services.Client.Strings.Context_BothLocationAndIdMustBeSpecified);
                        }
                        WebUtil.ValidateIdentityValue(str2);
                    }
                    else
                    {
                        str2 = str;
                    }
                    if (null != editLink)
                    {
                        this.RequestInfo.EntityTracker.AttachLocation(descriptor2.Entity, str2, editLink);
                    }
                }
                if (this.streamRequestKind != StreamRequestKind.None)
                {
                    if (!WebUtil.SuccessStatusCode(statusCode))
                    {
                        if (this.streamRequestKind == StreamRequestKind.PostMediaResource)
                        {
                            descriptor.State = EntityStates.Added;
                        }
                        this.streamRequestKind             = StreamRequestKind.None;
                        descriptor.ContentGeneratedForSave = true;
                    }
                    else
                    {
                        string str3;
                        if ((this.streamRequestKind == StreamRequestKind.PostMediaResource) && headers.TryGetValue("ETag", out str3))
                        {
                            descriptor2.ETag = str3;
                        }
                    }
                }
            }
        }