//
using System;
-using System.Collections;
+using System.Collections.Generic;
namespace System.Runtime.Serialization
{
-#if NET_2_0
[System.Runtime.InteropServices.ComVisibleAttribute (true)]
-#endif
public sealed class SerializationInfo
{
- Hashtable serialized = new Hashtable ();
- ArrayList values = new ArrayList ();
+ Dictionary<string, SerializationEntry> serialized = new Dictionary<string, SerializationEntry> ();
+ List<SerializationEntry> values = new List<SerializationEntry> ();
string assemblyName; // the assembly being serialized
string fullTypeName; // the type being serialized.
+ Type objectType;
+ bool isAssemblyNameSetExplicit;
+ bool isFullTypeNameSetExplicit;
IFormatterConverter converter;
assemblyName = type.Assembly.FullName;
fullTypeName = type.FullName;
converter = new FormatterConverter ();
+ objectType = type;
}
/* used by the runtime */
assemblyName = type.Assembly.FullName;
fullTypeName = type.FullName;
converter = new FormatterConverter ();
+ objectType = type;
for (int i = 0; i < len; i++) {
serialized.Add (data [i].Name, data [i]);
this.converter = converter;
assemblyName = type.Assembly.FullName;
fullTypeName = type.FullName;
+ objectType = type;
}
// Properties
if (value == null)
throw new ArgumentNullException ("Argument is null.");
assemblyName = value;
+ isAssemblyNameSetExplicit = true;
}
}
if ( value == null)
throw new ArgumentNullException ("Argument is null.");
fullTypeName = value;
+ isFullTypeNameSetExplicit = true;
}
}
get { return serialized.Count; }
}
+ public bool IsAssemblyNameSetExplicit {
+ get {
+ return isAssemblyNameSetExplicit;
+ }
+ }
+
+ public bool IsFullTypeNameSetExplicit {
+ get {
+ return isFullTypeNameSetExplicit;
+ }
+ }
+
+ public Type ObjectType {
+ get {
+ return objectType;
+ }
+ }
+
// Methods
public void AddValue (string name, object value, Type type)
{
if (!serialized.ContainsKey (name))
throw new SerializationException ("No element named " + name + " could be found.");
- SerializationEntry entry = (SerializationEntry) serialized [name];
+ SerializationEntry entry = serialized [name];
if (entry.Value != null && !type.IsInstanceOfType (entry.Value))
return converter.Convert (entry.Value, type);
return entry.Value;
}
+ internal bool HasKey (string name)
+ {
+ return serialized.ContainsKey (name);
+ }
+
public void SetType (Type type)
{
if (type == null)
fullTypeName = type.FullName;
assemblyName = type.Assembly.FullName;
+ objectType = type;
+ isAssemblyNameSetExplicit = false;
+ isFullTypeNameSetExplicit = false;
}
public SerializationInfoEnumerator GetEnumerator ()
}
/* used by the runtime */
+#pragma warning disable 169
private SerializationEntry [] get_entries ()
{
SerializationEntry [] res = new SerializationEntry [this.MemberCount];
return res;
}
+#pragma warning restore 169
}
}