internal IDataNode ReadExtensionData(Type valueType)
{
switch (Type.GetTypeCode(valueType))
{
case TypeCode.Boolean:
return new DataNode<bool>(ReadContentAsBoolean());
case TypeCode.Char:
return new DataNode<char>(ReadContentAsChar());
case TypeCode.Byte:
return new DataNode<byte>(ReadContentAsUnsignedByte());
case TypeCode.Int16:
return new DataNode<short>(ReadContentAsShort());
case TypeCode.Int32:
return new DataNode<int>(ReadContentAsInt());
case TypeCode.Int64:
return new DataNode<long>(ReadContentAsLong());
case TypeCode.Single:
return new DataNode<float>(ReadContentAsSingle());
case TypeCode.Double:
return new DataNode<double>(ReadContentAsDouble());
case TypeCode.Decimal:
return new DataNode<decimal>(ReadContentAsDecimal());
case TypeCode.DateTime:
return new DataNode<DateTime>(ReadContentAsDateTime());
case TypeCode.String:
return new DataNode<string>(ReadContentAsString());
case TypeCode.SByte:
return new DataNode<sbyte>(ReadContentAsSignedByte());
case TypeCode.UInt16:
return new DataNode<ushort>(ReadContentAsUnsignedShort());
case TypeCode.UInt32:
return new DataNode<uint>(ReadContentAsUnsignedInt());
case TypeCode.UInt64:
return new DataNode<ulong>(ReadContentAsUnsignedLong());
case TypeCode.Empty:
case TypeCode.DBNull:
case TypeCode.Object:
default:
if (valueType == Globals.TypeOfByteArray)
return new DataNode<byte[]>(ReadContentAsBase64());
else if (valueType == Globals.TypeOfObject)
return new DataNode<object>(new object());
else if (valueType == Globals.TypeOfTimeSpan)
return new DataNode<TimeSpan>(ReadContentAsTimeSpan());
else if (valueType == Globals.TypeOfGuid)
return new DataNode<Guid>(ReadContentAsGuid());
else if (valueType == Globals.TypeOfUri)
return new DataNode<Uri>(ReadContentAsUri());
else if (valueType == Globals.TypeOfXmlQualifiedName)
return new DataNode<XmlQualifiedName>(ReadContentAsQName());
break;
}
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateInvalidPrimitiveTypeException(valueType));
}