Author: gert
Date: 2008-01-27 14:05:30 -0500 (Sun, 27 Jan 2008)
New Revision: 94073
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/ResXFileRef.cs
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
Log:
* ResXResourceReader.cs: Avoid unnecessary initialization of
useResXDataNodes field. Modified argument names to match MS. When
UseResXDataNodes is true, then never use the metadata hashtable.
* ResXFileRef.cs: Only support convert from fileref to MemoryStream
on 2.0 profile.
* ResXResourceWriter.cs: Modified argument names to match MS.
* ResXDataNode: Fixed line endings.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog
2008-01-27 18:34:15 UTC (rev 94072)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog
2008-01-27 19:05:30 UTC (rev 94073)
@@ -1,3 +1,13 @@
+2008-01-27 Gert Driesen <[EMAIL PROTECTED]>
+
+ * ResXResourceReader.cs: Avoid unnecessary initialization of
+ useResXDataNodes field. Modified argument names to match MS. When
+ UseResXDataNodes is true, then never use the metadata hashtable.
+ * ResXFileRef.cs: Only support convert from fileref to MemoryStream
+ on 2.0 profile.
+ * ResXResourceWriter.cs: Modified argument names to match MS.
+ * ResXDataNode: Fixed line endings.
+
2008-01-21 Zoltan Varga <[EMAIL PROTECTED]>
* ResXFileRef.cs (ConvertFrom): Add special support for MemoryStream.
Fixes
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs
2008-01-27 18:34:15 UTC (rev 94072)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs
2008-01-27 19:05:30 UTC (rev 94073)
@@ -1,104 +1,104 @@
-// 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.
-//
-// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
-//
-// Authors:
-// Andreia Gaita ([EMAIL PROTECTED])
-// Olivier Dufour [EMAIL PROTECTED]
+// 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.
//
-
-#if NET_2_0
-using System;
-using System.Runtime.Serialization;
+// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
+//
+// 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
-{
- [SerializableAttribute]
- public sealed class ResXDataNode : ISerializable
- {
- private string name;
- private object value;
- private Type type;
- private ResXFileRef fileRef;
- private string comment;
+
+namespace System.Resources
+{
+ [SerializableAttribute]
+ public sealed class ResXDataNode : ISerializable
+ {
+ private string name;
+ private object value;
+ private Type type;
+ private ResXFileRef fileRef;
+ private string comment;
private Point pos;
-
- public string Comment {
- get { return this.comment; }
- set { this.comment = value; }
- }
-
- public ResXFileRef FileRef {
- get { return this.fileRef; }
- }
-
- public string Name {
- get { return this.name; }
- set { this.name = value; }
- }
-
- internal object Value {
- get { return this.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");
-
- this.name = name;
+
+ public string Comment {
+ get { return this.comment; }
+ set { this.comment = value; }
+ }
+
+ public ResXFileRef FileRef {
+ get { return this.fileRef; }
+ }
+
+ public string Name {
+ get { return this.name; }
+ set { this.name = value; }
+ }
+
+ internal object Value {
+ get { return this.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");
+
+ this.name = name;
this.fileRef = fileRef;
- pos = Point.Empty;
+ pos = Point.Empty;
}
- internal ResXDataNode (string name, object value, Point
position)
- {
- if (name == null)
- throw new ArgumentNullException ("name");
-
- 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;
+ internal ResXDataNode (string name, object value, Point
position)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ 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;
- pos = position;
+ pos = position;
}
public Point GetNodePosition ()
@@ -108,7 +108,7 @@
//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")]
+ [MonoTODO ("Move the type parsing process from
ResxResourceReader")]
public string GetValueTypeName (AssemblyName[] names)
{
return type.AssemblyQualifiedName;
@@ -131,16 +131,16 @@
{
return value;
}
-
- #region ISerializable Members
-
- void ISerializable.GetObjectData (SerializationInfo info,
StreamingContext context)
- {
- info.AddValue ("Name", this.Name);
- info.AddValue ("Comment", this.Comment);
- }
-
- #endregion
- }
-}
+
+ #region ISerializable Members
+
+ void ISerializable.GetObjectData (SerializationInfo info,
StreamingContext context)
+ {
+ info.AddValue ("Name", this.Name);
+ info.AddValue ("Comment", this.Comment);
+ }
+
+ #endregion
+ }
+}
#endif
Property changes on:
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXDataNode.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs
2008-01-27 18:34:15 UTC (rev 94072)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs
2008-01-27 19:05:30 UTC (rev 94073)
@@ -91,10 +91,10 @@
MemoryStream ms = new MemoryStream
(buffer);
return new Icon (ms).ToBitmap ();
}
-#endif
if (type == typeof (MemoryStream))
return new MemoryStream (buffer);
+#endif
return Activator.CreateInstance(type,
BindingFlags.CreateInstance
| BindingFlags.Public |
BindingFlags.Instance, null,
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
2008-01-27 18:34:15 UTC (rev 94072)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
2008-01-27 19:05:30 UTC (rev 94073)
@@ -25,7 +25,7 @@
// Paolo Molaro [EMAIL PROTECTED]
// Peter Bartok [EMAIL PROTECTED]
// Gert Driesen [EMAIL PROTECTED]
-// Olivier Dufour [EMAIL PROTECTED]
+// Olivier Dufour [EMAIL PROTECTED]
using System;
using System.Collections;
@@ -52,7 +52,6 @@
private ITypeResolutionService typeresolver;
private XmlTextReader xmlReader;
-
#if NET_2_0
private string basepath;
private bool useResXDataNodes;
@@ -65,49 +64,40 @@
public ResXResourceReader (Stream stream)
{
if (stream == null)
- throw new ArgumentNullException ("Value cannot
be null.");
+ throw new ArgumentNullException ("stream");
if (!stream.CanRead)
throw new ArgumentException ("Stream was not
readable.");
this.stream = stream;
-#if NET_2_0
- this.useResXDataNodes = false;
-#endif
- }
+ }
- public ResXResourceReader (Stream stream,
ITypeResolutionService typeresolver)
+ public ResXResourceReader (Stream stream,
ITypeResolutionService typeResolver)
: this (stream)
{
- this.typeresolver = typeresolver;
+ this.typeresolver = typeResolver;
}
public ResXResourceReader (string fileName)
{
this.fileName = fileName;
-#if NET_2_0
- this.useResXDataNodes = false;
-#endif
- }
+ }
- public ResXResourceReader (string fileName,
ITypeResolutionService typeresolver)
+ public ResXResourceReader (string fileName,
ITypeResolutionService typeResolver)
: this (fileName)
{
- this.typeresolver = typeresolver;
+ this.typeresolver = typeResolver;
}
public ResXResourceReader (TextReader reader)
{
this.reader = reader;
-#if NET_2_0
- this.useResXDataNodes = false;
-#endif
}
- public ResXResourceReader (TextReader reader,
ITypeResolutionService typeresolver)
+ public ResXResourceReader (TextReader reader,
ITypeResolutionService typeResolver)
: this (reader)
{
- this.typeresolver = typeresolver;
+ this.typeresolver = typeResolver;
}
#if NET_2_0
@@ -143,6 +133,7 @@
get { return basepath; }
set { basepath = value; }
}
+
public bool UseResXDataNodes {
get { return useResXDataNodes; }
set {
@@ -306,7 +297,7 @@
private void ParseDataNode (bool meta)
{
#if NET_2_0
- Hashtable hashtable = (meta ? hashtm : hasht);
+ Hashtable hashtable = ((meta && ! useResXDataNodes) ?
hashtm : hasht);
Point pos = new Point (xmlReader.LineNumber,
xmlReader.LinePosition);
#else
Hashtable hashtable = hasht;
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
2008-01-27 18:34:15 UTC (rev 94072)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
2008-01-27 19:05:30 UTC (rev 94073)
@@ -61,18 +61,18 @@
if (stream == null)
throw new ArgumentNullException ("stream");
- if (stream.CanWrite == false)
+ if (!stream.CanWrite)
throw new ArgumentException ("stream is not
writable.", "stream");
this.stream = stream;
}
- public ResXResourceWriter (TextWriter textwriter)
+ public ResXResourceWriter (TextWriter textWriter)
{
- if (textwriter == null)
- throw new ArgumentNullException ("textwriter");
+ if (textWriter == null)
+ throw new ArgumentNullException ("textWriter");
- this.textwriter = textwriter;
+ this.textwriter = textWriter;
}
public ResXResourceWriter (string fileName)
@@ -333,10 +333,10 @@
writer.Flush ();
}
- protected virtual void Dispose(bool disposing) {
- if (disposing) {
+ protected virtual void Dispose (bool disposing)
+ {
+ if (disposing)
Close();
- }
}
static string schema = @"
@@ -370,4 +370,3 @@
".Replace ("'", "\"");
}
}
-
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches