Author: olivier Date: 2008-01-20 05:06:12 -0500 (Sun, 20 Jan 2008) New Revision: 93340
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs Log: 2008-01-20 Olivier Dufour <[EMAIL PROTECTED]> * ResXDataNode.cs: Add GetNodePosition, GetValueTypeName, GetValue * ResXResourceReader.cs: Add Node Position Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog 2008-01-20 06:05:35 UTC (rev 93339) +++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog 2008-01-20 10:06:12 UTC (rev 93340) @@ -1,3 +1,8 @@ +2008-01-20 Olivier Dufour <[EMAIL PROTECTED]> + + * ResXDataNode.cs: Add GetNodePosition, GetValueTypeName, GetValue + * ResXResourceReader.cs: Add Node Position + 2007-12-07 Atsushi Enomoto <[EMAIL PROTECTED]> * ResXResourceReader.cs: fix build. Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs 2008-01-20 06:05:35 UTC (rev 93339) +++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs 2008-01-20 10:06:12 UTC (rev 93340) @@ -21,11 +21,16 @@ // // Authors: // Andreia Gaita ([EMAIL PROTECTED]) -// +// Olivier Dufour [EMAIL PROTECTED] +// #if NET_2_0 using System; using System.Runtime.Serialization; +using System.Drawing; +using System.ComponentModel; +using System.Reflection; +using System.ComponentModel.Design; namespace System.Resources { @@ -37,6 +42,7 @@ private Type type; private ResXFileRef fileRef; private string comment; + private Point pos; public string Comment { get { return this.comment; } @@ -56,38 +62,75 @@ get { return this.value; } } - public ResXDataNode (string name, object value) + public ResXDataNode (string name, object value) : this (name, value, Point.Empty) { + } + + public ResXDataNode (string name, ResXFileRef fileRef) + { if (name == null) throw new ArgumentNullException ("name"); + if (fileRef == null) + throw new ArgumentNullException ("fileRef"); + if (name.Length == 0) throw new ArgumentException ("name"); - Type type = (value == null) ? typeof (object) : value.GetType (); - if ((value != null) && !type.IsSerializable) { - throw new InvalidOperationException (String.Format ("'{0}' of type '{1}' cannot be added because it is not serializable", name, type)); - } - - this.type = type; this.name = name; - this.value = value; - } - - public ResXDataNode (string name, ResXFileRef fileRef) + this.fileRef = fileRef; + pos = Point.Empty; + } + + internal ResXDataNode (string name, object value, Point position) { if (name == null) throw new ArgumentNullException ("name"); - if (fileRef == null) - throw new ArgumentNullException ("fileRef"); - if (name.Length == 0) throw new ArgumentException ("name"); + Type type = (value == null) ? typeof (object) : value.GetType (); + if ((value != null) && !type.IsSerializable) { + throw new InvalidOperationException (String.Format ("'{0}' of type '{1}' cannot be added because it is not serializable", name, type)); + } + + this.type = type; this.name = name; - this.fileRef = fileRef; - } + this.value = value; + pos = position; + } + + public Point GetNodePosition () + { + return pos; + } + //TODO make this class internal for 1.1 and add field type_name, mime_type + //move resolvetype and resolve value here + + [MonoTODO ("Move the type parsing process from ResxResourceReader")] + public string GetValueTypeName (AssemblyName[] names) + { + return type.AssemblyQualifiedName; + } + + [MonoTODO ("Move the type parsing process from ResxResourceReader")] + public string GetValueTypeName (ITypeResolutionService typeResolver) + { + return type.AssemblyQualifiedName; + } + + [MonoTODO ("Move the value parsing process from ResxResourceReader")] + public Object GetValue (AssemblyName[] names) + { + return value; + } + + [MonoTODO ("Move the value parsing process from ResxResourceReader")] + public Object GetValue (ITypeResolutionService typeResolver) + { + return value; + } #region ISerializable Members @@ -100,4 +143,4 @@ #endregion } } -#endif \ No newline at end of file +#endif Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs 2008-01-20 06:05:35 UTC (rev 93339) +++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs 2008-01-20 10:06:12 UTC (rev 93340) @@ -25,7 +25,7 @@ // Paolo Molaro [EMAIL PROTECTED] // Peter Bartok [EMAIL PROTECTED] // Gert Driesen [EMAIL PROTECTED] -// +// Olivier Dufour [EMAIL PROTECTED] using System; using System.Collections; @@ -38,6 +38,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Xml; using System.Reflection; +using System.Drawing; namespace System.Resources { @@ -304,15 +305,17 @@ private void ParseDataNode (bool meta) { - string name = GetAttribute ("name"); - string type_name = GetAttribute ("type"); - string mime_type = GetAttribute ("mimetype"); #if NET_2_0 Hashtable hashtable = (meta ? hashtm : hasht); + Point pos = new Point (xmlReader.LineNumber, xmlReader.LinePosition); #else Hashtable hashtable = hasht; #endif + string name = GetAttribute ("name"); + string type_name = GetAttribute ("type"); + string mime_type = GetAttribute ("mimetype"); + Type type = type_name == null ? null : ResolveType (type_name); if (type_name != null && type == null) @@ -323,7 +326,7 @@ #if NET_2_0 if (useResXDataNodes) - hashtable [name] = new ResXDataNode(name, null); + hashtable [name] = new ResXDataNode (name, null, pos); else #endif hashtable [name] = null; @@ -381,7 +384,7 @@ + "was '{0}'.", obj)); #if NET_2_0 if (useResXDataNodes) - hashtable [name] = new ResXDataNode(name, obj); + hashtable [name] = new ResXDataNode(name, obj, pos); else #endif hashtable [name] = obj; _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches