diff Source/Mapping/MemberMapper.generated.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/Mapping/MemberMapper.generated.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,1477 @@
+//---------------------------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated by BLToolkit template for T4.
+//    Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
+// </auto-generated>
+//---------------------------------------------------------------------------------------------------
+using System;
+using System.Data.SqlTypes;
+using System.IO;
+using System.Xml;
+
+using Convert = BLToolkit.Common.Convert;
+#if !SILVERLIGHT
+using System.Xml.Linq;
+#endif
+
+namespace BLToolkit.Mapping
+{
+	public partial class MemberMapper
+	{
+
+		class SByteMapper : MemberMapper
+		{
+			SByte _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetSByte(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSByte(
+					o,
+					value is SByte ? (SByte)value :
+					value == null ? _nullValue : MappingSchema.ConvertToSByte(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToSByte(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : SByteMapper
+			{
+				public override bool IsNull(object o) { return GetSByte(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetSByte(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class Int16Mapper : MemberMapper
+		{
+			Int16 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetInt16(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetInt16(
+					o,
+					value is Int16 ? (Int16)value :
+					value == null ? _nullValue : MappingSchema.ConvertToInt16(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToInt16(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : Int16Mapper
+			{
+				public override bool IsNull(object o) { return GetInt16(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetInt16(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class Int32Mapper : MemberMapper
+		{
+			Int32 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetInt32(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetInt32(
+					o,
+					value is Int32 ? (Int32)value :
+					value == null ? _nullValue : MappingSchema.ConvertToInt32(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToInt32(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : Int32Mapper
+			{
+				public override bool IsNull(object o) { return GetInt32(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetInt32(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class Int64Mapper : MemberMapper
+		{
+			Int64 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetInt64(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetInt64(
+					o,
+					value is Int64 ? (Int64)value :
+					value == null ? _nullValue : MappingSchema.ConvertToInt64(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToInt64(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : Int64Mapper
+			{
+				public override bool IsNull(object o) { return GetInt64(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetInt64(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class ByteMapper : MemberMapper
+		{
+			Byte _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetByte(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetByte(
+					o,
+					value is Byte ? (Byte)value :
+					value == null ? _nullValue : MappingSchema.ConvertToByte(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToByte(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : ByteMapper
+			{
+				public override bool IsNull(object o) { return GetByte(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetByte(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class UInt16Mapper : MemberMapper
+		{
+			UInt16 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetUInt16(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetUInt16(
+					o,
+					value is UInt16 ? (UInt16)value :
+					value == null ? _nullValue : MappingSchema.ConvertToUInt16(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToUInt16(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : UInt16Mapper
+			{
+				public override bool IsNull(object o) { return GetUInt16(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetUInt16(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class UInt32Mapper : MemberMapper
+		{
+			UInt32 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetUInt32(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetUInt32(
+					o,
+					value is UInt32 ? (UInt32)value :
+					value == null ? _nullValue : MappingSchema.ConvertToUInt32(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToUInt32(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : UInt32Mapper
+			{
+				public override bool IsNull(object o) { return GetUInt32(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetUInt32(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class UInt64Mapper : MemberMapper
+		{
+			UInt64 _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetUInt64(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetUInt64(
+					o,
+					value is UInt64 ? (UInt64)value :
+					value == null ? _nullValue : MappingSchema.ConvertToUInt64(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToUInt64(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : UInt64Mapper
+			{
+				public override bool IsNull(object o) { return GetUInt64(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetUInt64(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class SingleMapper : MemberMapper
+		{
+			Single _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetSingle(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSingle(
+					o,
+					value is Single ? (Single)value :
+					value == null ? _nullValue : MappingSchema.ConvertToSingle(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToSingle(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : SingleMapper
+			{
+				public override bool IsNull(object o) { return GetSingle(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetSingle(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class DoubleMapper : MemberMapper
+		{
+			Double _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetDouble(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetDouble(
+					o,
+					value is Double ? (Double)value :
+					value == null ? _nullValue : MappingSchema.ConvertToDouble(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToDouble(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : DoubleMapper
+			{
+				public override bool IsNull(object o) { return GetDouble(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetDouble(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class CharMapper : MemberMapper
+		{
+			Char _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetChar(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetChar(
+					o,
+					value is Char ? (Char)value :
+					value == null ? _nullValue : MappingSchema.ConvertToChar(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToChar(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : CharMapper
+			{
+				public override bool IsNull(object o) { return GetChar(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetChar(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class BooleanMapper : MemberMapper
+		{
+			Boolean _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetBoolean(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetBoolean(
+					o,
+					value is Boolean ? (Boolean)value :
+					value == null ? _nullValue : MappingSchema.ConvertToBoolean(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToBoolean(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : BooleanMapper
+			{
+				public override bool IsNull(object o) { return GetBoolean(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetBoolean(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class DateTimeMapper : MemberMapper
+		{
+			DateTime _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetDateTime(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetDateTime(
+					o,
+					value is DateTime ? (DateTime)value :
+					value == null ? _nullValue : MappingSchema.ConvertToDateTime(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToDateTime(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : DateTimeMapper
+			{
+				public override bool IsNull(object o) { return GetDateTime(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetDateTime(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class DateTimeOffsetMapper : MemberMapper
+		{
+			DateTimeOffset _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetDateTimeOffset(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetDateTimeOffset(
+					o,
+					value is DateTimeOffset ? (DateTimeOffset)value :
+					value == null ? _nullValue : MappingSchema.ConvertToDateTimeOffset(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToDateTimeOffset(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : DateTimeOffsetMapper
+			{
+				public override bool IsNull(object o) { return GetDateTimeOffset(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetDateTimeOffset(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class DecimalMapper : MemberMapper
+		{
+			Decimal _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetDecimal(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetDecimal(
+					o,
+					value is Decimal ? (Decimal)value :
+					value == null ? _nullValue : MappingSchema.ConvertToDecimal(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				_nullValue = Convert.ToDecimal(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : DecimalMapper
+			{
+				public override bool IsNull(object o) { return GetDecimal(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetDecimal(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class GuidMapper : MemberMapper
+		{
+			Guid _nullValue;
+
+			public override bool IsNull (object o) { return false; }
+			public override void SetNull(object o) { MemberAccessor.SetGuid(o, _nullValue); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetGuid(
+					o,
+					value is Guid ? (Guid)value :
+					value == null ? _nullValue : MappingSchema.ConvertToGuid(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				if (mapMemberInfo.NullValue != null)
+					_nullValue = mapMemberInfo.NullValue is Guid ?
+						(Guid)mapMemberInfo.NullValue : new Guid(mapMemberInfo.NullValue.ToString());
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : GuidMapper
+			{
+				public override bool IsNull(object o) { return GetGuid(o) == _nullValue; }
+
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetGuid(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class StreamMapper : MemberMapper
+		{
+			Stream _nullValue;
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetValue(
+					o,
+					value is Stream ? value :
+					value == null ? _nullValue : MappingSchema.ConvertToStream(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				if (mapMemberInfo.NullValue != null)
+					_nullValue = mapMemberInfo.MappingSchema.ConvertToStream(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : StreamMapper
+			{
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetValue(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class NullableSByteMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableSByte(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableSByte(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableSByte(
+					o, value == null || value is SByte? (SByte?)value: MappingSchema.ConvertToNullableSByte(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableSByte(value);
+
+							value = System.Enum.ToObject(MemberType, (SByte)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableInt16Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableInt16(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableInt16(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableInt16(
+					o, value == null || value is Int16? (Int16?)value: MappingSchema.ConvertToNullableInt16(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableInt16(value);
+
+							value = System.Enum.ToObject(MemberType, (Int16)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableInt32Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableInt32(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableInt32(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableInt32(
+					o, value == null || value is Int32? (Int32?)value: MappingSchema.ConvertToNullableInt32(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableInt32(value);
+
+							value = System.Enum.ToObject(MemberType, (Int32)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableInt64Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableInt64(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableInt64(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableInt64(
+					o, value == null || value is Int64? (Int64?)value: MappingSchema.ConvertToNullableInt64(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableInt64(value);
+
+							value = System.Enum.ToObject(MemberType, (Int64)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableByteMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableByte(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableByte(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableByte(
+					o, value == null || value is Byte? (Byte?)value: MappingSchema.ConvertToNullableByte(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableByte(value);
+
+							value = System.Enum.ToObject(MemberType, (Byte)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableUInt16Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableUInt16(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableUInt16(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableUInt16(
+					o, value == null || value is UInt16? (UInt16?)value: MappingSchema.ConvertToNullableUInt16(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableUInt16(value);
+
+							value = System.Enum.ToObject(MemberType, (UInt16)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableUInt32Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableUInt32(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableUInt32(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableUInt32(
+					o, value == null || value is UInt32? (UInt32?)value: MappingSchema.ConvertToNullableUInt32(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableUInt32(value);
+
+							value = System.Enum.ToObject(MemberType, (UInt32)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableUInt64Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableUInt64(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableUInt64(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableUInt64(
+					o, value == null || value is UInt64? (UInt64?)value: MappingSchema.ConvertToNullableUInt64(value));
+			}
+
+			public class Enum : NullableEnumMapper
+			{
+				public override void SetValue(object o, object value)
+				{
+					if (value != null)
+					{
+						var valueType = value.GetType();
+						
+						if (valueType != MemberType)
+						{
+							if (valueType != UnderlyingType)
+								value = MappingSchema.ConvertToNullableUInt64(value);
+
+							value = System.Enum.ToObject(MemberType, (UInt64)value);
+						}
+					}
+
+					MemberAccessor.SetValue(o, value);
+				}
+			}
+		}
+
+		class NullableCharMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableChar(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableChar(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableChar(
+					o, value == null || value is Char? (Char?)value: MappingSchema.ConvertToNullableChar(value));
+			}
+		}
+
+		class NullableDoubleMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableDouble(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableDouble(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableDouble(
+					o, value == null || value is Double? (Double?)value: MappingSchema.ConvertToNullableDouble(value));
+			}
+		}
+
+		class NullableSingleMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableSingle(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableSingle(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableSingle(
+					o, value == null || value is Single? (Single?)value: MappingSchema.ConvertToNullableSingle(value));
+			}
+		}
+
+		class NullableBooleanMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableBoolean(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableBoolean(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableBoolean(
+					o, value == null || value is Boolean? (Boolean?)value: MappingSchema.ConvertToNullableBoolean(value));
+			}
+		}
+
+		class NullableDateTimeMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableDateTime(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableDateTime(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableDateTime(
+					o, value == null || value is DateTime? (DateTime?)value: MappingSchema.ConvertToNullableDateTime(value));
+			}
+		}
+
+		class NullableDecimalMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableDecimal(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableDecimal(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableDecimal(
+					o, value == null || value is Decimal? (Decimal?)value: MappingSchema.ConvertToNullableDecimal(value));
+			}
+		}
+
+		class NullableGuidMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetNullableGuid(o) == null; }
+			public override void SetNull(object o) { MemberAccessor.SetNullableGuid(o, null); }
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetNullableGuid(
+					o, value == null || value is Guid? (Guid?)value: MappingSchema.ConvertToNullableGuid(value));
+			}
+		}
+
+#if !SILVERLIGHT
+
+		class XmlReaderMapper : MemberMapper
+		{
+			XmlReader _nullValue;
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetValue(
+					o,
+					value is XmlReader ? value :
+					value == null ? _nullValue : MappingSchema.ConvertToXmlReader(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				if (mapMemberInfo.NullValue != null)
+					_nullValue = mapMemberInfo.MappingSchema.ConvertToXmlReader(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : XmlReaderMapper
+			{
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetValue(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+		class XmlDocumentMapper : MemberMapper
+		{
+			XmlDocument _nullValue;
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetValue(
+					o,
+					value is XmlDocument ? value :
+					value == null ? _nullValue : MappingSchema.ConvertToXmlDocument(value));
+			}
+
+			public override void Init(MapMemberInfo mapMemberInfo)
+			{
+				if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+				if (mapMemberInfo.NullValue != null)
+					_nullValue = mapMemberInfo.MappingSchema.ConvertToXmlDocument(mapMemberInfo.NullValue);
+
+				base.Init(mapMemberInfo);
+			}
+
+			public class Nullable : XmlDocumentMapper
+			{
+				public override object GetValue(object o)
+				{
+					var value = MemberAccessor.GetValue(o);
+					return value == _nullValue ? null : (object)value;
+				}
+			}
+		}
+
+        class XElementMapper : MemberMapper
+        {
+            XElement _nullValue;
+
+            public override void SetValue(object o, object value)
+            {
+                MemberAccessor.SetValue(
+                    o,
+                    value is XElement ? value :
+                    value == null ? _nullValue : MappingSchema.ConvertToXElement(value));
+            }
+
+            public override void Init(MapMemberInfo mapMemberInfo)
+            {
+                if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
+
+                if (mapMemberInfo.NullValue != null)
+                    _nullValue = mapMemberInfo.MappingSchema.ConvertToXElement(mapMemberInfo.NullValue);
+
+                base.Init(mapMemberInfo);
+            }
+
+            public class Nullable : XElementMapper
+            {
+                public override object GetValue(object o)
+                {
+                    var value = MemberAccessor.GetValue(o);
+                    return value == _nullValue ? null : (object)value;
+                }
+            }
+        }
+
+		class SqlByteMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlByte(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlByte(o, SqlByte.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlByte(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlByte(
+					o, value is SqlByte? (SqlByte)value: MappingSchema.ConvertToSqlByte(value));
+			}
+
+			public class Default : SqlByteMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlInt16Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlInt16(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlInt16(o, SqlInt16.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlInt16(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlInt16(
+					o, value is SqlInt16? (SqlInt16)value: MappingSchema.ConvertToSqlInt16(value));
+			}
+
+			public class Default : SqlInt16Mapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlInt32Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlInt32(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlInt32(o, SqlInt32.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlInt32(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlInt32(
+					o, value is SqlInt32? (SqlInt32)value: MappingSchema.ConvertToSqlInt32(value));
+			}
+
+			public class Default : SqlInt32Mapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlInt64Mapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlInt64(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlInt64(o, SqlInt64.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlInt64(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlInt64(
+					o, value is SqlInt64? (SqlInt64)value: MappingSchema.ConvertToSqlInt64(value));
+			}
+
+			public class Default : SqlInt64Mapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlSingleMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlSingle(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlSingle(o, SqlSingle.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlSingle(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlSingle(
+					o, value is SqlSingle? (SqlSingle)value: MappingSchema.ConvertToSqlSingle(value));
+			}
+
+			public class Default : SqlSingleMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlBooleanMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlBoolean(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlBoolean(o, SqlBoolean.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlBoolean(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlBoolean(
+					o, value is SqlBoolean? (SqlBoolean)value: MappingSchema.ConvertToSqlBoolean(value));
+			}
+
+			public class Default : SqlBooleanMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlDoubleMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlDouble(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlDouble(o, SqlDouble.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlDouble(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlDouble(
+					o, value is SqlDouble? (SqlDouble)value: MappingSchema.ConvertToSqlDouble(value));
+			}
+
+			public class Default : SqlDoubleMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlDateTimeMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlDateTime(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlDateTime(o, SqlDateTime.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlDateTime(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlDateTime(
+					o, value is SqlDateTime? (SqlDateTime)value: MappingSchema.ConvertToSqlDateTime(value));
+			}
+
+			public class Default : SqlDateTimeMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlDecimalMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlDecimal(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlDecimal(o, SqlDecimal.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlDecimal(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlDecimal(
+					o, value is SqlDecimal? (SqlDecimal)value: MappingSchema.ConvertToSqlDecimal(value));
+			}
+
+			public class Default : SqlDecimalMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlMoneyMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlMoney(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlMoney(o, SqlMoney.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlMoney(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlMoney(
+					o, value is SqlMoney? (SqlMoney)value: MappingSchema.ConvertToSqlMoney(value));
+			}
+
+			public class Default : SqlMoneyMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlGuidMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlGuid(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlGuid(o, SqlGuid.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlGuid(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlGuid(
+					o, value is SqlGuid? (SqlGuid)value: MappingSchema.ConvertToSqlGuid(value));
+			}
+
+			public class Default : SqlGuidMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+		class SqlStringMapper : MemberMapper
+		{
+			public override bool IsNull (object o) { return GetSqlString(o).IsNull; }
+			public override void SetNull(object o) { MemberAccessor.SetSqlString(o, SqlString.Null); }
+
+			public override object GetValue(object o)
+			{
+				var value = MemberAccessor.GetSqlString(o);
+				return value.IsNull? null: (object)value.Value;
+			}
+
+			public override void SetValue(object o, object value)
+			{
+				MemberAccessor.SetSqlString(
+					o, value is SqlString? (SqlString)value: MappingSchema.ConvertToSqlString(value));
+			}
+
+			public class Default : SqlStringMapper
+			{
+				public override bool SupportsValue { get { return false; } }
+
+				public override object GetValue(object o)
+				{
+					return MapTo(base.GetValue(o));
+				}
+
+				public override void SetValue(object o, object value)
+				{
+					base.SetValue(o, MapFrom(value));
+				}
+			}
+		}
+
+#endif
+	}
+}
+