/// <summary> /// Sets the value of the header with the given name. /// </summary> /// <param name="headerName">Name of the header.</param> /// <param name="headerValue">Value of the header.</param> public override void SetHeader(string headerName, string headerValue) { #if DEBUG // Only content length header is set after firing SendingRequest2 event Debug.Assert(!this.sendingRequest2Fired || headerName == XmlConstants.HttpContentLength, "!this.sendingRequest2Fired || headerName == XmlConstants.HttpContentLength"); #endif Util.CheckArgumentNullAndEmpty(headerName, "headerName"); HttpWebRequestMessage.SetHeaderValue(this.httpRequest, headerName, headerValue); }
/// <summary> /// Initializes a new instance of the <see cref="ConventionalODataEntityMetadataBuilder"/> class. /// </summary> /// <param name="resolver">The URI resolver to use.</param> /// <param name="entitySetName">Name of the entity set the entity belongs to.</param> /// <param name="entityInstance">The entity instance to build metadata for.</param> /// <param name="conventions">The user-specified conventions to use.</param> internal ConventionalODataEntityMetadataBuilder(UriResolver resolver, string entitySetName, IEdmStructuredValue entityInstance, DataServiceUrlConventions conventions) { Util.CheckArgumentNullAndEmpty(entitySetName, "entitySetName"); Util.CheckArgumentNull(entityInstance, "entityInstance"); Util.CheckArgumentNull(conventions, "conventions"); this.entitySetName = entitySetName; this.entityInstance = entityInstance; this.uriBuilder = new ConventionalODataUriBuilder(resolver, conventions); this.baseUri = resolver.BaseUriOrNull; }
public string GetHeader(string headerName) { Util.CheckArgumentNullAndEmpty(headerName, "headerName"); string headerValue = GetHeaderValue(this.httpRequest, headerName); if (((this.sendingRequest2Fired && string.Equals(headerName, "Content-Type", StringComparison.Ordinal)) && (!string.Equals(headerValue, this.originalContentTypeHeaderValue, StringComparison.OrdinalIgnoreCase) && (headerValue != null))) && (headerValue.IndexOf("application/json", StringComparison.OrdinalIgnoreCase) != -1)) { throw new NotSupportedException("'application/json' is currently not supported in Content-Type header"); } return(headerValue); }
/// <summary>Expands a query to include entities from a related entity set in the query response.</summary> /// <returns>A new query that includes the requested $expand query option appended to the URI of the supplied query.</returns> /// <param name="path">The expand path in the format Orders/Order_Details.</param> public DataServiceQuery <TElement> Expand(string path) { Util.CheckArgumentNullAndEmpty(path, "path"); Debug.Assert(DataServiceQuery <TElement> .expandMethodInfo != null, "DataServiceQuery<TElement>.expandMethodInfo != null"); return((DataServiceQuery <TElement>) this.Provider.CreateQuery <TElement>( Expression.Call( Expression.Convert(this.Expression, typeof(DataServiceQuery <TElement> .DataServiceOrderedQuery)), DataServiceQuery <TElement> .expandMethodInfo, new Expression[] { Expression.Constant(path) }))); }
public string GetHeader(string headerName) { string str; Util.CheckArgumentNullAndEmpty(headerName, "headerName"); if (this.headers.TryGetValue(headerName, out str)) { CheckAndFailForJsonContentType(headerName, str); return(str); } return(null); }
/// <summary> /// Returns the LinkInfo for the given navigation property. /// </summary> /// <param name="propertyName">name of the navigation property </param> /// <param name="linkInfo"> LinkInfo for the navigation propery</param> /// <returns>true if LinkInfo is found for the navigation property, false if not found</returns> internal bool TryGetLinkInfo(string propertyName, out LinkInfo linkInfo) { Util.CheckArgumentNullAndEmpty(propertyName, "propertyName"); Debug.Assert(propertyName.IndexOf('/') == -1, "propertyName.IndexOf('/') == -1"); linkInfo = null; if (this.TransientEntityDescriptor != null && this.TransientEntityDescriptor.TryGetLinkInfo(propertyName, out linkInfo)) { return(true); } else if (this.relatedEntityLinks != null) { return(this.relatedEntityLinks.TryGetValue(propertyName, out linkInfo)); } return(false); }
/// <summary> /// Returns the value of the header with the given name. /// </summary> /// <param name="headerName">Name of the header.</param> /// <returns>Returns the value of the header with the given name.</returns> public virtual string GetHeader(string headerName) { Util.CheckArgumentNullAndEmpty(headerName, "headerName"); string result; if (this.headers.TryGetHeader(headerName, out result)) { return(result); } // Since the unintialized value of ContentLength header is -1, we need to return // -1 if the content length header is not present if (string.Equals(headerName, XmlConstants.HttpContentLength, StringComparison.Ordinal)) { return("-1"); } return(null); }
internal bool TryGetLinkInfo(string propertyName, out LinkInfo linkInfo) { Util.CheckArgumentNullAndEmpty(propertyName, "propertyName"); linkInfo = null; return(((this.TransientEntityDescriptor != null) && this.TransientEntityDescriptor.TryGetLinkInfo(propertyName, out linkInfo)) || ((this.relatedEntityLinks != null) && this.relatedEntityLinks.TryGetValue(propertyName, out linkInfo))); }
public void SetHeader(string headerName, string headerValue) { Util.CheckArgumentNullAndEmpty(headerName, "headerName"); SetHeaderValue(this.httpRequest, headerName, headerValue); }
/// <summary> /// Returns the value of the header with the given name. /// </summary> /// <param name="headerName">Name of the header.</param> /// <returns>Returns the value of the header with the given name.</returns> public override string GetHeader(string headerName) { Util.CheckArgumentNullAndEmpty(headerName, "headerName"); return(HttpWebRequestMessage.GetHeaderValue(this.httpRequest, headerName)); }
public DataServiceQuery <TElement> Expand(string path) { Util.CheckArgumentNullAndEmpty(path, "path"); return((DataServiceQuery <TElement>) this.Provider.CreateQuery <TElement>(System.Linq.Expressions.Expression.Call(System.Linq.Expressions.Expression.Convert(this.Expression, typeof(DataServiceOrderedQuery)), DataServiceQuery <TElement> .expandMethodInfo, new System.Linq.Expressions.Expression[] { System.Linq.Expressions.Expression.Constant(path) }))); }