Author: marek
Date: 2007-08-26 11:07:57 -0400 (Sun, 26 Aug 2007)
New Revision: 84858

Modified:
   trunk/olive/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
   trunk/olive/class/System.Xml.Linq/System.Xml.Linq/XElement.cs
Log:
2007-08-26  Marek Safar  <[EMAIL PROTECTED]>

        * XElement.cs : Implemented explicit operators.
        


Modified: trunk/olive/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
===================================================================
--- trunk/olive/class/System.Xml.Linq/System.Xml.Linq/ChangeLog 2007-08-26 
11:09:27 UTC (rev 84857)
+++ trunk/olive/class/System.Xml.Linq/System.Xml.Linq/ChangeLog 2007-08-26 
15:07:57 UTC (rev 84858)
@@ -1,3 +1,7 @@
+2007-08-26  Marek Safar  <[EMAIL PROTECTED]>
+
+       * XElement.cs : Implemented explicit operators.
+       
 2007-05-08  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XNamespace.cs : added missing implicit operator.

Modified: trunk/olive/class/System.Xml.Linq/System.Xml.Linq/XElement.cs
===================================================================
--- trunk/olive/class/System.Xml.Linq/System.Xml.Linq/XElement.cs       
2007-08-26 11:09:27 UTC (rev 84857)
+++ trunk/olive/class/System.Xml.Linq/System.Xml.Linq/XElement.cs       
2007-08-26 15:07:57 UTC (rev 84858)
@@ -71,7 +71,195 @@
                        this.name = name;
                        Add (contents);
                }
+               
+               public static explicit operator int (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToInt32 (element.Value);
+               }
+               
+               public static explicit operator int? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToInt32 (element.Value);
+               }               
+               
+               [CLSCompliant (false)]
+               public static explicit operator uint (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToUInt32 (element.Value);
+               }
+               
+               [CLSCompliant (false)]
+               public static explicit operator uint? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToUInt32 (element.Value);
+               }               
 
+               public static explicit operator long (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToInt64 (element.Value);
+               }
+               
+               public static explicit operator long? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToInt64 (element.Value);
+               }                       
+
+               [CLSCompliant (false)]
+               public static explicit operator ulong (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToUInt64 (element.Value);
+               }
+               
+               [CLSCompliant (false)]
+               public static explicit operator ulong? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToUInt64 (element.Value);
+               }               
+
+               public static explicit operator float (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToSingle (element.Value);
+               }
+               
+               public static explicit operator float? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToSingle (element.Value);
+               }               
+                               
+               public static explicit operator double (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToDouble (element.Value);
+               }
+               
+               public static explicit operator double? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToDouble (element.Value);
+               }               
+               
+               public static explicit operator decimal (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToDecimal (element.Value);
+               }
+               
+               public static explicit operator decimal? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToDecimal (element.Value);
+               }                       
+               
+               public static explicit operator bool (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToBoolean (element.Value);
+               }
+               
+               public static explicit operator bool? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToBoolean (element.Value);
+               }               
+               
+               public static explicit operator Guid (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToGuid (element.Value);
+               }
+               
+               public static explicit operator Guid? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToGuid (element.Value);
+               }               
+               
+               public static explicit operator DateTime (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                       
+                       throw new NotImplementedException ();   
+               }
+               
+               public static explicit operator DateTime? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                       
+                       throw new NotImplementedException ();   
+               }                               
+               
+               public static explicit operator TimeSpan (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToTimeSpan (element.Value);
+               }
+               
+               public static explicit operator TimeSpan? (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return XmlConvert.ToTimeSpan (element.Value);
+               }                       
+               
+               public static explicit operator string (XElement element)
+               {
+                       if (element == null)
+                               throw new ArgumentNullException ("element");
+                               
+                       return element.Value;
+               }                       
+
                public XAttribute FirstAttribute {
                        get { return attr_first; }
                        internal set { attr_first = value; }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to