Skip to content

Commit 07a6dc6

Browse files
committed
1 parent 837eafd commit 07a6dc6

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

RestSharp/RestRequest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public RestRequest(string resource, Method method) : this(resource, method, Data
7070
{
7171
}
7272

73+
public RestRequest(string resource, DataFormat dataFormat) : this(resource, Method.GET, dataFormat)
74+
{
75+
}
76+
7377
public RestRequest(string resource) : this(resource, Method.GET, DataFormat.Xml)
7478
{
7579
}
@@ -341,7 +345,6 @@ public IRestRequest AddJsonBody(object obj)
341345
public IRestRequest AddXmlBody(object obj) => AddXmlBody(obj, "");
342346

343347
/// <summary>
344-
/// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer
345348
/// Serializes obj to XML format and passes xmlNamespace then adds it to the request body.
346349
/// </summary>
347350
/// <param name="obj">The object to serialize</param>
@@ -654,6 +657,7 @@ public IRestRequest AddDecompressionMethod(DecompressionMethods decompressionMet
654657
/// Used by the default deserializers to determine where to start deserializing from.
655658
/// Can be used to skip container or root elements that do not have corresponding deserialzation targets.
656659
/// </summary>
660+
[Obsolete("Add custom content handler instead. This property will be removed.")]
657661
public string RootElement { get; set; }
658662

659663
/// <summary>
@@ -664,12 +668,14 @@ public IRestRequest AddDecompressionMethod(DecompressionMethods decompressionMet
664668
/// <summary>
665669
/// Used by the default deserializers to explicitly set which date format string to use when parsing dates.
666670
/// </summary>
671+
[Obsolete("Add custom content handler instead. This property will be removed.")]
667672
public string DateFormat { get; set; }
668673

669674
/// <summary>
670675
/// Used by XmlDeserializer. If not specified, XmlDeserializer will flatten response by removing namespaces from
671676
/// element names.
672677
/// </summary>
678+
[Obsolete("Add custom content handler instead. This property will be removed.")]
673679
public string XmlNamespace { get; set; }
674680

675681
/// <summary>

RestSharp/Serialization/Xml/XmlRestSerializer.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,34 @@ public string Serialize(Parameter parameter)
8686
public string RootElement
8787
{
8888
get => _options.RootElement;
89-
set => _options.RootElement = value;
89+
set
90+
{
91+
_options.RootElement = value;
92+
_xmlSerializer.RootElement = value;
93+
_xmlDeserializer.RootElement = value;
94+
}
9095
}
9196

9297
public string Namespace
9398
{
9499
get => _options.Namespace;
95-
set => _options.Namespace = value;
100+
set
101+
{
102+
_options.Namespace = value;
103+
_xmlSerializer.Namespace = value;
104+
_xmlDeserializer.Namespace = value;
105+
}
96106
}
97107

98108
public string DateFormat
99109
{
100110
get => _options.DateFormat;
101-
set => _options.DateFormat = value;
111+
set
112+
{
113+
_options.DateFormat = value;
114+
_xmlSerializer.DateFormat = value;
115+
_xmlDeserializer.DateFormat = value;
116+
}
102117
}
103118
}
104119

0 commit comments

Comments
 (0)