// Copyright (C) Tim Coleman, 2002
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
using System.Collections;
using System.Text;
case "unsignedInt": return XmlConvert.ToString ((UInt32)value);
case "unsignedLong": return XmlConvert.ToString ((UInt64)value);
case "guid": return XmlConvert.ToString ((Guid)value);
+ case "base64":
case "base64Binary": return Convert.ToBase64String ((byte[])value);
+ case "duration": return XmlConvert.ToString ((TimeSpan) value);
default: return value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString ();
}
}
case "unsignedInt": return XmlConvert.ToUInt32 (value);
case "unsignedLong": return XmlConvert.ToUInt64 (value);
case "guid": return XmlConvert.ToGuid (value);
+ case "base64":
case "base64Binary": return Convert.FromBase64String (value);
+ case "duration": return XmlConvert.ToTimeSpan (value);
default:
if (type.Type != null)
return Convert.ChangeType (value, type.Type);
case "unsignedInt": return value + ".ToString(CultureInfo.InvariantCulture)";
case "unsignedLong": return value + ".ToString(CultureInfo.InvariantCulture)";
case "guid": return "XmlConvert.ToString (" + value + ")";
+ case "base64":
case "base64Binary": return "Convert.ToBase64String (" + value + ")";
+ case "duration": return "XmlConvert.ToString (" + value + ")";
case "NMTOKEN":
case "Name":
case "NCName":
case "int": return "Int32.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "long": return "Int64.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "byte": return "SByte.Parse (" + value + ", CultureInfo.InvariantCulture)";
- case "float": return "XmlConvert.ToSingle (" + value + ", CultureInfo.InvariantCulture)";
+ case "float": return "XmlConvert.ToSingle (" + value + ")";
case "unsignedShort": return "UInt16.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "unsignedInt": return "UInt32.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "unsignedLong": return "UInt64.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "guid": return "XmlConvert.ToGuid (" + value + ")";
+ case "base64:":
case "base64Binary": return "Convert.FromBase64String (" + value + ")";
+ case "duration": return "XmlConvert.ToTimeSpan (" + value + ")";
default: return value;
}
}