Skip to content

Commit 35e4013

Browse files
committed
Merge pull request #573 from davidgrupp/master
Added clearer comments for RestRequest.AddBody and additional RestRequest.AddJsonBody and RestRequest.AddXmlBody
2 parents ea0b33a + ab19b14 commit 35e4013

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

RestSharp.Tests/NamespacedXmlTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Licensed
1+
#region Licensed
22
// Copyright 2010 John Sheehan
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");

RestSharp.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
44
VisualStudioVersion = 12.0.30723.0

RestSharp/IRestRequest.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ public interface IRestRequest
160160
#endif
161161

162162
/// <summary>
163-
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer
163+
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer.
164+
/// The default format is XML. Change RequestFormat if you wish to use a different serialization format.
164165
/// </summary>
165166
/// <param name="obj">The object to serialize</param>
166167
/// <param name="xmlNamespace">The XML namespace to use when serializing</param>
@@ -169,11 +170,35 @@ public interface IRestRequest
169170

170171
/// <summary>
171172
/// Serializes obj to data format specified by RequestFormat and adds it to the request body.
173+
/// The default format is XML. Change RequestFormat if you wish to use a different serialization format.
172174
/// </summary>
173175
/// <param name="obj">The object to serialize</param>
174176
/// <returns>This request</returns>
175177
IRestRequest AddBody (object obj);
176178

179+
/// <summary>
180+
/// Serializes obj to JSON format and adds it to the request body.
181+
/// </summary>
182+
/// <param name="obj">The object to serialize</param>
183+
/// <returns>This request</returns>
184+
IRestRequest AddJsonBody(object obj);
185+
186+
/// <summary>
187+
/// Serializes obj to XML format and adds it to the request body.
188+
/// </summary>
189+
/// <param name="obj">The object to serialize</param>
190+
/// <returns>This request</returns>
191+
IRestRequest AddXmlBody(object obj);
192+
193+
/// <summary>
194+
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer
195+
/// Serializes obj to XML format and passes xmlNamespace then adds it to the request body.
196+
/// </summary>
197+
/// <param name="obj">The object to serialize</param>
198+
/// <param name="xmlNamespace">The XML namespace to use when serializing</param>
199+
/// <returns>This request</returns>
200+
IRestRequest AddXmlBody(object obj, string xmlNamespace);
201+
177202
/// <summary>
178203
/// Calls AddParameter() for all public, readable properties specified in the includedProperties list
179204
/// </summary>

RestSharp/RestRequest.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ private IRestRequest AddFile (FileParameter file)
207207
}
208208

209209
/// <summary>
210-
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer
210+
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer.
211+
/// The default format is XML. Change RequestFormat if you wish to use a different serialization format.
211212
/// </summary>
212213
/// <param name="obj">The object to serialize</param>
213214
/// <param name="xmlNamespace">The XML namespace to use when serializing</param>
@@ -244,6 +245,7 @@ public IRestRequest AddBody (object obj, string xmlNamespace)
244245

245246
/// <summary>
246247
/// Serializes obj to data format specified by RequestFormat and adds it to the request body.
248+
/// The default format is XML. Change RequestFormat if you wish to use a different serialization format.
247249
/// </summary>
248250
/// <param name="obj">The object to serialize</param>
249251
/// <returns>This request</returns>
@@ -252,6 +254,42 @@ public IRestRequest AddBody (object obj)
252254
return AddBody(obj, "");
253255
}
254256

257+
/// <summary>
258+
/// Serializes obj to JSON format and adds it to the request body.
259+
/// </summary>
260+
/// <param name="obj">The object to serialize</param>
261+
/// <returns>This request</returns>
262+
public IRestRequest AddJsonBody(object obj)
263+
{
264+
RequestFormat = DataFormat.Json;
265+
return AddBody(obj, "");
266+
}
267+
268+
/// <summary>
269+
/// Serializes obj to XML format and adds it to the request body.
270+
/// </summary>
271+
/// <param name="obj">The object to serialize</param>
272+
/// <returns>This request</returns>
273+
public IRestRequest AddXmlBody(object obj)
274+
{
275+
RequestFormat = DataFormat.Xml;
276+
return AddBody(obj, "");
277+
}
278+
279+
/// <summary>
280+
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer
281+
/// Serializes obj to XML format and passes xmlNamespace then adds it to the request body.
282+
/// </summary>
283+
/// <param name="obj">The object to serialize</param>
284+
/// <param name="xmlNamespace">The XML namespace to use when serializing</param>
285+
/// <returns>This request</returns>
286+
public IRestRequest AddXmlBody(object obj, string xmlNamespace)
287+
{
288+
RequestFormat = DataFormat.Xml;
289+
return AddBody(obj, xmlNamespace);
290+
}
291+
292+
255293
/// <summary>
256294
/// Calls AddParameter() for all public, readable properties specified in the includedProperties list
257295
/// </summary>

0 commit comments

Comments
 (0)