23 |
* Authors: |
* Authors: |
24 |
* Nicolai P Guba |
* Nicolai P Guba |
25 |
*/ |
*/ |
26 |
|
using System.Globalization; |
27 |
|
using System.IO; |
28 |
|
using System.Xml; |
29 |
|
|
30 |
namespace DotGNU.XmlRpc |
namespace DotGNU.XmlRpc |
31 |
{ |
{ |
|
using System.Xml; |
|
|
using System.IO; |
|
|
|
|
32 |
public class XmlRpcReader |
public class XmlRpcReader |
33 |
{ |
{ |
34 |
private String request; |
private String request; |
36 |
private XmlTextReader xmlReader; |
private XmlTextReader xmlReader; |
37 |
private XmlRpcStruct structure; |
private XmlRpcStruct structure; |
38 |
private XmlRpcArray array; |
private XmlRpcArray array; |
39 |
|
private DateTimeFormatInfo dateFormat; |
40 |
|
|
41 |
public XmlRpcReader( String buffer ) |
public XmlRpcReader( String buffer ) |
42 |
: this( new StringReader( buffer ) ){ |
: this( new StringReader( buffer ) ){ |
44 |
|
|
45 |
public XmlRpcReader( StringReader reader ) |
public XmlRpcReader( StringReader reader ) |
46 |
{ |
{ |
47 |
structure = null; |
structure = null; |
48 |
array = null; |
array = null; |
49 |
method = new XmlRpcMethod(); |
method = new XmlRpcMethod(); |
50 |
xmlReader = new XmlTextReader( reader ); |
xmlReader = new XmlTextReader( reader ); |
51 |
|
dateFormat = new DateTimeFormatInfo(); |
52 |
|
dateFormat.FullDateTimePattern = dateFormat.RFC1123Pattern; |
53 |
|
|
54 |
// Itereate through the tree and construct an n-ary tree with |
// Itereate through the tree and construct an n-ary tree with |
55 |
// XmlRpcNodes so we can detect protocol errors and the current |
// XmlRpcNodes so we can detect protocol errors and the current |
56 |
// scope/context of a value parameter. |
// scope/context of a value parameter. |
170 |
Add( dval ); |
Add( dval ); |
171 |
break; |
break; |
172 |
case "dateTime.iso8601": |
case "dateTime.iso8601": |
|
/* |
|
173 |
try { |
try { |
174 |
DateTime dtval = Convert.ToDateTime( xmlReader.Value ); |
DateTime dtval = DateTime.ParseExact( xmlReader.Value, "s", dateFormat ); |
175 |
Add( dtval ); |
Add( dtval ); |
176 |
} |
} |
177 |
catch( FormatException e ){ |
catch( FormatException e ){ |
178 |
throw new XmlRpcBadFormatException( 100, "Cannot parse DateTime value: " + |
string str = |
179 |
xmlReader.Value, xmlReader ); |
String.Format( "Cannot parse DateTime value: {0}, expected format is: {1}", |
180 |
|
xmlReader.Value, dateFormat.UniversalSortableDateTimePattern ); |
181 |
|
|
182 |
|
throw new XmlRpcBadFormatException( 100, str , xmlReader ); |
183 |
} |
} |
|
*/ |
|
184 |
break; |
break; |
185 |
case "string": |
case "string": |
186 |
Add( xmlReader.Value ); |
Add( xmlReader.Value ); |