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

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 //---------------------------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by BLToolkit template for T4.
4 // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
5 // </auto-generated>
6 //---------------------------------------------------------------------------------------------------
7 using System;
8 using System.Data.SqlTypes;
9 using System.IO;
10 using System.Xml;
11
12 using Convert = BLToolkit.Common.Convert;
13 #if !SILVERLIGHT
14 using System.Xml.Linq;
15 #endif
16
17 namespace BLToolkit.Mapping
18 {
19 public partial class MemberMapper
20 {
21
22 class SByteMapper : MemberMapper
23 {
24 SByte _nullValue;
25
26 public override bool IsNull (object o) { return false; }
27 public override void SetNull(object o) { MemberAccessor.SetSByte(o, _nullValue); }
28
29 public override void SetValue(object o, object value)
30 {
31 MemberAccessor.SetSByte(
32 o,
33 value is SByte ? (SByte)value :
34 value == null ? _nullValue : MappingSchema.ConvertToSByte(value));
35 }
36
37 public override void Init(MapMemberInfo mapMemberInfo)
38 {
39 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
40
41 _nullValue = Convert.ToSByte(mapMemberInfo.NullValue);
42
43 base.Init(mapMemberInfo);
44 }
45
46 public class Nullable : SByteMapper
47 {
48 public override bool IsNull(object o) { return GetSByte(o) == _nullValue; }
49
50 public override object GetValue(object o)
51 {
52 var value = MemberAccessor.GetSByte(o);
53 return value == _nullValue ? null : (object)value;
54 }
55 }
56 }
57
58 class Int16Mapper : MemberMapper
59 {
60 Int16 _nullValue;
61
62 public override bool IsNull (object o) { return false; }
63 public override void SetNull(object o) { MemberAccessor.SetInt16(o, _nullValue); }
64
65 public override void SetValue(object o, object value)
66 {
67 MemberAccessor.SetInt16(
68 o,
69 value is Int16 ? (Int16)value :
70 value == null ? _nullValue : MappingSchema.ConvertToInt16(value));
71 }
72
73 public override void Init(MapMemberInfo mapMemberInfo)
74 {
75 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
76
77 _nullValue = Convert.ToInt16(mapMemberInfo.NullValue);
78
79 base.Init(mapMemberInfo);
80 }
81
82 public class Nullable : Int16Mapper
83 {
84 public override bool IsNull(object o) { return GetInt16(o) == _nullValue; }
85
86 public override object GetValue(object o)
87 {
88 var value = MemberAccessor.GetInt16(o);
89 return value == _nullValue ? null : (object)value;
90 }
91 }
92 }
93
94 class Int32Mapper : MemberMapper
95 {
96 Int32 _nullValue;
97
98 public override bool IsNull (object o) { return false; }
99 public override void SetNull(object o) { MemberAccessor.SetInt32(o, _nullValue); }
100
101 public override void SetValue(object o, object value)
102 {
103 MemberAccessor.SetInt32(
104 o,
105 value is Int32 ? (Int32)value :
106 value == null ? _nullValue : MappingSchema.ConvertToInt32(value));
107 }
108
109 public override void Init(MapMemberInfo mapMemberInfo)
110 {
111 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
112
113 _nullValue = Convert.ToInt32(mapMemberInfo.NullValue);
114
115 base.Init(mapMemberInfo);
116 }
117
118 public class Nullable : Int32Mapper
119 {
120 public override bool IsNull(object o) { return GetInt32(o) == _nullValue; }
121
122 public override object GetValue(object o)
123 {
124 var value = MemberAccessor.GetInt32(o);
125 return value == _nullValue ? null : (object)value;
126 }
127 }
128 }
129
130 class Int64Mapper : MemberMapper
131 {
132 Int64 _nullValue;
133
134 public override bool IsNull (object o) { return false; }
135 public override void SetNull(object o) { MemberAccessor.SetInt64(o, _nullValue); }
136
137 public override void SetValue(object o, object value)
138 {
139 MemberAccessor.SetInt64(
140 o,
141 value is Int64 ? (Int64)value :
142 value == null ? _nullValue : MappingSchema.ConvertToInt64(value));
143 }
144
145 public override void Init(MapMemberInfo mapMemberInfo)
146 {
147 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
148
149 _nullValue = Convert.ToInt64(mapMemberInfo.NullValue);
150
151 base.Init(mapMemberInfo);
152 }
153
154 public class Nullable : Int64Mapper
155 {
156 public override bool IsNull(object o) { return GetInt64(o) == _nullValue; }
157
158 public override object GetValue(object o)
159 {
160 var value = MemberAccessor.GetInt64(o);
161 return value == _nullValue ? null : (object)value;
162 }
163 }
164 }
165
166 class ByteMapper : MemberMapper
167 {
168 Byte _nullValue;
169
170 public override bool IsNull (object o) { return false; }
171 public override void SetNull(object o) { MemberAccessor.SetByte(o, _nullValue); }
172
173 public override void SetValue(object o, object value)
174 {
175 MemberAccessor.SetByte(
176 o,
177 value is Byte ? (Byte)value :
178 value == null ? _nullValue : MappingSchema.ConvertToByte(value));
179 }
180
181 public override void Init(MapMemberInfo mapMemberInfo)
182 {
183 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
184
185 _nullValue = Convert.ToByte(mapMemberInfo.NullValue);
186
187 base.Init(mapMemberInfo);
188 }
189
190 public class Nullable : ByteMapper
191 {
192 public override bool IsNull(object o) { return GetByte(o) == _nullValue; }
193
194 public override object GetValue(object o)
195 {
196 var value = MemberAccessor.GetByte(o);
197 return value == _nullValue ? null : (object)value;
198 }
199 }
200 }
201
202 class UInt16Mapper : MemberMapper
203 {
204 UInt16 _nullValue;
205
206 public override bool IsNull (object o) { return false; }
207 public override void SetNull(object o) { MemberAccessor.SetUInt16(o, _nullValue); }
208
209 public override void SetValue(object o, object value)
210 {
211 MemberAccessor.SetUInt16(
212 o,
213 value is UInt16 ? (UInt16)value :
214 value == null ? _nullValue : MappingSchema.ConvertToUInt16(value));
215 }
216
217 public override void Init(MapMemberInfo mapMemberInfo)
218 {
219 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
220
221 _nullValue = Convert.ToUInt16(mapMemberInfo.NullValue);
222
223 base.Init(mapMemberInfo);
224 }
225
226 public class Nullable : UInt16Mapper
227 {
228 public override bool IsNull(object o) { return GetUInt16(o) == _nullValue; }
229
230 public override object GetValue(object o)
231 {
232 var value = MemberAccessor.GetUInt16(o);
233 return value == _nullValue ? null : (object)value;
234 }
235 }
236 }
237
238 class UInt32Mapper : MemberMapper
239 {
240 UInt32 _nullValue;
241
242 public override bool IsNull (object o) { return false; }
243 public override void SetNull(object o) { MemberAccessor.SetUInt32(o, _nullValue); }
244
245 public override void SetValue(object o, object value)
246 {
247 MemberAccessor.SetUInt32(
248 o,
249 value is UInt32 ? (UInt32)value :
250 value == null ? _nullValue : MappingSchema.ConvertToUInt32(value));
251 }
252
253 public override void Init(MapMemberInfo mapMemberInfo)
254 {
255 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
256
257 _nullValue = Convert.ToUInt32(mapMemberInfo.NullValue);
258
259 base.Init(mapMemberInfo);
260 }
261
262 public class Nullable : UInt32Mapper
263 {
264 public override bool IsNull(object o) { return GetUInt32(o) == _nullValue; }
265
266 public override object GetValue(object o)
267 {
268 var value = MemberAccessor.GetUInt32(o);
269 return value == _nullValue ? null : (object)value;
270 }
271 }
272 }
273
274 class UInt64Mapper : MemberMapper
275 {
276 UInt64 _nullValue;
277
278 public override bool IsNull (object o) { return false; }
279 public override void SetNull(object o) { MemberAccessor.SetUInt64(o, _nullValue); }
280
281 public override void SetValue(object o, object value)
282 {
283 MemberAccessor.SetUInt64(
284 o,
285 value is UInt64 ? (UInt64)value :
286 value == null ? _nullValue : MappingSchema.ConvertToUInt64(value));
287 }
288
289 public override void Init(MapMemberInfo mapMemberInfo)
290 {
291 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
292
293 _nullValue = Convert.ToUInt64(mapMemberInfo.NullValue);
294
295 base.Init(mapMemberInfo);
296 }
297
298 public class Nullable : UInt64Mapper
299 {
300 public override bool IsNull(object o) { return GetUInt64(o) == _nullValue; }
301
302 public override object GetValue(object o)
303 {
304 var value = MemberAccessor.GetUInt64(o);
305 return value == _nullValue ? null : (object)value;
306 }
307 }
308 }
309
310 class SingleMapper : MemberMapper
311 {
312 Single _nullValue;
313
314 public override bool IsNull (object o) { return false; }
315 public override void SetNull(object o) { MemberAccessor.SetSingle(o, _nullValue); }
316
317 public override void SetValue(object o, object value)
318 {
319 MemberAccessor.SetSingle(
320 o,
321 value is Single ? (Single)value :
322 value == null ? _nullValue : MappingSchema.ConvertToSingle(value));
323 }
324
325 public override void Init(MapMemberInfo mapMemberInfo)
326 {
327 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
328
329 _nullValue = Convert.ToSingle(mapMemberInfo.NullValue);
330
331 base.Init(mapMemberInfo);
332 }
333
334 public class Nullable : SingleMapper
335 {
336 public override bool IsNull(object o) { return GetSingle(o) == _nullValue; }
337
338 public override object GetValue(object o)
339 {
340 var value = MemberAccessor.GetSingle(o);
341 return value == _nullValue ? null : (object)value;
342 }
343 }
344 }
345
346 class DoubleMapper : MemberMapper
347 {
348 Double _nullValue;
349
350 public override bool IsNull (object o) { return false; }
351 public override void SetNull(object o) { MemberAccessor.SetDouble(o, _nullValue); }
352
353 public override void SetValue(object o, object value)
354 {
355 MemberAccessor.SetDouble(
356 o,
357 value is Double ? (Double)value :
358 value == null ? _nullValue : MappingSchema.ConvertToDouble(value));
359 }
360
361 public override void Init(MapMemberInfo mapMemberInfo)
362 {
363 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
364
365 _nullValue = Convert.ToDouble(mapMemberInfo.NullValue);
366
367 base.Init(mapMemberInfo);
368 }
369
370 public class Nullable : DoubleMapper
371 {
372 public override bool IsNull(object o) { return GetDouble(o) == _nullValue; }
373
374 public override object GetValue(object o)
375 {
376 var value = MemberAccessor.GetDouble(o);
377 return value == _nullValue ? null : (object)value;
378 }
379 }
380 }
381
382 class CharMapper : MemberMapper
383 {
384 Char _nullValue;
385
386 public override bool IsNull (object o) { return false; }
387 public override void SetNull(object o) { MemberAccessor.SetChar(o, _nullValue); }
388
389 public override void SetValue(object o, object value)
390 {
391 MemberAccessor.SetChar(
392 o,
393 value is Char ? (Char)value :
394 value == null ? _nullValue : MappingSchema.ConvertToChar(value));
395 }
396
397 public override void Init(MapMemberInfo mapMemberInfo)
398 {
399 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
400
401 _nullValue = Convert.ToChar(mapMemberInfo.NullValue);
402
403 base.Init(mapMemberInfo);
404 }
405
406 public class Nullable : CharMapper
407 {
408 public override bool IsNull(object o) { return GetChar(o) == _nullValue; }
409
410 public override object GetValue(object o)
411 {
412 var value = MemberAccessor.GetChar(o);
413 return value == _nullValue ? null : (object)value;
414 }
415 }
416 }
417
418 class BooleanMapper : MemberMapper
419 {
420 Boolean _nullValue;
421
422 public override bool IsNull (object o) { return false; }
423 public override void SetNull(object o) { MemberAccessor.SetBoolean(o, _nullValue); }
424
425 public override void SetValue(object o, object value)
426 {
427 MemberAccessor.SetBoolean(
428 o,
429 value is Boolean ? (Boolean)value :
430 value == null ? _nullValue : MappingSchema.ConvertToBoolean(value));
431 }
432
433 public override void Init(MapMemberInfo mapMemberInfo)
434 {
435 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
436
437 _nullValue = Convert.ToBoolean(mapMemberInfo.NullValue);
438
439 base.Init(mapMemberInfo);
440 }
441
442 public class Nullable : BooleanMapper
443 {
444 public override bool IsNull(object o) { return GetBoolean(o) == _nullValue; }
445
446 public override object GetValue(object o)
447 {
448 var value = MemberAccessor.GetBoolean(o);
449 return value == _nullValue ? null : (object)value;
450 }
451 }
452 }
453
454 class DateTimeMapper : MemberMapper
455 {
456 DateTime _nullValue;
457
458 public override bool IsNull (object o) { return false; }
459 public override void SetNull(object o) { MemberAccessor.SetDateTime(o, _nullValue); }
460
461 public override void SetValue(object o, object value)
462 {
463 MemberAccessor.SetDateTime(
464 o,
465 value is DateTime ? (DateTime)value :
466 value == null ? _nullValue : MappingSchema.ConvertToDateTime(value));
467 }
468
469 public override void Init(MapMemberInfo mapMemberInfo)
470 {
471 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
472
473 _nullValue = Convert.ToDateTime(mapMemberInfo.NullValue);
474
475 base.Init(mapMemberInfo);
476 }
477
478 public class Nullable : DateTimeMapper
479 {
480 public override bool IsNull(object o) { return GetDateTime(o) == _nullValue; }
481
482 public override object GetValue(object o)
483 {
484 var value = MemberAccessor.GetDateTime(o);
485 return value == _nullValue ? null : (object)value;
486 }
487 }
488 }
489
490 class DateTimeOffsetMapper : MemberMapper
491 {
492 DateTimeOffset _nullValue;
493
494 public override bool IsNull (object o) { return false; }
495 public override void SetNull(object o) { MemberAccessor.SetDateTimeOffset(o, _nullValue); }
496
497 public override void SetValue(object o, object value)
498 {
499 MemberAccessor.SetDateTimeOffset(
500 o,
501 value is DateTimeOffset ? (DateTimeOffset)value :
502 value == null ? _nullValue : MappingSchema.ConvertToDateTimeOffset(value));
503 }
504
505 public override void Init(MapMemberInfo mapMemberInfo)
506 {
507 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
508
509 _nullValue = Convert.ToDateTimeOffset(mapMemberInfo.NullValue);
510
511 base.Init(mapMemberInfo);
512 }
513
514 public class Nullable : DateTimeOffsetMapper
515 {
516 public override bool IsNull(object o) { return GetDateTimeOffset(o) == _nullValue; }
517
518 public override object GetValue(object o)
519 {
520 var value = MemberAccessor.GetDateTimeOffset(o);
521 return value == _nullValue ? null : (object)value;
522 }
523 }
524 }
525
526 class DecimalMapper : MemberMapper
527 {
528 Decimal _nullValue;
529
530 public override bool IsNull (object o) { return false; }
531 public override void SetNull(object o) { MemberAccessor.SetDecimal(o, _nullValue); }
532
533 public override void SetValue(object o, object value)
534 {
535 MemberAccessor.SetDecimal(
536 o,
537 value is Decimal ? (Decimal)value :
538 value == null ? _nullValue : MappingSchema.ConvertToDecimal(value));
539 }
540
541 public override void Init(MapMemberInfo mapMemberInfo)
542 {
543 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
544
545 _nullValue = Convert.ToDecimal(mapMemberInfo.NullValue);
546
547 base.Init(mapMemberInfo);
548 }
549
550 public class Nullable : DecimalMapper
551 {
552 public override bool IsNull(object o) { return GetDecimal(o) == _nullValue; }
553
554 public override object GetValue(object o)
555 {
556 var value = MemberAccessor.GetDecimal(o);
557 return value == _nullValue ? null : (object)value;
558 }
559 }
560 }
561
562 class GuidMapper : MemberMapper
563 {
564 Guid _nullValue;
565
566 public override bool IsNull (object o) { return false; }
567 public override void SetNull(object o) { MemberAccessor.SetGuid(o, _nullValue); }
568
569 public override void SetValue(object o, object value)
570 {
571 MemberAccessor.SetGuid(
572 o,
573 value is Guid ? (Guid)value :
574 value == null ? _nullValue : MappingSchema.ConvertToGuid(value));
575 }
576
577 public override void Init(MapMemberInfo mapMemberInfo)
578 {
579 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
580
581 if (mapMemberInfo.NullValue != null)
582 _nullValue = mapMemberInfo.NullValue is Guid ?
583 (Guid)mapMemberInfo.NullValue : new Guid(mapMemberInfo.NullValue.ToString());
584
585 base.Init(mapMemberInfo);
586 }
587
588 public class Nullable : GuidMapper
589 {
590 public override bool IsNull(object o) { return GetGuid(o) == _nullValue; }
591
592 public override object GetValue(object o)
593 {
594 var value = MemberAccessor.GetGuid(o);
595 return value == _nullValue ? null : (object)value;
596 }
597 }
598 }
599
600 class StreamMapper : MemberMapper
601 {
602 Stream _nullValue;
603
604 public override void SetValue(object o, object value)
605 {
606 MemberAccessor.SetValue(
607 o,
608 value is Stream ? value :
609 value == null ? _nullValue : MappingSchema.ConvertToStream(value));
610 }
611
612 public override void Init(MapMemberInfo mapMemberInfo)
613 {
614 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
615
616 if (mapMemberInfo.NullValue != null)
617 _nullValue = mapMemberInfo.MappingSchema.ConvertToStream(mapMemberInfo.NullValue);
618
619 base.Init(mapMemberInfo);
620 }
621
622 public class Nullable : StreamMapper
623 {
624 public override object GetValue(object o)
625 {
626 var value = MemberAccessor.GetValue(o);
627 return value == _nullValue ? null : (object)value;
628 }
629 }
630 }
631
632 class NullableSByteMapper : MemberMapper
633 {
634 public override bool IsNull (object o) { return GetNullableSByte(o) == null; }
635 public override void SetNull(object o) { MemberAccessor.SetNullableSByte(o, null); }
636
637 public override void SetValue(object o, object value)
638 {
639 MemberAccessor.SetNullableSByte(
640 o, value == null || value is SByte? (SByte?)value: MappingSchema.ConvertToNullableSByte(value));
641 }
642
643 public class Enum : NullableEnumMapper
644 {
645 public override void SetValue(object o, object value)
646 {
647 if (value != null)
648 {
649 var valueType = value.GetType();
650
651 if (valueType != MemberType)
652 {
653 if (valueType != UnderlyingType)
654 value = MappingSchema.ConvertToNullableSByte(value);
655
656 value = System.Enum.ToObject(MemberType, (SByte)value);
657 }
658 }
659
660 MemberAccessor.SetValue(o, value);
661 }
662 }
663 }
664
665 class NullableInt16Mapper : MemberMapper
666 {
667 public override bool IsNull (object o) { return GetNullableInt16(o) == null; }
668 public override void SetNull(object o) { MemberAccessor.SetNullableInt16(o, null); }
669
670 public override void SetValue(object o, object value)
671 {
672 MemberAccessor.SetNullableInt16(
673 o, value == null || value is Int16? (Int16?)value: MappingSchema.ConvertToNullableInt16(value));
674 }
675
676 public class Enum : NullableEnumMapper
677 {
678 public override void SetValue(object o, object value)
679 {
680 if (value != null)
681 {
682 var valueType = value.GetType();
683
684 if (valueType != MemberType)
685 {
686 if (valueType != UnderlyingType)
687 value = MappingSchema.ConvertToNullableInt16(value);
688
689 value = System.Enum.ToObject(MemberType, (Int16)value);
690 }
691 }
692
693 MemberAccessor.SetValue(o, value);
694 }
695 }
696 }
697
698 class NullableInt32Mapper : MemberMapper
699 {
700 public override bool IsNull (object o) { return GetNullableInt32(o) == null; }
701 public override void SetNull(object o) { MemberAccessor.SetNullableInt32(o, null); }
702
703 public override void SetValue(object o, object value)
704 {
705 MemberAccessor.SetNullableInt32(
706 o, value == null || value is Int32? (Int32?)value: MappingSchema.ConvertToNullableInt32(value));
707 }
708
709 public class Enum : NullableEnumMapper
710 {
711 public override void SetValue(object o, object value)
712 {
713 if (value != null)
714 {
715 var valueType = value.GetType();
716
717 if (valueType != MemberType)
718 {
719 if (valueType != UnderlyingType)
720 value = MappingSchema.ConvertToNullableInt32(value);
721
722 value = System.Enum.ToObject(MemberType, (Int32)value);
723 }
724 }
725
726 MemberAccessor.SetValue(o, value);
727 }
728 }
729 }
730
731 class NullableInt64Mapper : MemberMapper
732 {
733 public override bool IsNull (object o) { return GetNullableInt64(o) == null; }
734 public override void SetNull(object o) { MemberAccessor.SetNullableInt64(o, null); }
735
736 public override void SetValue(object o, object value)
737 {
738 MemberAccessor.SetNullableInt64(
739 o, value == null || value is Int64? (Int64?)value: MappingSchema.ConvertToNullableInt64(value));
740 }
741
742 public class Enum : NullableEnumMapper
743 {
744 public override void SetValue(object o, object value)
745 {
746 if (value != null)
747 {
748 var valueType = value.GetType();
749
750 if (valueType != MemberType)
751 {
752 if (valueType != UnderlyingType)
753 value = MappingSchema.ConvertToNullableInt64(value);
754
755 value = System.Enum.ToObject(MemberType, (Int64)value);
756 }
757 }
758
759 MemberAccessor.SetValue(o, value);
760 }
761 }
762 }
763
764 class NullableByteMapper : MemberMapper
765 {
766 public override bool IsNull (object o) { return GetNullableByte(o) == null; }
767 public override void SetNull(object o) { MemberAccessor.SetNullableByte(o, null); }
768
769 public override void SetValue(object o, object value)
770 {
771 MemberAccessor.SetNullableByte(
772 o, value == null || value is Byte? (Byte?)value: MappingSchema.ConvertToNullableByte(value));
773 }
774
775 public class Enum : NullableEnumMapper
776 {
777 public override void SetValue(object o, object value)
778 {
779 if (value != null)
780 {
781 var valueType = value.GetType();
782
783 if (valueType != MemberType)
784 {
785 if (valueType != UnderlyingType)
786 value = MappingSchema.ConvertToNullableByte(value);
787
788 value = System.Enum.ToObject(MemberType, (Byte)value);
789 }
790 }
791
792 MemberAccessor.SetValue(o, value);
793 }
794 }
795 }
796
797 class NullableUInt16Mapper : MemberMapper
798 {
799 public override bool IsNull (object o) { return GetNullableUInt16(o) == null; }
800 public override void SetNull(object o) { MemberAccessor.SetNullableUInt16(o, null); }
801
802 public override void SetValue(object o, object value)
803 {
804 MemberAccessor.SetNullableUInt16(
805 o, value == null || value is UInt16? (UInt16?)value: MappingSchema.ConvertToNullableUInt16(value));
806 }
807
808 public class Enum : NullableEnumMapper
809 {
810 public override void SetValue(object o, object value)
811 {
812 if (value != null)
813 {
814 var valueType = value.GetType();
815
816 if (valueType != MemberType)
817 {
818 if (valueType != UnderlyingType)
819 value = MappingSchema.ConvertToNullableUInt16(value);
820
821 value = System.Enum.ToObject(MemberType, (UInt16)value);
822 }
823 }
824
825 MemberAccessor.SetValue(o, value);
826 }
827 }
828 }
829
830 class NullableUInt32Mapper : MemberMapper
831 {
832 public override bool IsNull (object o) { return GetNullableUInt32(o) == null; }
833 public override void SetNull(object o) { MemberAccessor.SetNullableUInt32(o, null); }
834
835 public override void SetValue(object o, object value)
836 {
837 MemberAccessor.SetNullableUInt32(
838 o, value == null || value is UInt32? (UInt32?)value: MappingSchema.ConvertToNullableUInt32(value));
839 }
840
841 public class Enum : NullableEnumMapper
842 {
843 public override void SetValue(object o, object value)
844 {
845 if (value != null)
846 {
847 var valueType = value.GetType();
848
849 if (valueType != MemberType)
850 {
851 if (valueType != UnderlyingType)
852 value = MappingSchema.ConvertToNullableUInt32(value);
853
854 value = System.Enum.ToObject(MemberType, (UInt32)value);
855 }
856 }
857
858 MemberAccessor.SetValue(o, value);
859 }
860 }
861 }
862
863 class NullableUInt64Mapper : MemberMapper
864 {
865 public override bool IsNull (object o) { return GetNullableUInt64(o) == null; }
866 public override void SetNull(object o) { MemberAccessor.SetNullableUInt64(o, null); }
867
868 public override void SetValue(object o, object value)
869 {
870 MemberAccessor.SetNullableUInt64(
871 o, value == null || value is UInt64? (UInt64?)value: MappingSchema.ConvertToNullableUInt64(value));
872 }
873
874 public class Enum : NullableEnumMapper
875 {
876 public override void SetValue(object o, object value)
877 {
878 if (value != null)
879 {
880 var valueType = value.GetType();
881
882 if (valueType != MemberType)
883 {
884 if (valueType != UnderlyingType)
885 value = MappingSchema.ConvertToNullableUInt64(value);
886
887 value = System.Enum.ToObject(MemberType, (UInt64)value);
888 }
889 }
890
891 MemberAccessor.SetValue(o, value);
892 }
893 }
894 }
895
896 class NullableCharMapper : MemberMapper
897 {
898 public override bool IsNull (object o) { return GetNullableChar(o) == null; }
899 public override void SetNull(object o) { MemberAccessor.SetNullableChar(o, null); }
900
901 public override void SetValue(object o, object value)
902 {
903 MemberAccessor.SetNullableChar(
904 o, value == null || value is Char? (Char?)value: MappingSchema.ConvertToNullableChar(value));
905 }
906 }
907
908 class NullableDoubleMapper : MemberMapper
909 {
910 public override bool IsNull (object o) { return GetNullableDouble(o) == null; }
911 public override void SetNull(object o) { MemberAccessor.SetNullableDouble(o, null); }
912
913 public override void SetValue(object o, object value)
914 {
915 MemberAccessor.SetNullableDouble(
916 o, value == null || value is Double? (Double?)value: MappingSchema.ConvertToNullableDouble(value));
917 }
918 }
919
920 class NullableSingleMapper : MemberMapper
921 {
922 public override bool IsNull (object o) { return GetNullableSingle(o) == null; }
923 public override void SetNull(object o) { MemberAccessor.SetNullableSingle(o, null); }
924
925 public override void SetValue(object o, object value)
926 {
927 MemberAccessor.SetNullableSingle(
928 o, value == null || value is Single? (Single?)value: MappingSchema.ConvertToNullableSingle(value));
929 }
930 }
931
932 class NullableBooleanMapper : MemberMapper
933 {
934 public override bool IsNull (object o) { return GetNullableBoolean(o) == null; }
935 public override void SetNull(object o) { MemberAccessor.SetNullableBoolean(o, null); }
936
937 public override void SetValue(object o, object value)
938 {
939 MemberAccessor.SetNullableBoolean(
940 o, value == null || value is Boolean? (Boolean?)value: MappingSchema.ConvertToNullableBoolean(value));
941 }
942 }
943
944 class NullableDateTimeMapper : MemberMapper
945 {
946 public override bool IsNull (object o) { return GetNullableDateTime(o) == null; }
947 public override void SetNull(object o) { MemberAccessor.SetNullableDateTime(o, null); }
948
949 public override void SetValue(object o, object value)
950 {
951 MemberAccessor.SetNullableDateTime(
952 o, value == null || value is DateTime? (DateTime?)value: MappingSchema.ConvertToNullableDateTime(value));
953 }
954 }
955
956 class NullableDecimalMapper : MemberMapper
957 {
958 public override bool IsNull (object o) { return GetNullableDecimal(o) == null; }
959 public override void SetNull(object o) { MemberAccessor.SetNullableDecimal(o, null); }
960
961 public override void SetValue(object o, object value)
962 {
963 MemberAccessor.SetNullableDecimal(
964 o, value == null || value is Decimal? (Decimal?)value: MappingSchema.ConvertToNullableDecimal(value));
965 }
966 }
967
968 class NullableGuidMapper : MemberMapper
969 {
970 public override bool IsNull (object o) { return GetNullableGuid(o) == null; }
971 public override void SetNull(object o) { MemberAccessor.SetNullableGuid(o, null); }
972
973 public override void SetValue(object o, object value)
974 {
975 MemberAccessor.SetNullableGuid(
976 o, value == null || value is Guid? (Guid?)value: MappingSchema.ConvertToNullableGuid(value));
977 }
978 }
979
980 #if !SILVERLIGHT
981
982 class XmlReaderMapper : MemberMapper
983 {
984 XmlReader _nullValue;
985
986 public override void SetValue(object o, object value)
987 {
988 MemberAccessor.SetValue(
989 o,
990 value is XmlReader ? value :
991 value == null ? _nullValue : MappingSchema.ConvertToXmlReader(value));
992 }
993
994 public override void Init(MapMemberInfo mapMemberInfo)
995 {
996 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
997
998 if (mapMemberInfo.NullValue != null)
999 _nullValue = mapMemberInfo.MappingSchema.ConvertToXmlReader(mapMemberInfo.NullValue);
1000
1001 base.Init(mapMemberInfo);
1002 }
1003
1004 public class Nullable : XmlReaderMapper
1005 {
1006 public override object GetValue(object o)
1007 {
1008 var value = MemberAccessor.GetValue(o);
1009 return value == _nullValue ? null : (object)value;
1010 }
1011 }
1012 }
1013
1014 class XmlDocumentMapper : MemberMapper
1015 {
1016 XmlDocument _nullValue;
1017
1018 public override void SetValue(object o, object value)
1019 {
1020 MemberAccessor.SetValue(
1021 o,
1022 value is XmlDocument ? value :
1023 value == null ? _nullValue : MappingSchema.ConvertToXmlDocument(value));
1024 }
1025
1026 public override void Init(MapMemberInfo mapMemberInfo)
1027 {
1028 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
1029
1030 if (mapMemberInfo.NullValue != null)
1031 _nullValue = mapMemberInfo.MappingSchema.ConvertToXmlDocument(mapMemberInfo.NullValue);
1032
1033 base.Init(mapMemberInfo);
1034 }
1035
1036 public class Nullable : XmlDocumentMapper
1037 {
1038 public override object GetValue(object o)
1039 {
1040 var value = MemberAccessor.GetValue(o);
1041 return value == _nullValue ? null : (object)value;
1042 }
1043 }
1044 }
1045
1046 class XElementMapper : MemberMapper
1047 {
1048 XElement _nullValue;
1049
1050 public override void SetValue(object o, object value)
1051 {
1052 MemberAccessor.SetValue(
1053 o,
1054 value is XElement ? value :
1055 value == null ? _nullValue : MappingSchema.ConvertToXElement(value));
1056 }
1057
1058 public override void Init(MapMemberInfo mapMemberInfo)
1059 {
1060 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
1061
1062 if (mapMemberInfo.NullValue != null)
1063 _nullValue = mapMemberInfo.MappingSchema.ConvertToXElement(mapMemberInfo.NullValue);
1064
1065 base.Init(mapMemberInfo);
1066 }
1067
1068 public class Nullable : XElementMapper
1069 {
1070 public override object GetValue(object o)
1071 {
1072 var value = MemberAccessor.GetValue(o);
1073 return value == _nullValue ? null : (object)value;
1074 }
1075 }
1076 }
1077
1078 class SqlByteMapper : MemberMapper
1079 {
1080 public override bool IsNull (object o) { return GetSqlByte(o).IsNull; }
1081 public override void SetNull(object o) { MemberAccessor.SetSqlByte(o, SqlByte.Null); }
1082
1083 public override object GetValue(object o)
1084 {
1085 var value = MemberAccessor.GetSqlByte(o);
1086 return value.IsNull? null: (object)value.Value;
1087 }
1088
1089 public override void SetValue(object o, object value)
1090 {
1091 MemberAccessor.SetSqlByte(
1092 o, value is SqlByte? (SqlByte)value: MappingSchema.ConvertToSqlByte(value));
1093 }
1094
1095 public class Default : SqlByteMapper
1096 {
1097 public override bool SupportsValue { get { return false; } }
1098
1099 public override object GetValue(object o)
1100 {
1101 return MapTo(base.GetValue(o));
1102 }
1103
1104 public override void SetValue(object o, object value)
1105 {
1106 base.SetValue(o, MapFrom(value));
1107 }
1108 }
1109 }
1110
1111 class SqlInt16Mapper : MemberMapper
1112 {
1113 public override bool IsNull (object o) { return GetSqlInt16(o).IsNull; }
1114 public override void SetNull(object o) { MemberAccessor.SetSqlInt16(o, SqlInt16.Null); }
1115
1116 public override object GetValue(object o)
1117 {
1118 var value = MemberAccessor.GetSqlInt16(o);
1119 return value.IsNull? null: (object)value.Value;
1120 }
1121
1122 public override void SetValue(object o, object value)
1123 {
1124 MemberAccessor.SetSqlInt16(
1125 o, value is SqlInt16? (SqlInt16)value: MappingSchema.ConvertToSqlInt16(value));
1126 }
1127
1128 public class Default : SqlInt16Mapper
1129 {
1130 public override bool SupportsValue { get { return false; } }
1131
1132 public override object GetValue(object o)
1133 {
1134 return MapTo(base.GetValue(o));
1135 }
1136
1137 public override void SetValue(object o, object value)
1138 {
1139 base.SetValue(o, MapFrom(value));
1140 }
1141 }
1142 }
1143
1144 class SqlInt32Mapper : MemberMapper
1145 {
1146 public override bool IsNull (object o) { return GetSqlInt32(o).IsNull; }
1147 public override void SetNull(object o) { MemberAccessor.SetSqlInt32(o, SqlInt32.Null); }
1148
1149 public override object GetValue(object o)
1150 {
1151 var value = MemberAccessor.GetSqlInt32(o);
1152 return value.IsNull? null: (object)value.Value;
1153 }
1154
1155 public override void SetValue(object o, object value)
1156 {
1157 MemberAccessor.SetSqlInt32(
1158 o, value is SqlInt32? (SqlInt32)value: MappingSchema.ConvertToSqlInt32(value));
1159 }
1160
1161 public class Default : SqlInt32Mapper
1162 {
1163 public override bool SupportsValue { get { return false; } }
1164
1165 public override object GetValue(object o)
1166 {
1167 return MapTo(base.GetValue(o));
1168 }
1169
1170 public override void SetValue(object o, object value)
1171 {
1172 base.SetValue(o, MapFrom(value));
1173 }
1174 }
1175 }
1176
1177 class SqlInt64Mapper : MemberMapper
1178 {
1179 public override bool IsNull (object o) { return GetSqlInt64(o).IsNull; }
1180 public override void SetNull(object o) { MemberAccessor.SetSqlInt64(o, SqlInt64.Null); }
1181
1182 public override object GetValue(object o)
1183 {
1184 var value = MemberAccessor.GetSqlInt64(o);
1185 return value.IsNull? null: (object)value.Value;
1186 }
1187
1188 public override void SetValue(object o, object value)
1189 {
1190 MemberAccessor.SetSqlInt64(
1191 o, value is SqlInt64? (SqlInt64)value: MappingSchema.ConvertToSqlInt64(value));
1192 }
1193
1194 public class Default : SqlInt64Mapper
1195 {
1196 public override bool SupportsValue { get { return false; } }
1197
1198 public override object GetValue(object o)
1199 {
1200 return MapTo(base.GetValue(o));
1201 }
1202
1203 public override void SetValue(object o, object value)
1204 {
1205 base.SetValue(o, MapFrom(value));
1206 }
1207 }
1208 }
1209
1210 class SqlSingleMapper : MemberMapper
1211 {
1212 public override bool IsNull (object o) { return GetSqlSingle(o).IsNull; }
1213 public override void SetNull(object o) { MemberAccessor.SetSqlSingle(o, SqlSingle.Null); }
1214
1215 public override object GetValue(object o)
1216 {
1217 var value = MemberAccessor.GetSqlSingle(o);
1218 return value.IsNull? null: (object)value.Value;
1219 }
1220
1221 public override void SetValue(object o, object value)
1222 {
1223 MemberAccessor.SetSqlSingle(
1224 o, value is SqlSingle? (SqlSingle)value: MappingSchema.ConvertToSqlSingle(value));
1225 }
1226
1227 public class Default : SqlSingleMapper
1228 {
1229 public override bool SupportsValue { get { return false; } }
1230
1231 public override object GetValue(object o)
1232 {
1233 return MapTo(base.GetValue(o));
1234 }
1235
1236 public override void SetValue(object o, object value)
1237 {
1238 base.SetValue(o, MapFrom(value));
1239 }
1240 }
1241 }
1242
1243 class SqlBooleanMapper : MemberMapper
1244 {
1245 public override bool IsNull (object o) { return GetSqlBoolean(o).IsNull; }
1246 public override void SetNull(object o) { MemberAccessor.SetSqlBoolean(o, SqlBoolean.Null); }
1247
1248 public override object GetValue(object o)
1249 {
1250 var value = MemberAccessor.GetSqlBoolean(o);
1251 return value.IsNull? null: (object)value.Value;
1252 }
1253
1254 public override void SetValue(object o, object value)
1255 {
1256 MemberAccessor.SetSqlBoolean(
1257 o, value is SqlBoolean? (SqlBoolean)value: MappingSchema.ConvertToSqlBoolean(value));
1258 }
1259
1260 public class Default : SqlBooleanMapper
1261 {
1262 public override bool SupportsValue { get { return false; } }
1263
1264 public override object GetValue(object o)
1265 {
1266 return MapTo(base.GetValue(o));
1267 }
1268
1269 public override void SetValue(object o, object value)
1270 {
1271 base.SetValue(o, MapFrom(value));
1272 }
1273 }
1274 }
1275
1276 class SqlDoubleMapper : MemberMapper
1277 {
1278 public override bool IsNull (object o) { return GetSqlDouble(o).IsNull; }
1279 public override void SetNull(object o) { MemberAccessor.SetSqlDouble(o, SqlDouble.Null); }
1280
1281 public override object GetValue(object o)
1282 {
1283 var value = MemberAccessor.GetSqlDouble(o);
1284 return value.IsNull? null: (object)value.Value;
1285 }
1286
1287 public override void SetValue(object o, object value)
1288 {
1289 MemberAccessor.SetSqlDouble(
1290 o, value is SqlDouble? (SqlDouble)value: MappingSchema.ConvertToSqlDouble(value));
1291 }
1292
1293 public class Default : SqlDoubleMapper
1294 {
1295 public override bool SupportsValue { get { return false; } }
1296
1297 public override object GetValue(object o)
1298 {
1299 return MapTo(base.GetValue(o));
1300 }
1301
1302 public override void SetValue(object o, object value)
1303 {
1304 base.SetValue(o, MapFrom(value));
1305 }
1306 }
1307 }
1308
1309 class SqlDateTimeMapper : MemberMapper
1310 {
1311 public override bool IsNull (object o) { return GetSqlDateTime(o).IsNull; }
1312 public override void SetNull(object o) { MemberAccessor.SetSqlDateTime(o, SqlDateTime.Null); }
1313
1314 public override object GetValue(object o)
1315 {
1316 var value = MemberAccessor.GetSqlDateTime(o);
1317 return value.IsNull? null: (object)value.Value;
1318 }
1319
1320 public override void SetValue(object o, object value)
1321 {
1322 MemberAccessor.SetSqlDateTime(
1323 o, value is SqlDateTime? (SqlDateTime)value: MappingSchema.ConvertToSqlDateTime(value));
1324 }
1325
1326 public class Default : SqlDateTimeMapper
1327 {
1328 public override bool SupportsValue { get { return false; } }
1329
1330 public override object GetValue(object o)
1331 {
1332 return MapTo(base.GetValue(o));
1333 }
1334
1335 public override void SetValue(object o, object value)
1336 {
1337 base.SetValue(o, MapFrom(value));
1338 }
1339 }
1340 }
1341
1342 class SqlDecimalMapper : MemberMapper
1343 {
1344 public override bool IsNull (object o) { return GetSqlDecimal(o).IsNull; }
1345 public override void SetNull(object o) { MemberAccessor.SetSqlDecimal(o, SqlDecimal.Null); }
1346
1347 public override object GetValue(object o)
1348 {
1349 var value = MemberAccessor.GetSqlDecimal(o);
1350 return value.IsNull? null: (object)value.Value;
1351 }
1352
1353 public override void SetValue(object o, object value)
1354 {
1355 MemberAccessor.SetSqlDecimal(
1356 o, value is SqlDecimal? (SqlDecimal)value: MappingSchema.ConvertToSqlDecimal(value));
1357 }
1358
1359 public class Default : SqlDecimalMapper
1360 {
1361 public override bool SupportsValue { get { return false; } }
1362
1363 public override object GetValue(object o)
1364 {
1365 return MapTo(base.GetValue(o));
1366 }
1367
1368 public override void SetValue(object o, object value)
1369 {
1370 base.SetValue(o, MapFrom(value));
1371 }
1372 }
1373 }
1374
1375 class SqlMoneyMapper : MemberMapper
1376 {
1377 public override bool IsNull (object o) { return GetSqlMoney(o).IsNull; }
1378 public override void SetNull(object o) { MemberAccessor.SetSqlMoney(o, SqlMoney.Null); }
1379
1380 public override object GetValue(object o)
1381 {
1382 var value = MemberAccessor.GetSqlMoney(o);
1383 return value.IsNull? null: (object)value.Value;
1384 }
1385
1386 public override void SetValue(object o, object value)
1387 {
1388 MemberAccessor.SetSqlMoney(
1389 o, value is SqlMoney? (SqlMoney)value: MappingSchema.ConvertToSqlMoney(value));
1390 }
1391
1392 public class Default : SqlMoneyMapper
1393 {
1394 public override bool SupportsValue { get { return false; } }
1395
1396 public override object GetValue(object o)
1397 {
1398 return MapTo(base.GetValue(o));
1399 }
1400
1401 public override void SetValue(object o, object value)
1402 {
1403 base.SetValue(o, MapFrom(value));
1404 }
1405 }
1406 }
1407
1408 class SqlGuidMapper : MemberMapper
1409 {
1410 public override bool IsNull (object o) { return GetSqlGuid(o).IsNull; }
1411 public override void SetNull(object o) { MemberAccessor.SetSqlGuid(o, SqlGuid.Null); }
1412
1413 public override object GetValue(object o)
1414 {
1415 var value = MemberAccessor.GetSqlGuid(o);
1416 return value.IsNull? null: (object)value.Value;
1417 }
1418
1419 public override void SetValue(object o, object value)
1420 {
1421 MemberAccessor.SetSqlGuid(
1422 o, value is SqlGuid? (SqlGuid)value: MappingSchema.ConvertToSqlGuid(value));
1423 }
1424
1425 public class Default : SqlGuidMapper
1426 {
1427 public override bool SupportsValue { get { return false; } }
1428
1429 public override object GetValue(object o)
1430 {
1431 return MapTo(base.GetValue(o));
1432 }
1433
1434 public override void SetValue(object o, object value)
1435 {
1436 base.SetValue(o, MapFrom(value));
1437 }
1438 }
1439 }
1440
1441 class SqlStringMapper : MemberMapper
1442 {
1443 public override bool IsNull (object o) { return GetSqlString(o).IsNull; }
1444 public override void SetNull(object o) { MemberAccessor.SetSqlString(o, SqlString.Null); }
1445
1446 public override object GetValue(object o)
1447 {
1448 var value = MemberAccessor.GetSqlString(o);
1449 return value.IsNull? null: (object)value.Value;
1450 }
1451
1452 public override void SetValue(object o, object value)
1453 {
1454 MemberAccessor.SetSqlString(
1455 o, value is SqlString? (SqlString)value: MappingSchema.ConvertToSqlString(value));
1456 }
1457
1458 public class Default : SqlStringMapper
1459 {
1460 public override bool SupportsValue { get { return false; } }
1461
1462 public override object GetValue(object o)
1463 {
1464 return MapTo(base.GetValue(o));
1465 }
1466
1467 public override void SetValue(object o, object value)
1468 {
1469 base.SetValue(o, MapFrom(value));
1470 }
1471 }
1472 }
1473
1474 #endif
1475 }
1476 }
1477