Author: kornelpal
Date: 2006-07-05 15:24:01 -0400 (Wed, 05 Jul 2006)
New Revision: 62274
Modified:
trunk/mcs/class/corlib/System.Text/ChangeLog
trunk/mcs/class/corlib/System.Text/CodePageEncoding.cs
trunk/mcs/class/corlib/System.Text/MLangCodePageEncoding.cs
trunk/mcs/class/corlib/System.Text/SurrogateEncoder.cs
Log:
CodePageEncoding.cs: Return the same real object in subsequent calls to
GetRealObject ().; MLangCodePageEncoding.cs: Return the same real object in
subsequent calls to GetRealObject (). Rename Encoder and Decoder MLangEncoder
and MLangDecoder. These classes are not serializable in 1.x although MS.NET 2.0
can deserialize them.; SurrogateEncoder.cs: Return the same real object in
subsequent calls to GetRealObject ().
Modified: trunk/mcs/class/corlib/System.Text/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Text/ChangeLog 2006-07-05 17:19:23 UTC
(rev 62273)
+++ trunk/mcs/class/corlib/System.Text/ChangeLog 2006-07-05 19:24:01 UTC
(rev 62274)
@@ -1,3 +1,14 @@
+2006-07-05 Kornél Pál <[EMAIL PROTECTED]>
+
+ * CodePageEncoding.cs: Return the same real object in subsequent
+ calls to GetRealObject ().
+ * MLangCodePageEncoding.cs: Return the same real object in
+ subsequent calls to GetRealObject (). Rename Encoder and Decoder
+ MLangEncoder and MLangDecoder. These classes are not serializable
+ in 1.x although MS.NET 2.0 can deserialize them.
+ * SurrogateEncoder.cs: Return the same real object in subsequent
+ calls to GetRealObject ().
+
2006-07-04 Kornél Pál <[EMAIL PROTECTED]>
* CodePageEncoding.cs: Added comment on usage.
Modified: trunk/mcs/class/corlib/System.Text/CodePageEncoding.cs
===================================================================
--- trunk/mcs/class/corlib/System.Text/CodePageEncoding.cs 2006-07-05
17:19:23 UTC (rev 62273)
+++ trunk/mcs/class/corlib/System.Text/CodePageEncoding.cs 2006-07-05
19:24:01 UTC (rev 62274)
@@ -37,13 +37,13 @@
// Use SerializationInfo.SetType() in ISerializable.GetObjectData() method of
// serializable classes to serialize their instances using a proxy class.
//
-// All of these proxy classes are non-public so they only have to be
+// All of these proxy classes are non-public thus they only have to be
// serialization compatible with .NET Framework.
//
//
-// .NET Framework 1.x uses this class for single-byte encodings and
-// .NET Framework 2.0 serializes single byte-encodings using a proxy.
+// .NET Framework 1.x uses this class for internal encodings and
+// .NET Framework 2.0 serializes internal encodings using a proxy.
// This class supports serialization compatibility.
//
@@ -56,7 +56,7 @@
internal sealed class CodePageEncoding : ISerializable, IObjectReference
{
//
- // .NET Framework 1.x uses this class for single-byte decoders
and
+ // .NET Framework 1.x uses this class for internal decoders and
// .NET Framework 2.0 can deserialize them using a proxy.
// This class supports serialization compatibility.
//
@@ -65,6 +65,7 @@
private sealed class Decoder : ISerializable, IObjectReference
{
private Encoding encoding;
+ private System.Text.Decoder realObject;
private Decoder (SerializationInfo info,
StreamingContext context)
{
@@ -81,7 +82,10 @@
public object GetRealObject (StreamingContext context)
{
- return this.encoding.GetDecoder ();
+ if (this.realObject == null)
+ this.realObject =
this.encoding.GetDecoder ();
+
+ return this.realObject;
}
}
@@ -91,6 +95,7 @@
private EncoderFallback encoderFallback;
private DecoderFallback decoderFallback;
#endif
+ private Encoding realObject;
private CodePageEncoding (SerializationInfo info,
StreamingContext context)
{
@@ -117,17 +122,21 @@
public object GetRealObject (StreamingContext context)
{
- Encoding encoding = Encoding.GetEncoding
(this.codePage);
+ if (this.realObject == null) {
+ Encoding encoding = Encoding.GetEncoding
(this.codePage);
#if NET_2_0
- if (!this.isReadOnly) {
- encoding = (Encoding) encoding.Clone ();
- encoding.EncoderFallback = this.encoderFallback;
- encoding.DecoderFallback = this.decoderFallback;
- }
+ if (!this.isReadOnly) {
+ encoding = (Encoding) encoding.Clone ();
+ encoding.EncoderFallback =
this.encoderFallback;
+ encoding.DecoderFallback =
this.decoderFallback;
+ }
#endif
- return encoding;
+ this.realObject = encoding;
+ }
+
+ return this.realObject;
}
}
}
Modified: trunk/mcs/class/corlib/System.Text/MLangCodePageEncoding.cs
===================================================================
--- trunk/mcs/class/corlib/System.Text/MLangCodePageEncoding.cs 2006-07-05
17:19:23 UTC (rev 62273)
+++ trunk/mcs/class/corlib/System.Text/MLangCodePageEncoding.cs 2006-07-05
19:24:01 UTC (rev 62274)
@@ -37,13 +37,13 @@
// Use SerializationInfo.SetType() in ISerializable.GetObjectData() method of
// serializable classes to serialize their instances using a proxy class.
//
-// All of these proxy classes are non-public so they only have to be
+// All of these proxy classes are non-public thus they only have to be
// serialization compatible with .NET Framework.
//
//
-// .NET Framework 1.x uses this class for multi-byte encodings and
-// .NET Framework 2.0 serializes multi-byte encodings using a proxy.
+// .NET Framework 1.x uses this class for internal encodings and
+// .NET Framework 2.0 serializes internal encodings using a proxy.
// This class supports serialization compatibility.
//
@@ -56,22 +56,25 @@
internal sealed class MLangCodePageEncoding : ISerializable,
IObjectReference
{
//
- // .NET Framework 1.x uses this class for multi-byte encoders
and
- // .NET Framework 2.0 can deserialize them using a proxy.
+ // .NET Framework 1.x uses this class for internal encoders.
+ // .NET Framework 2.0 can deserialize them using a proxy
although
+ // this class is not serializable in .NET Framework 1.x.
// This class supports serialization compatibility.
//
+#if NET_2_0
[Serializable]
- private sealed class Encoder : ISerializable, IObjectReference
+ private sealed class MLangEncoder : ISerializable,
IObjectReference
{
private Encoding encoding;
+ private Encoder realObject;
- private Encoder (SerializationInfo info,
StreamingContext context)
+ private MLangEncoder (SerializationInfo info,
StreamingContext context)
{
if (info == null)
throw new ArgumentNullException
("info");
- this.encoding = (Encoding) info.GetValue
("encoding", typeof (Encoding));
+ this.encoding = (Encoding) info.GetValue
("m_encoding", typeof (Encoding));
}
public void GetObjectData (SerializationInfo info,
StreamingContext context)
@@ -81,27 +84,42 @@
public object GetRealObject (StreamingContext context)
{
- return this.encoding.GetEncoder ();
+ if (this.realObject == null)
+ this.realObject =
this.encoding.GetEncoder ();
+
+ return this.realObject;
}
}
+#else
+ private sealed class MLangEncoder
+ {
+ private MLangEncoder ()
+ {
+ throw new ArgumentException ("This class cannot
be instantiated.");
+ }
+ }
+#endif
//
- // .NET Framework 1.x uses this class for multi-byte decoders
and
- // .NET Framework 2.0 can deserialize them using a proxy.
+ // .NET Framework 1.x uses this class for internal decoders.
+ // .NET Framework 2.0 can deserialize them using a proxy
although
+ // this class is not serializable in .NET Framework 1.x.
// This class supports serialization compatibility.
//
+#if NET_2_0
[Serializable]
- private sealed class Decoder : ISerializable, IObjectReference
+ private sealed class MLangDecoder : ISerializable,
IObjectReference
{
private Encoding encoding;
+ private Decoder realObject;
- private Decoder (SerializationInfo info,
StreamingContext context)
+ private MLangDecoder (SerializationInfo info,
StreamingContext context)
{
if (info == null)
throw new ArgumentNullException
("info");
- this.encoding = (Encoding) info.GetValue
("encoding", typeof (Encoding));
+ this.encoding = (Encoding) info.GetValue
("m_encoding", typeof (Encoding));
}
public void GetObjectData (SerializationInfo info,
StreamingContext context)
@@ -111,9 +129,21 @@
public object GetRealObject (StreamingContext context)
{
- return this.encoding.GetDecoder ();
+ if (this.realObject == null)
+ this.realObject =
this.encoding.GetDecoder ();
+
+ return this.realObject;
}
}
+#else
+ private sealed class MLangDecoder
+ {
+ private MLangDecoder ()
+ {
+ throw new ArgumentException ("This class cannot
be instantiated.");
+ }
+ }
+#endif
private int codePage;
#if NET_2_0
@@ -121,6 +151,7 @@
private EncoderFallback encoderFallback;
private DecoderFallback decoderFallback;
#endif
+ private Encoding realObject;
private MLangCodePageEncoding (SerializationInfo info,
StreamingContext context)
{
@@ -147,17 +178,21 @@
public object GetRealObject (StreamingContext context)
{
- Encoding encoding = Encoding.GetEncoding
(this.codePage);
+ if (this.realObject == null) {
+ Encoding encoding = Encoding.GetEncoding
(this.codePage);
#if NET_2_0
- if (!this.isReadOnly) {
- encoding = (Encoding) encoding.Clone ();
- encoding.EncoderFallback = this.encoderFallback;
- encoding.DecoderFallback = this.decoderFallback;
- }
+ if (!this.isReadOnly) {
+ encoding = (Encoding) encoding.Clone ();
+ encoding.EncoderFallback =
this.encoderFallback;
+ encoding.DecoderFallback =
this.decoderFallback;
+ }
#endif
- return encoding;
+ this.realObject = encoding;
+ }
+
+ return this.realObject;
}
}
}
Modified: trunk/mcs/class/corlib/System.Text/SurrogateEncoder.cs
===================================================================
--- trunk/mcs/class/corlib/System.Text/SurrogateEncoder.cs 2006-07-05
17:19:23 UTC (rev 62273)
+++ trunk/mcs/class/corlib/System.Text/SurrogateEncoder.cs 2006-07-05
19:24:01 UTC (rev 62274)
@@ -37,7 +37,7 @@
// Use SerializationInfo.SetType() in ISerializable.GetObjectData() method of
// serializable classes to serialize their instances using a proxy class.
//
-// All of these proxy classes are non-public so they only have to be
+// All of these proxy classes are non-public thus they only have to be
// serialization compatible with .NET Framework.
//
@@ -56,6 +56,7 @@
internal sealed class SurrogateEncoder : ISerializable, IObjectReference
{
private Encoding encoding;
+ private Encoder realObject;
private SurrogateEncoder (SerializationInfo info,
StreamingContext context)
{
@@ -72,7 +73,10 @@
public object GetRealObject (StreamingContext context)
{
- return this.encoding.GetEncoder ();
+ if (this.realObject == null)
+ this.realObject = this.encoding.GetEncoder ();
+
+ return this.realObject;
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches