[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System UnitySerializationHold
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System UnitySerializationHolder.cs, NONE, 1.1 DBNull.cs, 1.7, 1.8 |
Date: |
Tue, 19 Aug 2003 22:44:49 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System
In directory subversions:/tmp/cvs-serv3135/runtime/System
Modified Files:
DBNull.cs
Added Files:
UnitySerializationHolder.cs
Log Message:
Serialization for DBNull and Empty.
--- NEW FILE ---
/*
* UnitySerializationHolder.cs - Implementation of the
* "System.UnitySerializationHolder" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System
{
#if CONFIG_SERIALIZATION
using System.Runtime.Serialization;
using System.Reflection;
using System.Private;
// This class is used as a proxy to stand in for singleton objects
// like "System.DBNull", "System.Reflection.Missing", and for special
// types like "Module", "Assembly", etc. This class must be named
// "System.UnitySerializationHolder" for compatibility with other
// serialization implementations.
internal class UnitySerializationHolder : ISerializable, IObjectReference
{
// Special constants for the unity types.
public enum UnityType
{
Empty = 1,
DBNull = 2,
Missing = 3,
ClrType = 4,
Module = 5,
Assembly = 6
}; // enum UnityType
// Internal state.
private UnityType type;
private String data;
private String assembly;
// Constructor.
public UnitySerializationHolder(SerializationInfo info,
StreamingContext context)
{
if(info == null)
{
throw new ArgumentNullException("info");
}
type = (UnityType)(info.GetInt32("UnityType"));
data = info.GetString("Data");
assembly = info.GetString("AssemblyName");
}
// Serialize a unity object.
public static void Serialize(SerializationInfo info, UnityType type,
String data,
Assembly assembly)
{
info.SetType(typeof(UnitySerializationHolder));
info.AddValue("data", data);
info.AddValue("UnityType", (int)type);
if(assembly != null)
{
info.AddValue("AssemblyName",
assembly.FullName);
}
else
{
info.AddValue("AssemblyName",
String.Empty);
}
}
// Implement the ISerializable interface.
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
// This method should never be called.
throw new NotSupportedException();
}
// Implement the IObjectReference interface.
[TODO]
public Object GetRealObject(StreamingContext context)
{
switch(type)
{
case UnityType.Empty: return
Empty.Value;
case UnityType.DBNull: return
DBNull.Value;
case UnityType.Missing: return
Missing.Value;
// TODO: other unity types
default:
throw new ArgumentException
(_("Arg_InvalidUnityObject"));
}
}
}; // class UnitySerializationHolder
#endif // CONFIG_SERIALIZATION
}; // namespace System
Index: DBNull.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/DBNull.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** DBNull.cs 26 May 2003 04:41:21 -0000 1.7
--- DBNull.cs 20 Aug 2003 02:44:47 -0000 1.8
***************
*** 111,118 ****
// Get the serialization data for this object.
- [TODO]
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
! // TODO
}
--- 111,119 ----
// Get the serialization data for this object.
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
! UnitySerializationHolder.Serialize
! (info,
UnitySerializationHolder.UnityType.DBNull,
! null, null);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System UnitySerializationHolder.cs, NONE, 1.1 DBNull.cs, 1.7, 1.8,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.1277,1.1278
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection Assembly.cs, 1.29, 1.30 AssemblyName.cs, 1.4, 1.5
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.1277,1.1278
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection Assembly.cs, 1.29, 1.30 AssemblyName.cs, 1.4, 1.5
- Index(es):