public virtual void OnDeserialization(object sender)
{
if (_keyComparer != null)
{
//Somebody had a dependency on this and fixed us up before the ObjectManager got to it.
return;
}
if (_serializationInfo == null)
{
throw new SerializationException();
}
SerializationInfo info = _serializationInfo;
_serializationInfo = null;
bool readOnly = false;
int count = 0;
string[] keys = null;
object[] values = null;
IHashCodeProvider hashProvider = null;
IComparer comparer = null;
bool hasVersion = false;
int serializedVersion = 0;
SerializationInfoEnumerator enumerator = info.GetEnumerator();
while (enumerator.MoveNext())
{
switch (enumerator.Name)
{
case ReadOnlyName:
readOnly = info.GetBoolean(ReadOnlyName); ;
break;
case HashCodeProviderName:
hashProvider = (IHashCodeProvider)info.GetValue(HashCodeProviderName, typeof(IHashCodeProvider)); ;
break;
case ComparerName:
comparer = (IComparer)info.GetValue(ComparerName, typeof(IComparer));
break;
case KeyComparerName:
_keyComparer = (IEqualityComparer)info.GetValue(KeyComparerName, typeof(IEqualityComparer));
break;
case CountName:
count = info.GetInt32(CountName);
break;
case KeysName:
keys = (String[])info.GetValue(KeysName, typeof(String[]));
break;
case ValuesName:
values = (Object[])info.GetValue(ValuesName, typeof(Object[]));
break;
case VersionName:
hasVersion = true;
serializedVersion = info.GetInt32(VersionName);
break;
}
}
if (_keyComparer == null)
{
if (comparer == null || hashProvider == null)
{
throw new SerializationException();
}
else
{
// create a new key comparer for V1 Object
_keyComparer = new CompatibleComparer(hashProvider, comparer);
}
}
if (keys == null || values == null)
{
throw new SerializationException();
}
Reset(count);
for (int i = 0; i < count; i++)
{
BaseAdd(keys[i], values[i]);
}
_readOnly = readOnly; // after collection populated
if (hasVersion)
{
_version = serializedVersion;
}
}