XQueryConvert.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. //
  2. // System.Xml.Query.XQueryConvert
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2004 Novell Inc.
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Globalization;
  32. using System.IO;
  33. using System.Text;
  34. using System.Xml;
  35. using System.Xml.Schema;
  36. using System.Xml.XPath;
  37. namespace MS.Internal.Xml
  38. {
  39. public class XQueryConvert // Won't be public in the final stage
  40. {
  41. [MonoTODO]
  42. public static bool ShouldCheckValueFacets (XmlSchemaType schemaTypeDest)
  43. {
  44. throw new NotImplementedException ();
  45. }
  46. [MonoTODO]
  47. public static XmlTypeCode GetFallbackType (XmlTypeCode type)
  48. {
  49. throw new NotImplementedException ();
  50. }
  51. [MonoTODO]
  52. // See XQuery & XPath 2.0 functions & operators section 17.
  53. public static bool CanConvert (XPathItem item, XmlSchemaType schemaTypeDest)
  54. {
  55. if (item == null)
  56. throw new ArgumentNullException ("item");
  57. if (schemaTypeDest == null)
  58. throw new ArgumentNullException ("schemaTypeDest");
  59. XmlTypeCode src = item.XmlType.TypeCode;
  60. XmlTypeCode dst = schemaTypeDest.TypeCode;
  61. // Notation cannot be converted from other than Notation
  62. if (src == XmlTypeCode.Notation && dst != XmlTypeCode.Notation)
  63. return false;
  64. // untypedAtomic and string are convertable unless source type is QName.
  65. switch (dst) {
  66. case XmlTypeCode.UntypedAtomic:
  67. case XmlTypeCode.String:
  68. return src != XmlTypeCode.QName;
  69. }
  70. switch (src) {
  71. case XmlTypeCode.None:
  72. case XmlTypeCode.Item:
  73. case XmlTypeCode.Node:
  74. case XmlTypeCode.Document:
  75. case XmlTypeCode.Element:
  76. case XmlTypeCode.Attribute:
  77. case XmlTypeCode.Namespace:
  78. case XmlTypeCode.ProcessingInstruction:
  79. case XmlTypeCode.Comment:
  80. case XmlTypeCode.Text:
  81. throw new NotImplementedException (); // FIXME: check what happens
  82. case XmlTypeCode.AnyAtomicType:
  83. throw new NotImplementedException (); // FIXME: check what happens
  84. case XmlTypeCode.UntypedAtomic:
  85. case XmlTypeCode.String:
  86. // 'M'
  87. throw new NotImplementedException (); // FIXME: check what happens
  88. case XmlTypeCode.Boolean:
  89. case XmlTypeCode.Decimal:
  90. switch (dst) {
  91. case XmlTypeCode.Float:
  92. case XmlTypeCode.Double:
  93. case XmlTypeCode.Decimal:
  94. case XmlTypeCode.Boolean:
  95. return true;
  96. }
  97. return false;
  98. case XmlTypeCode.Float:
  99. case XmlTypeCode.Double:
  100. if (dst == XmlTypeCode.Decimal)
  101. // 'M'
  102. throw new NotImplementedException (); // FIXME: check what happens
  103. goto case XmlTypeCode.Decimal;
  104. case XmlTypeCode.Duration:
  105. switch (dst) {
  106. case XmlTypeCode.Duration:
  107. case XmlTypeCode.YearMonthDuration:
  108. case XmlTypeCode.DayTimeDuration:
  109. return true;
  110. }
  111. return false;
  112. case XmlTypeCode.DateTime:
  113. switch (dst) {
  114. case XmlTypeCode.DateTime:
  115. case XmlTypeCode.Time:
  116. case XmlTypeCode.Date:
  117. case XmlTypeCode.GYearMonth:
  118. case XmlTypeCode.GYear:
  119. case XmlTypeCode.GMonthDay:
  120. case XmlTypeCode.GDay:
  121. case XmlTypeCode.GMonth:
  122. return true;
  123. }
  124. return false;
  125. case XmlTypeCode.Time:
  126. switch (dst) {
  127. case XmlTypeCode.Time:
  128. case XmlTypeCode.Date:
  129. return true;
  130. }
  131. return false;
  132. case XmlTypeCode.Date:
  133. if (dst == XmlTypeCode.Time)
  134. return false;
  135. goto case XmlTypeCode.DateTime;
  136. case XmlTypeCode.GYearMonth:
  137. case XmlTypeCode.GYear:
  138. case XmlTypeCode.GMonthDay:
  139. case XmlTypeCode.GDay:
  140. case XmlTypeCode.GMonth:
  141. return src == dst;
  142. case XmlTypeCode.HexBinary:
  143. case XmlTypeCode.Base64Binary:
  144. if (src == dst)
  145. return true;
  146. switch (dst) {
  147. case XmlTypeCode.HexBinary:
  148. case XmlTypeCode.Base64Binary:
  149. return true;
  150. }
  151. return false;
  152. case XmlTypeCode.AnyUri:
  153. case XmlTypeCode.QName:
  154. case XmlTypeCode.Notation:
  155. return src == dst;
  156. case XmlTypeCode.NormalizedString:
  157. case XmlTypeCode.Token:
  158. case XmlTypeCode.Language:
  159. case XmlTypeCode.NmToken:
  160. case XmlTypeCode.Name:
  161. case XmlTypeCode.NCName:
  162. case XmlTypeCode.Id:
  163. case XmlTypeCode.Idref:
  164. case XmlTypeCode.Entity:
  165. case XmlTypeCode.Integer:
  166. case XmlTypeCode.NonPositiveInteger:
  167. case XmlTypeCode.NegativeInteger:
  168. case XmlTypeCode.Long:
  169. case XmlTypeCode.Int:
  170. case XmlTypeCode.Short:
  171. case XmlTypeCode.Byte:
  172. case XmlTypeCode.NonNegativeInteger:
  173. case XmlTypeCode.UnsignedLong:
  174. case XmlTypeCode.UnsignedInt:
  175. case XmlTypeCode.UnsignedShort:
  176. case XmlTypeCode.UnsignedByte:
  177. case XmlTypeCode.PositiveInteger:
  178. throw new NotImplementedException ();
  179. // xdt:*
  180. case XmlTypeCode.YearMonthDuration:
  181. if (dst == XmlTypeCode.DayTimeDuration)
  182. return false;
  183. goto case XmlTypeCode.Duration;
  184. case XmlTypeCode.DayTimeDuration:
  185. if (dst == XmlTypeCode.YearMonthDuration)
  186. return false;
  187. goto case XmlTypeCode.Duration;
  188. }
  189. throw new NotImplementedException ();
  190. }
  191. // Individual conversion
  192. public static string AnyUriToString (string value)
  193. {
  194. return value;
  195. }
  196. public static byte [] Base64BinaryToHexBinary (byte [] value)
  197. {
  198. return XmlConvert.FromBinHexString (Convert.ToBase64String (value));
  199. }
  200. public static string Base64BinaryToString (byte [] value)
  201. {
  202. return Convert.ToBase64String (value);
  203. }
  204. public static decimal BooleanToDecimal (bool value)
  205. {
  206. return Convert.ToDecimal (value);
  207. }
  208. public static double BooleanToDouble (bool value)
  209. {
  210. return Convert.ToDouble (value);
  211. }
  212. public static float BooleanToFloat (bool value)
  213. {
  214. return Convert.ToSingle (value);
  215. }
  216. public static int BooleanToInt (bool value)
  217. {
  218. return Convert.ToInt32 (value);
  219. }
  220. public static long BooleanToInteger (bool value)
  221. {
  222. return Convert.ToInt64 (value);
  223. }
  224. public static string BooleanToString (bool value)
  225. {
  226. // It looks not returning "True"
  227. return value ? "true" : "false";
  228. }
  229. [MonoTODO]
  230. public static DateTime DateTimeToDate (DateTime value)
  231. {
  232. return value.Date;
  233. }
  234. [MonoTODO]
  235. public static DateTime DateTimeToGDay (DateTime value)
  236. {
  237. return new DateTime (0, 0, value.Day);
  238. }
  239. [MonoTODO]
  240. public static DateTime DateTimeToGMonth (DateTime value)
  241. {
  242. return new DateTime (0, value.Month, 0);
  243. }
  244. [MonoTODO]
  245. public static DateTime DateTimeToGYear (DateTime value)
  246. {
  247. return new DateTime (value.Year, 0, 0);
  248. }
  249. [MonoTODO]
  250. public static DateTime DateTimeToGYearMonth (DateTime value)
  251. {
  252. return new DateTime (value.Year, value.Month, 0);
  253. }
  254. [MonoTODO]
  255. public static DateTime DateToDateTime (DateTime value)
  256. {
  257. return value.Date;
  258. }
  259. [MonoTODO]
  260. public static DateTime DateToGDay (DateTime value)
  261. {
  262. return new DateTime (0, 0, value.Day);
  263. }
  264. [MonoTODO]
  265. public static DateTime DateToGMonth (DateTime value)
  266. {
  267. return new DateTime (0, value.Month, 0);
  268. }
  269. [MonoTODO]
  270. public static DateTime DateToGYear (DateTime value)
  271. {
  272. return new DateTime (value.Year, 0, 0);
  273. }
  274. [MonoTODO]
  275. public static DateTime DateToGYearMonth (DateTime value)
  276. {
  277. return new DateTime (value.Year, value.Month, 0);
  278. }
  279. [MonoTODO]
  280. public static string DateToString (DateTime value)
  281. {
  282. return XmlConvert.ToString (value);
  283. }
  284. [MonoTODO]
  285. public static string DayTimeDurationToDuration (TimeSpan value)
  286. {
  287. return XmlConvert.ToString (value);
  288. }
  289. [MonoTODO]
  290. public static string DayTimeDurationToString (TimeSpan value)
  291. {
  292. return DayTimeDurationToDuration (value);
  293. }
  294. [MonoTODO]
  295. public static bool DecimalToBoolean (decimal value)
  296. {
  297. return value != 0;
  298. }
  299. [MonoTODO]
  300. public static double DecimalToDouble (decimal value)
  301. {
  302. return (double) value;
  303. }
  304. [MonoTODO]
  305. public static float DecimalToFloat (decimal value)
  306. {
  307. return (float) value;
  308. }
  309. [MonoTODO]
  310. public static int DecimalToInt (decimal value)
  311. {
  312. return (int) value;
  313. }
  314. [MonoTODO]
  315. public static long DecimalToInteger (decimal value)
  316. {
  317. return (long) value;
  318. }
  319. [MonoTODO] // what is value was negative?
  320. public static decimal DecimalToNonNegativeInteger (decimal value)
  321. {
  322. throw new NotImplementedException ();
  323. }
  324. [MonoTODO] // what is value was positive?
  325. public static decimal DecimalToNonPositiveInteger (decimal value)
  326. {
  327. throw new NotImplementedException ();
  328. }
  329. [MonoTODO]
  330. public static string DecimalToString (decimal value)
  331. {
  332. return XmlConvert.ToString (value);
  333. }
  334. [MonoTODO]
  335. public static bool DoubleToBoolean (double value)
  336. {
  337. return value != 0;
  338. }
  339. [MonoTODO]
  340. public static decimal DoubleToDecimal (double value)
  341. {
  342. return (decimal) value;
  343. }
  344. [MonoTODO]
  345. public static float DoubleToFloat (double value)
  346. {
  347. return (float) value;
  348. }
  349. [MonoTODO]
  350. public static int DoubleToInt (double value)
  351. {
  352. return (int) value;
  353. }
  354. [MonoTODO]
  355. public static long DoubleToInteger (double value)
  356. {
  357. return (long) value;
  358. }
  359. [MonoTODO] // what is value was negative?
  360. public static decimal DoubleToNonNegativeInteger (double value)
  361. {
  362. throw new NotImplementedException ();
  363. }
  364. [MonoTODO] // what is value was positive?
  365. public static decimal DoubleToNonPositiveInteger (double value)
  366. {
  367. throw new NotImplementedException ();
  368. }
  369. [MonoTODO]
  370. public static string DoubleToString (double value)
  371. {
  372. return XmlConvert.ToString (value);
  373. }
  374. [MonoTODO]
  375. public static TimeSpan DurationToDayTimeDuration (string value)
  376. {
  377. return XmlConvert.ToTimeSpan (value);
  378. }
  379. [MonoTODO]
  380. public static string DurationToString (string value)
  381. {
  382. return XmlConvert.ToString (XmlConvert.ToTimeSpan (value));
  383. }
  384. [MonoTODO]
  385. public static TimeSpan DurationToYearMonthDuration (string value)
  386. {
  387. return XmlConvert.ToTimeSpan (value);
  388. }
  389. [MonoTODO]
  390. public static bool FloatToBoolean (float value)
  391. {
  392. return value != 0;
  393. }
  394. [MonoTODO]
  395. public static decimal FloatToDecimal (float value)
  396. {
  397. return (decimal) value;
  398. }
  399. [MonoTODO]
  400. public static double FloatToDouble (float value)
  401. {
  402. return (double) value;
  403. }
  404. [MonoTODO]
  405. public static int FloatToInt (float value)
  406. {
  407. return (int) value;
  408. }
  409. [MonoTODO]
  410. public static long FloatToInteger (float value)
  411. {
  412. return (long) value;
  413. }
  414. [MonoTODO] // what is value was negative?
  415. public static decimal FloatToNonNegativeInteger (float value)
  416. {
  417. throw new NotImplementedException ();
  418. }
  419. [MonoTODO] // what is value was positive?
  420. public static decimal FloatToNonPositiveInteger (float value)
  421. {
  422. throw new NotImplementedException ();
  423. }
  424. [MonoTODO]
  425. public static string FloatToString (float value)
  426. {
  427. return XmlConvert.ToString (value);
  428. }
  429. [MonoTODO]
  430. public static string GDayToString (DateTime value)
  431. {
  432. return XmlConvert.ToString (TimeSpan.FromDays (value.Day));
  433. }
  434. [MonoTODO]
  435. public static string GMonthDayToString (DateTime value)
  436. {
  437. return XmlConvert.ToString (new TimeSpan (value.Day, value.Hour, value.Minute, value.Second));
  438. }
  439. [MonoTODO]
  440. public static string GMonthToString (DateTime value)
  441. {
  442. return XmlConvert.ToString (new TimeSpan (0, value.Month, 0));
  443. }
  444. [MonoTODO]
  445. public static string GYearMonthToString (DateTime value)
  446. {
  447. return XmlConvert.ToString (new TimeSpan (value.Year, value.Month, 0));
  448. }
  449. [MonoTODO]
  450. public static string GYearToString (DateTime value)
  451. {
  452. return XmlConvert.ToString (new TimeSpan (new DateTime (value.Year, 0, 0).Ticks));
  453. }
  454. public static string HexBinaryToString (byte [] data)
  455. {
  456. return XmlConvert.ToBinHexString (data);
  457. }
  458. public static string HexBinaryToBase64String (byte [] data)
  459. {
  460. return XmlConvert.ToBinHexString (data);
  461. }
  462. [MonoTODO]
  463. public static bool IntegerToBoolean (long value)
  464. {
  465. return value != 0;
  466. }
  467. [MonoTODO]
  468. public static decimal IntegerToDecimal (long value)
  469. {
  470. return (decimal) value;
  471. }
  472. [MonoTODO]
  473. public static double IntegerToDouble (long value)
  474. {
  475. return (double) value;
  476. }
  477. [MonoTODO]
  478. public static float IntegerToFloat (long value)
  479. {
  480. return (float) value;
  481. }
  482. [MonoTODO]
  483. public static int IntegerToInt (long value)
  484. {
  485. return (int) value;
  486. }
  487. [MonoTODO]
  488. public static string IntegerToString (long value)
  489. {
  490. return XmlConvert.ToString (value);
  491. }
  492. [MonoTODO]
  493. public static bool IntToBoolean (int value)
  494. {
  495. return value != 0;
  496. }
  497. [MonoTODO]
  498. public static decimal IntToDecimal (int value)
  499. {
  500. return (decimal) value;
  501. }
  502. [MonoTODO]
  503. public static double IntToDouble (int value)
  504. {
  505. return (double) value;
  506. }
  507. [MonoTODO]
  508. public static float IntToFloat (int value)
  509. {
  510. return (float) value;
  511. }
  512. [MonoTODO]
  513. public static long IntToInteger (int value)
  514. {
  515. return (long) value;
  516. }
  517. [MonoTODO]
  518. public static string IntToString (int value)
  519. {
  520. return XmlConvert.ToString (value);
  521. }
  522. [MonoTODO]
  523. public static string NonNegativeIntegerToString (decimal value)
  524. {
  525. return XmlConvert.ToString (value);
  526. }
  527. [MonoTODO]
  528. public static string NonPositiveIntegerToString (decimal value)
  529. {
  530. return XmlConvert.ToString (value);
  531. }
  532. [MonoTODO]
  533. public static DateTime TimeToDateTime (DateTime value)
  534. {
  535. return value;
  536. }
  537. [MonoTODO]
  538. public static string TimeToString (DateTime value)
  539. {
  540. return XmlConvert.ToString (value, "HH:mm:ssZ");
  541. }
  542. [MonoTODO]
  543. public static string YearMonthDurationToDuration (TimeSpan value)
  544. {
  545. return XmlConvert.ToString (value);
  546. }
  547. [MonoTODO]
  548. public static string YearMonthDurationToString (TimeSpan value)
  549. {
  550. return YearMonthDurationToDuration (value);
  551. }
  552. [MonoTODO]
  553. public static string StringToAnyUri (string value)
  554. {
  555. return value;
  556. }
  557. [MonoTODO]
  558. public static byte [] StringToBase64Binary (string value)
  559. {
  560. return Convert.FromBase64String (value);
  561. }
  562. [MonoTODO]
  563. public static bool StringToBoolean (string value)
  564. {
  565. return XmlConvert.ToBoolean (value);
  566. }
  567. [MonoTODO]
  568. public static DateTime StringToDate (string value)
  569. {
  570. return XmlConvert.ToDateTime (value);
  571. }
  572. [MonoTODO]
  573. public static DateTime StringToDateTime (string value)
  574. {
  575. return XmlConvert.ToDateTime (value);
  576. }
  577. [MonoTODO]
  578. public static TimeSpan StringToDayTimeDuration (string value)
  579. {
  580. return XmlConvert.ToTimeSpan (value);
  581. }
  582. [MonoTODO]
  583. public static decimal StringToDecimal (string value)
  584. {
  585. return XmlConvert.ToDecimal (value);
  586. }
  587. [MonoTODO]
  588. public static double StringToDouble (string value)
  589. {
  590. return XmlConvert.ToDouble (value);
  591. }
  592. [MonoTODO]
  593. public static string StringToDuration (string value)
  594. {
  595. return XmlConvert.ToString (XmlConvert.ToTimeSpan (value));
  596. }
  597. [MonoTODO]
  598. public static float StringToFloat (string value)
  599. {
  600. return XmlConvert.ToSingle (value);
  601. }
  602. [MonoTODO]
  603. public static DateTime StringToGDay (string value)
  604. {
  605. return XmlConvert.ToDateTime (value);
  606. }
  607. [MonoTODO]
  608. public static DateTime StringToGMonth (string value)
  609. {
  610. return XmlConvert.ToDateTime (value);
  611. }
  612. [MonoTODO]
  613. public static DateTime StringToGMonthDay (string value)
  614. {
  615. return XmlConvert.ToDateTime (value);
  616. }
  617. [MonoTODO]
  618. public static DateTime StringToGYear (string value)
  619. {
  620. return XmlConvert.ToDateTime (value);
  621. }
  622. [MonoTODO]
  623. public static DateTime StringToGYearMonth (string value)
  624. {
  625. return XmlConvert.ToDateTime (value);
  626. }
  627. [MonoTODO]
  628. public static byte [] StringToHexBinary (string value)
  629. {
  630. return XmlConvert.FromBinHexString (value);
  631. }
  632. [MonoTODO]
  633. public static int StringToInt (string value)
  634. {
  635. return XmlConvert.ToInt32 (value);
  636. }
  637. [MonoTODO]
  638. public static long StringToInteger (string value)
  639. {
  640. return XmlConvert.ToInt64 (value);
  641. }
  642. [MonoTODO]
  643. public static decimal StringToNonNegativeInteger (string value)
  644. {
  645. return XmlConvert.ToDecimal (value);
  646. }
  647. [MonoTODO]
  648. public static decimal StringToNonPositiveInteger (string value)
  649. {
  650. return XmlConvert.ToDecimal (value);
  651. }
  652. [MonoTODO]
  653. public static DateTime StringToTime (string value)
  654. {
  655. return XmlConvert.ToDateTime (value);
  656. }
  657. [MonoTODO]
  658. public static long StringToUnsignedInt (string value)
  659. {
  660. return XmlConvert.ToInt32 (value);
  661. }
  662. [MonoTODO]
  663. public static decimal StringToUnsignedLong (string value)
  664. {
  665. return XmlConvert.ToInt32 (value);
  666. }
  667. [MonoTODO]
  668. public static int StringToUnsignedShort (string value)
  669. {
  670. return XmlConvert.ToInt32 (value);
  671. }
  672. [MonoTODO]
  673. public static TimeSpan StringToYearMonthDuration (string value)
  674. {
  675. return XmlConvert.ToTimeSpan (value);
  676. }
  677. [MonoTODO]
  678. public static string ItemToAnyUri (XPathItem value)
  679. {
  680. return value.Value;
  681. }
  682. [MonoTODO]
  683. public static byte [] ItemToBase64Binary (XPathItem value)
  684. {
  685. return Convert.FromBase64String (value.Value);
  686. }
  687. [MonoTODO]
  688. public static bool ItemToBoolean (XPathItem value)
  689. {
  690. return XmlConvert.ToBoolean (value.Value);
  691. }
  692. [MonoTODO]
  693. public static DateTime ItemToDate (XPathItem value)
  694. {
  695. return XmlConvert.ToDateTime (value.Value);
  696. }
  697. [MonoTODO]
  698. public static DateTime ItemToDateTime (XPathItem value)
  699. {
  700. return XmlConvert.ToDateTime (value.Value);
  701. }
  702. [MonoTODO]
  703. public static TimeSpan ItemToDayTimeDuration (XPathItem value)
  704. {
  705. return XmlConvert.ToTimeSpan (value.Value);
  706. }
  707. [MonoTODO]
  708. public static decimal ItemToDecimal (XPathItem value)
  709. {
  710. return XmlConvert.ToDecimal (value.Value);
  711. }
  712. [MonoTODO]
  713. public static double ItemToDouble (XPathItem value)
  714. {
  715. return XmlConvert.ToDouble (value.Value);
  716. }
  717. [MonoTODO]
  718. public static string ItemToDuration (XPathItem value)
  719. {
  720. return XmlConvert.ToString (XmlConvert.ToTimeSpan (value.Value));
  721. }
  722. [MonoTODO]
  723. public static float ItemToFloat (XPathItem value)
  724. {
  725. return XmlConvert.ToSingle (value.Value);
  726. }
  727. [MonoTODO]
  728. public static DateTime ItemToGDay (XPathItem value)
  729. {
  730. return XmlConvert.ToDateTime (value.Value);
  731. }
  732. [MonoTODO]
  733. public static DateTime ItemToGMonth (XPathItem value)
  734. {
  735. return XmlConvert.ToDateTime (value.Value);
  736. }
  737. [MonoTODO]
  738. public static DateTime ItemToGMonthDay (XPathItem value)
  739. {
  740. return XmlConvert.ToDateTime (value.Value);
  741. }
  742. [MonoTODO]
  743. public static DateTime ItemToGYear (XPathItem value)
  744. {
  745. return XmlConvert.ToDateTime (value.Value);
  746. }
  747. [MonoTODO]
  748. public static DateTime ItemToGYearMonth (XPathItem value)
  749. {
  750. return XmlConvert.ToDateTime (value.Value);
  751. }
  752. [MonoTODO]
  753. public static byte [] ItemToHexBinary (XPathItem value)
  754. {
  755. return XmlConvert.FromBinHexString (value.Value);
  756. }
  757. [MonoTODO]
  758. public static int ItemToInt (XPathItem value)
  759. {
  760. return XmlConvert.ToInt32 (value.Value);
  761. }
  762. [MonoTODO]
  763. public static long ItemToInteger (XPathItem value)
  764. {
  765. return XmlConvert.ToInt64 (value.Value);
  766. }
  767. [MonoTODO]
  768. public static decimal ItemToNonNegativeInteger (XPathItem value)
  769. {
  770. return XmlConvert.ToDecimal (value.Value);
  771. }
  772. [MonoTODO]
  773. public static decimal ItemToNonPositiveInteger (XPathItem value)
  774. {
  775. return XmlConvert.ToDecimal (value.Value);
  776. }
  777. [MonoTODO]
  778. public static DateTime ItemToTime (XPathItem value)
  779. {
  780. return XmlConvert.ToDateTime (value.Value);
  781. }
  782. [MonoTODO]
  783. public static long ItemToUnsignedInt (XPathItem value)
  784. {
  785. return XmlConvert.ToInt32 (value.Value);
  786. }
  787. [MonoTODO]
  788. public static decimal ItemToUnsignedLong (XPathItem value)
  789. {
  790. return XmlConvert.ToInt32 (value.Value);
  791. }
  792. [MonoTODO]
  793. public static int ItemToUnsignedShort (XPathItem value)
  794. {
  795. return XmlConvert.ToInt32 (value.Value);
  796. }
  797. [MonoTODO]
  798. public static TimeSpan ItemToYearMonthDuration (XPathItem value)
  799. {
  800. return XmlConvert.ToTimeSpan (value.Value);
  801. }
  802. }
  803. }
  804. #endif