/// <summary> /// Instantiates a new Serializer class and calls WriteEntry method on it. /// </summary> /// <param name="dataServiceContext"></param> /// <returns></returns> private static Person SetupSerializerAndCallWriteEntry(DataServiceContext dataServiceContext) { Person person = new Person(); Address address = new Address(); Car car1 = new Car(); person.Cars.Add(car1); person.HomeAddress = address; dataServiceContext.AttachTo("Cars", car1); dataServiceContext.AttachTo("Addresses", address); var requestInfo = new RequestInfo(dataServiceContext); var serializer = new Serializer(requestInfo); var headers = new HeaderCollection(); var clientModel = new ClientEdmModel(ODataProtocolVersion.V4); var entityDescriptor = new EntityDescriptor(clientModel); entityDescriptor.State = EntityStates.Added; entityDescriptor.Entity = person; var requestMessageArgs = new BuildingRequestEventArgs("POST", new Uri("http://www.foo.com/Northwind"), headers, entityDescriptor, HttpStack.Auto); var linkDescriptors = new LinkDescriptor[] { new LinkDescriptor(person, "Cars", car1, clientModel), new LinkDescriptor(person, "HomeAddress", address, clientModel) }; var odataRequestMessageWrapper = ODataRequestMessageWrapper.CreateRequestMessageWrapper(requestMessageArgs, requestInfo); serializer.WriteEntry(entityDescriptor, linkDescriptors, odataRequestMessageWrapper); return person; }
/// <summary> /// Creates a new instance of ODataRequestMessage. This constructor is used for top level requests. /// </summary> /// <param name="requestMessage">RequestMessage that needs to be wrapped.</param> /// <param name="requestInfo">Request Info.</param> /// <param name="descriptor">Descriptor for this request.</param> protected ODataRequestMessageWrapper(DataServiceClientRequestMessage requestMessage, RequestInfo requestInfo, Descriptor descriptor) { Debug.Assert(requestMessage != null, "requestMessage != null"); Debug.Assert(requestInfo != null, "requestInfo != null"); this.requestMessage = requestMessage; this.requestInfo = requestInfo; this.Descriptor = descriptor; }
public void Init() { this.context = new DataServiceContext(new Uri("http://temp.org/"), ODataProtocolVersion.V4); this.requestInfo = new RequestInfo(context); this.writingHelper = new ODataMessageWritingHelper(this.requestInfo); this.atomRequestMessage = new ODataRequestMessageSimulator(); this.atomRequestMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/AtOm"); this.jsonRequestMessage = new ODataRequestMessageSimulator(); this.jsonRequestMessage.SetHeader(XmlConstants.HttpContentType, "ApplIcAtIOn/jsOn"); }
/// <summary> /// Constructs a new async result object /// </summary> /// <param name="context">The source of the operation.</param> /// <param name="method">Name of the method which is invoked asynchronously.</param> /// <param name="request">The <see cref="HttpWebRequest"/> object which is wrapped by this async result.</param> /// <param name="callback">User specified callback for the async operation.</param> /// <param name="state">User state for the async callback.</param> /// <param name="streamDescriptor">stream descriptor whose value is getting queried.</param> internal GetReadStreamResult( DataServiceContext context, string method, ODataRequestMessageWrapper request, AsyncCallback callback, object state, StreamDescriptor streamDescriptor) : base(context, method, callback, state) { Debug.Assert(request != null, "Null request can't be wrapped to a result."); Debug.Assert(streamDescriptor != null, "streamDescriptor != null"); this.requestMessage = request; this.Abortable = request; this.streamDescriptor = streamDescriptor; this.requestInfo = new RequestInfo(context); }
internal BaseSaveResult(DataServiceContext context, string method, DataServiceRequest[] queries, SaveChangesOptions options, AsyncCallback callback, object state) : base(context, method, callback, state) { this.RequestInfo = new RequestInfo(context); this.Options = options; this.SerializerInstance = new Serializer(this.RequestInfo, options); if (null == queries) { #region changed entries this.ChangedEntries = context.EntityTracker.Entities.Cast<Descriptor>() .Union(context.EntityTracker.Links.Cast<Descriptor>()) .Union(context.EntityTracker.Entities.SelectMany(e => e.StreamDescriptors).Cast<Descriptor>()) .Where(o => o.IsModified && o.ChangeOrder != UInt32.MaxValue) .OrderBy(o => o.ChangeOrder) .ToList(); foreach (Descriptor e in this.ChangedEntries) { e.ContentGeneratedForSave = false; e.SaveResultWasProcessed = 0; e.SaveError = null; if (e.DescriptorKind == DescriptorKind.Link) { object target = ((LinkDescriptor)e).Target; if (null != target) { Descriptor f = context.EntityTracker.GetEntityDescriptor(target); if (EntityStates.Unchanged == f.State) { f.ContentGeneratedForSave = false; f.SaveResultWasProcessed = 0; f.SaveError = null; } } } } #endregion } else { this.ChangedEntries = new List<Descriptor>(); } }
public void Init() { this.clientEdmModel = new ClientEdmModel(ODataProtocolVersion.V4); this.entityDescriptor = new EntityDescriptor(this.clientEdmModel) { Entity = new Customer() }; var serverType = new EdmEntityType("FQ.NS", "MyServerType"); serverType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Navigation", Target = serverType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }); this.serverTypeName = ((IEdmSchemaElement)serverType).FullName(); var serverContainer = new EdmEntityContainer("FQ.NS", "MyContainer"); this.serverEntitySet = serverContainer.AddEntitySet("MyEntitySet", serverType); var serverModel = new EdmModel(); serverModel.AddElement(serverType); serverModel.AddElement(serverContainer); this.ctx = new DataServiceContext(new Uri("http://temp.org/"), ODataProtocolVersion.V4, this.clientEdmModel); this.ctx.Format.UseJson(serverModel); this.testSubject = new RequestInfo(ctx); }
/// <summary> /// Gets the string of keys used in URI. /// </summary> /// <param name="context">Wrapping context instance.</param> /// <param name="keys">The dictionary containing key pairs.</param> /// <returns>The string of keys.</returns> public static string GetKeyString(DataServiceContext context, Dictionary<string, object> keys) { var requestInfo = new RequestInfo(context); var serializer = new Serializer(requestInfo); if (keys.Count == 1) { return serializer.ConvertToEscapedUriValue(keys.First().Key, keys.First().Value); } else { StringBuilder stringBuilder = new StringBuilder(); foreach (var keyPair in keys) { stringBuilder.Append(keyPair.Key); stringBuilder.Append(UriHelper.EQUALSSIGN); stringBuilder.Append(serializer.ConvertToEscapedUriValue(keyPair.Key, keyPair.Value)); stringBuilder.Append(UriHelper.COMMA); } stringBuilder.Remove(stringBuilder.Length - 1, 1); return stringBuilder.ToString(); } }
private void MaterializeTest(HttpStatusCode statusCode, ODataPayloadKind payloadKind) { var uri = new Uri("http://any"); var context = new DataServiceContext(); var requestInfo = new RequestInfo(context); var responseInfo = new ResponseInfo(requestInfo, MergeOption.OverwriteChanges); var queryComponents = new QueryComponents(uri, new Version(4, 0), typeof(Product), null, null); var responseMessage = new HttpWebResponseMessage( new HeaderCollection(), (int)statusCode, () => new MemoryStream()); var materialize = DataServiceRequest.Materialize( responseInfo, queryComponents, null, "application/json", responseMessage, payloadKind); Assert.IsNull(materialize.Context); Assert.IsNull(materialize.Current); var enumerable = materialize.Cast<object>(); Assert.AreEqual(0, enumerable.Count()); }
public void SerializeEnity_NullableEnumProperty() { MyEntity1 myEntity1 = new MyEntity1() { ID = 2, MyColorValue = null, MyFlagsColorValue = MyFlagsColor.Blue, ComplexValue1Value = new ComplexValue1() { MyColorValue = MyColor.Green, MyFlagsColorValue = MyFlagsColor.Red }, MyFlagsColorCollection1 = new List<MyFlagsColor>() { MyFlagsColor.Blue, MyFlagsColor.Red, MyFlagsColor.Red }, MyColorCollection = new List<MyColor?> { MyColor.Green, null } }; DataServiceContext dataServiceContext = new DataServiceContext(new Uri("http://www.odata.org/service.svc")); dataServiceContext.EnableAtom = true; dataServiceContext.Format.UseAtom(); dataServiceContext.AttachTo("MyEntitySet1", myEntity1); var requestInfo = new RequestInfo(dataServiceContext); var serializer = new Serializer(requestInfo); var headers = new HeaderCollection(); var clientModel = new ClientEdmModel(ODataProtocolVersion.V4); var entityDescriptor = new EntityDescriptor(clientModel); entityDescriptor.State = EntityStates.Added; entityDescriptor.Entity = myEntity1; var requestMessageArgs = new BuildingRequestEventArgs("POST", new Uri("http://www.foo.com/Northwind"), headers, entityDescriptor, HttpStack.Auto); var linkDescriptors = new LinkDescriptor[] { }; var odataRequestMessageWrapper = ODataRequestMessageWrapper.CreateRequestMessageWrapper(requestMessageArgs, requestInfo); serializer.WriteEntry(entityDescriptor, linkDescriptors, odataRequestMessageWrapper); // read result: MemoryStream stream = (MemoryStream)(odataRequestMessageWrapper.CachedRequestStream.Stream); stream.Position = 0; string payload = (new StreamReader(stream)).ReadToEnd(); payload = Regex.Replace(payload, "<updated>[^<]*</updated>", ""); payload.Should().Be( "{\"ComplexValue1Value\":{\"MyColorValue\":\"Green\",\"MyFlagsColorValue\":\"Red\",\"StringValue\":null},\"ID\":2,\"MyColorCollection\":[\"Green\",null],\"MyColorValue\":null,\"MyFlagsColorCollection1\":[\"Blue\",\"Red\",\"Red\"],\"MyFlagsColorValue\":\"Blue\"}"); }
/// <summary> /// Creates a new instance of InnerBatchRequestMessageWrapper; /// </summary> /// <param name="clientRequestMessage">Instance of DataServiceClientRequestMessage that represents this request.</param> /// <param name="odataRequestMessage">Instance of IODataRequestMessage created by ODataLib.</param> /// <param name="requestInfo">RequestInfo instance.</param> /// <param name="descriptor">Descriptor for this request.</param> internal InnerBatchRequestMessageWrapper(DataServiceClientRequestMessage clientRequestMessage, IODataRequestMessage odataRequestMessage, RequestInfo requestInfo, Descriptor descriptor) : base(clientRequestMessage, requestInfo, descriptor) { this.innerBatchRequestMessage = odataRequestMessage; }
/// <summary> /// Creates a new instance of ODataOuterRequestMessage. /// </summary> /// <param name="requestMessage">DataServiceClientRequestMessage instance.</param> /// <param name="requestInfo">RequestInfo instance.</param> /// <param name="descriptor">Descriptor for this request.</param> internal TopLevelRequestMessageWrapper(DataServiceClientRequestMessage requestMessage, RequestInfo requestInfo, Descriptor descriptor) : base(requestMessage, requestInfo, descriptor) { // Wrapper for the top-level request messages which caches the request stream as it is written. In order to keep the sync and non-async // code the same, we write all requests into an cached stream and then copy it to the underlying network stream in sync or async manner. this.messageWithCachedStream = new RequestMessageWithCachedStream(this.requestMessage); }
/// <summary> /// Initializes a new instance of the <see cref="ODataPropertyConverter"/> class. /// </summary> /// <param name="requestInfo">The request info.</param> internal ODataPropertyConverter(RequestInfo requestInfo) { Debug.Assert(requestInfo != null, "requestInfo != null"); this.requestInfo = requestInfo; }
/// <summary> /// Creates a new instance of the Serializer. /// </summary> /// <param name="requestInfo">the request info.</param> /// <param name="sendOption">The option to send entity operation parameters.</param> internal Serializer(RequestInfo requestInfo, EntityParameterSendOption sendOption) : this(requestInfo) { this.sendOption = sendOption; }
/// <summary> /// Creates a new instance of the Serializer. /// </summary> /// <param name="requestInfo">the request info.</param> internal Serializer(RequestInfo requestInfo) { Debug.Assert(requestInfo != null, "requestInfo != null"); this.requestInfo = requestInfo; this.propertyConverter = new ODataPropertyConverter(this.requestInfo); }
/// <summary> /// Seriliaze the parameter value to string. /// </summary> /// <param name="context">The context.</param> /// <param name="parameter">The parameter.</param> /// <returns>Parameter value string.</returns> internal static string GetParameterValue(DataServiceContext context, OperationParameter parameter) { var requestInfo = new RequestInfo(context); var serializer = new Serializer(requestInfo); UriEntityOperationParameter entityParameter = parameter as UriEntityOperationParameter; return serializer.ConvertToEscapedUriValue(parameter.Name, parameter.Value, entityParameter != null && entityParameter.UseEntityReference); }
/// <summary> /// Creates a new instance of the Serializer. /// </summary> /// <param name="requestInfo">the request info.</param> /// <param name="options">the save change options.</param> internal Serializer(RequestInfo requestInfo, SaveChangesOptions options) : this(requestInfo) { this.options = options; }
/// <summary> /// Creates an instance of ODataMessageWriter. /// </summary> /// <param name="requestMessage">Instance of IODataRequestMessage.</param> /// <param name="requestInfo">RequestInfo containing information about the client settings.</param> /// <param name="isParameterPayload">true if the writer is intended to for a parameter payload, false otherwise.</param> /// <returns>An instance of ODataMessageWriter.</returns> internal static ODataMessageWriter CreateMessageWriter(ODataRequestMessageWrapper requestMessage, RequestInfo requestInfo, bool isParameterPayload) { var writerSettings = requestInfo.WriteHelper.CreateSettings(requestMessage.IsBatchPartRequest, requestInfo.Context.EnableWritingODataAnnotationWithoutPrefix); return(requestMessage.CreateWriter(writerSettings, isParameterPayload)); }
/// <summary> /// Handle response by looking at status and possibly throwing an exception. /// </summary> /// <param name="requestInfo">The request info.</param> /// <param name="statusCode">response status code</param> /// <param name="responseVersion">Version string on the response header; possibly null.</param> /// <param name="getResponseStream">delegate to get response stream</param> /// <param name="throwOnFailure">throw or return on failure</param> /// <param name="parsedResponseVersion">Parsed response version (null if no version was specified).</param> /// <returns>exception on failure</returns> internal static InvalidOperationException HandleResponse( RequestInfo requestInfo, HttpStatusCode statusCode, string responseVersion, Func<Stream> getResponseStream, bool throwOnFailure, out Version parsedResponseVersion) { InvalidOperationException failure = null; if (!CanHandleResponseVersion(responseVersion, out parsedResponseVersion)) { string description = Strings.Context_VersionNotSupported(responseVersion, SerializeSupportedVersions()); failure = Error.InvalidOperation(description); } if (failure == null) { failure = requestInfo.ValidateResponseVersion(parsedResponseVersion); } if (failure == null && !WebUtil.SuccessStatusCode(statusCode)) { failure = GetResponseText(getResponseStream, statusCode); } if (failure != null && throwOnFailure) { throw failure; } return failure; }
/// <summary> /// Creates a new instance of the ResponseInfo class which exposes all the information from /// the context required for processing the response from the server. /// </summary> /// <param name="requestInfo">The request info</param> /// <param name="mergeOption">mergeOption</param> internal ResponseInfo(RequestInfo requestInfo, MergeOption mergeOption) { this.requestInfo = requestInfo; this.mergeOption = mergeOption; this.ReadHelper = new ODataMessageReadingHelper(this); }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="requestInfo">Information about the request.</param> /// <param name="mergeOption">Merge option.</param> /// <param name="entityDescriptor">Entity whose property is being loaded.</param> /// <param name="property">Property which is being loaded.</param> internal LoadPropertyResponseInfo( RequestInfo requestInfo, MergeOption mergeOption, EntityDescriptor entityDescriptor, ClientPropertyAnnotation property) : base(requestInfo, mergeOption) { this.EntityDescriptor = entityDescriptor; this.Property = property; }
public void SerializeEnity_EnumProperty() { MyEntity1 myEntity1 = new MyEntity1() { ID = 2, MyColorValue = MyColor.Yellow, MyFlagsColorValue = MyFlagsColor.Blue, ComplexValue1Value = new ComplexValue1() { MyColorValue = MyColor.Green, MyFlagsColorValue = MyFlagsColor.Red }, MyFlagsColorCollection1 = new List<MyFlagsColor>() { MyFlagsColor.Blue, MyFlagsColor.Red, MyFlagsColor.Red }, MyColorCollection = new List<MyColor?>() }; DataServiceContext dataServiceContext = new DataServiceContext(new Uri("http://www.odata.org/service.svc")); dataServiceContext.EnableAtom = true; dataServiceContext.Format.UseAtom(); dataServiceContext.AttachTo("MyEntitySet1", myEntity1); var requestInfo = new RequestInfo(dataServiceContext); var serializer = new Serializer(requestInfo); var headers = new HeaderCollection(); headers.SetHeader("Content-Type", "application/atom+xml;odata.metadata=minimal"); var clientModel = new ClientEdmModel(ODataProtocolVersion.V4); var entityDescriptor = new EntityDescriptor(clientModel); entityDescriptor.State = EntityStates.Added; entityDescriptor.Entity = myEntity1; var requestMessageArgs = new BuildingRequestEventArgs("POST", new Uri("http://www.foo.com/Northwind"), headers, entityDescriptor, HttpStack.Auto); var linkDescriptors = new LinkDescriptor[] { }; var odataRequestMessageWrapper = ODataRequestMessageWrapper.CreateRequestMessageWrapper(requestMessageArgs, requestInfo); serializer.WriteEntry(entityDescriptor, linkDescriptors, odataRequestMessageWrapper); // read result: MemoryStream stream = (MemoryStream)(odataRequestMessageWrapper.CachedRequestStream.Stream); stream.Position = 0; string payload = (new StreamReader(stream)).ReadToEnd(); payload = Regex.Replace(payload, "<updated>[^<]*</updated>", ""); payload.Should().Be( "<?xml version=\"1.0\" encoding=\"utf-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\" " + "xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" " + "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\">" + "<id />" + "<title />" + //"<updated>2013-11-11T19:29:54Z</updated>" + "<author><name /></author>" + "<content type=\"application/xml\">" + "<m:properties>" + "<d:ComplexValue1Value>" + "<d:MyColorValue m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests_MyColor\">Green</d:MyColorValue>" + "<d:MyFlagsColorValue m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests_MyFlagsColor\">Red</d:MyFlagsColorValue>" + "<d:StringValue m:null=\"true\" />" + "</d:ComplexValue1Value>" + "<d:ID m:type=\"Int64\">2</d:ID>" + "<d:MyColorCollection />" + "<d:MyColorValue m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests_MyColor\">Yellow</d:MyColorValue>" + "<d:MyFlagsColorCollection1>" + "<m:element m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests+MyFlagsColor\">Blue</m:element>" + "<m:element m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests+MyFlagsColor\">Red</m:element>" + "<m:element m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests+MyFlagsColor\">Red</m:element>" + "</d:MyFlagsColorCollection1>" + "<d:MyFlagsColorValue m:type=\"#AstoriaUnitTests.TDD.Tests.Client.ODataWriterWrapperUnitTests_MyFlagsColor\">Blue</d:MyFlagsColorValue>" + "</m:properties>" + "</content>" + "</entry>"); }
public void SerializeEnity_TwoNavigationLinksInJsonFormat() { var person = new Person { ID = 100, Name = "Bing", }; var car1 = new Car { ID = 1001 }; var car2 = new Car { ID = 1002 }; DataServiceContext dataServiceContext = new DataServiceContext(new Uri("http://www.odata.org/service.svc")); dataServiceContext.AttachTo("Persons", person); dataServiceContext.AttachTo("Cars", car1); dataServiceContext.AttachTo("Cars", car2); dataServiceContext.AddLink(person, "Cars", car1); dataServiceContext.AddLink(person, "Cars", car2); var requestInfo = new RequestInfo(dataServiceContext); var serializer = new Serializer(requestInfo); var headers = new HeaderCollection(); var clientModel = new ClientEdmModel(ODataProtocolVersion.V4); var entityDescriptor = new EntityDescriptor(clientModel); entityDescriptor.State = EntityStates.Added; entityDescriptor.Entity = person; entityDescriptor.EditLink = new Uri("http://www.foo.com/custom"); var requestMessageArgs = new BuildingRequestEventArgs("POST", new Uri("http://www.foo.com/Northwind"), headers, entityDescriptor, HttpStack.Auto); var linkDescriptors = new LinkDescriptor[] { new LinkDescriptor(person, "Cars", car1, clientModel), new LinkDescriptor(person, "Cars", car2, clientModel)}; var odataRequestMessageWrapper = ODataRequestMessageWrapper.CreateRequestMessageWrapper(requestMessageArgs, requestInfo); serializer.WriteEntry(entityDescriptor, linkDescriptors, odataRequestMessageWrapper); // read result: MemoryStream stream = (MemoryStream)(odataRequestMessageWrapper.CachedRequestStream.Stream); stream.Position = 0; string payload = (new StreamReader(stream)).ReadToEnd(); payload.Should().Be( "{\"ID\":100,\"Name\":\"Bing\",\"[email protected]\":[\"http://www.odata.org/service.svc/Cars(1001)\",\"http://www.odata.org/service.svc/Cars(1002)\"]}"); }
/// <summary> /// Gets the string of parameters used in URI. /// </summary> /// <param name="context">Wrapping context instance.</param> /// <param name="parameters">Parameters of function.</param> /// <returns>The string of parameters.</returns> public static string GetParameterString(DataServiceContext context, params OperationParameter[] parameters) { var requestInfo = new RequestInfo(context); var serializer = new Serializer(requestInfo); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(UriHelper.LEFTPAREN); foreach (var key in parameters) { stringBuilder.Append(key.Name); stringBuilder.Append(UriHelper.EQUALSSIGN); stringBuilder.Append(serializer.ConvertToEscapedUriValue(key.Name, key.Value)); stringBuilder.Append(UriHelper.COMMA); } if (parameters.Any()) { stringBuilder.Remove(stringBuilder.Length - 1, 1); } stringBuilder.Append(UriHelper.RIGHTPAREN); return stringBuilder.ToString(); }
/// <summary> /// Create a request message for a batch part from the batch writer. This method copies request headers /// from <paramref name="requestMessageArgs"/> in addition to the method and Uri. /// </summary> /// <param name="batchWriter">ODataBatchWriter instance to build operation message from.</param> /// <param name="requestMessageArgs">RequestMessageArgs for the request.</param> /// <param name="requestInfo">RequestInfo instance.</param> /// <param name="contentId">The Content-ID value to write in ChangeSet head.</param> /// <returns>an instance of ODataRequestMessageWrapper.</returns> internal static ODataRequestMessageWrapper CreateBatchPartRequestMessage( ODataBatchWriter batchWriter, BuildingRequestEventArgs requestMessageArgs, RequestInfo requestInfo, string contentId) { IODataRequestMessage requestMessage = batchWriter.CreateOperationRequestMessage(requestMessageArgs.Method, requestMessageArgs.RequestUri, contentId); foreach (var h in requestMessageArgs.Headers) { requestMessage.SetHeader(h.Key, h.Value); } var clientRequestMessage = new InternalODataRequestMessage(requestMessage, false /*allowGetStream*/); ODataRequestMessageWrapper messageWrapper = new InnerBatchRequestMessageWrapper(clientRequestMessage, requestMessage, requestInfo, requestMessageArgs.Descriptor); return messageWrapper; }
/// <summary> /// Creates an instance of ODataMessageWriter. /// </summary> /// <param name="requestMessage">Instance of IODataRequestMessage.</param> /// <param name="requestInfo">RequestInfo containing information about the client settings.</param> /// <param name="isParameterPayload">true if the writer is intended to for a parameter payload, false otherwise.</param> /// <returns>An instance of ODataMessageWriter.</returns> internal static ODataMessageWriter CreateMessageWriter(ODataRequestMessageWrapper requestMessage, RequestInfo requestInfo, bool isParameterPayload) { var writerSettings = requestInfo.WriteHelper.CreateSettings(requestMessage.IsBatchPartRequest, requestInfo.Context.EnableAtom, requestInfo.Context.ODataSimplified); return requestMessage.CreateWriter(writerSettings, isParameterPayload); }
/// <summary> /// Create a request message for a non-batch requests and outer $batch request. This method copies request headers /// from <paramref name="requestMessageArgs"/> in addition to the method and Uri. /// </summary> /// <param name="requestMessageArgs">RequestMessageArgs for the request.</param> /// <param name="requestInfo">RequestInfo instance.</param> /// <returns>an instance of ODataRequestMessageWrapper.</returns> internal static ODataRequestMessageWrapper CreateRequestMessageWrapper(BuildingRequestEventArgs requestMessageArgs, RequestInfo requestInfo) { Debug.Assert(requestMessageArgs != null, "requestMessageArgs != null"); var requestMessage = requestInfo.CreateRequestMessage(requestMessageArgs); if (null != requestInfo.Credentials) { requestMessage.Credentials = requestInfo.Credentials; } #if !PORTABLELIB // Timeout not available if (0 != requestInfo.Timeout) { requestMessage.Timeout = requestInfo.Timeout; } #endif return new TopLevelRequestMessageWrapper(requestMessage, requestInfo, requestMessageArgs.Descriptor); }
/// <summary> /// Creates a new instance of the Serializer. /// </summary> /// <param name="requestInfo">the request info.</param> /// <param name="sendOption">The option to send entity operation parameters.</param> internal Serializer(RequestInfo requestInfo, EntityParameterSendOption sendOption) : this(requestInfo) { this.sendOption = sendOption; }
/// <summary> /// Creates a new instance of the Serializer. /// </summary> /// <param name="requestInfo">the request info.</param> internal Serializer(RequestInfo requestInfo) { Debug.Assert(requestInfo != null, "requestInfo != null"); this.requestInfo = requestInfo; this.propertyConverter = new ODataPropertyConverter(this.requestInfo); }
/// <summary> /// Initializes a new instance of the <see cref="ODataMessageWritingHelper"/> class. /// </summary> /// <param name="requestInfo">The request info.</param> internal ODataMessageWritingHelper(RequestInfo requestInfo) { Debug.Assert(requestInfo != null, "requestInfo != null"); this.requestInfo = requestInfo; }
/// <summary> /// Create a request message for a non-batch requests and outer $batch request. This method copies request headers /// from <paramref name="requestMessageArgs"/> in addition to the method and Uri. /// </summary> /// <param name="requestMessageArgs">RequestMessageArgs for the request.</param> /// <param name="requestInfo">RequestInfo instance.</param> /// <returns>an instance of ODataRequestMessageWrapper.</returns> internal static ODataRequestMessageWrapper CreateRequestMessageWrapper(BuildingRequestEventArgs requestMessageArgs, RequestInfo requestInfo) { Debug.Assert(requestMessageArgs != null, "requestMessageArgs != null"); var requestMessage = requestInfo.CreateRequestMessage(requestMessageArgs); if (requestInfo.Credentials != null) { requestMessage.Credentials = requestInfo.Credentials; } if (requestInfo.Timeout != 0) { requestMessage.Timeout = requestInfo.Timeout; } if (requestInfo.ReadWriteTimeout != 0) { requestMessage.ReadWriteTimeout = requestInfo.ReadWriteTimeout; } return(new TopLevelRequestMessageWrapper(requestMessage, requestInfo, requestMessageArgs.Descriptor)); }