comparison Source/Mapping/ObjectMapper.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 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Data.SqlTypes;
5 using System.Diagnostics;
6 using System.Diagnostics.CodeAnalysis;
7 using System.Globalization;
8
9 namespace BLToolkit.Mapping
10 {
11 using DataAccess;
12 using Reflection;
13 using Reflection.Extension;
14 using Reflection.MetadataProvider;
15
16 [DebuggerDisplay("Type = {TypeAccessor.Type}, OriginalType = {TypeAccessor.OriginalType}")]
17 public class ObjectMapper : MapDataSourceDestinationBase, IEnumerable<MemberMapper>
18 {
19 #region Protected Members
20
21 protected virtual MemberMapper CreateMemberMapper(MapMemberInfo mapMemberInfo)
22 {
23 if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
24
25 MemberMapper mm = null;
26
27 var attr = mapMemberInfo.MemberAccessor.GetAttribute<MemberMapperAttribute>();
28
29 MemberExtension ext;
30
31 if (_extension != null && _extension.Members.TryGetValue(mapMemberInfo.MemberName,out ext))
32 {
33 AttributeExtensionCollection attrExt;
34
35 if (ext.Attributes.TryGetValue("MemberMapper", out attrExt))
36 {
37 attr = new MemberMapperAttribute((Type)attrExt[0].Values["MemberMapperType"]);
38 }
39 }
40
41 if (attr == null)
42 {
43 var attrs = TypeHelper.GetAttributes(mapMemberInfo.Type, typeof(MemberMapperAttribute));
44
45 foreach (MemberMapperAttribute a in attrs)
46 {
47 if (a.MemberType == null)
48 {
49 mm = a.MemberMapper;
50 break;
51 }
52 }
53 }
54 else
55 mm = attr.MemberMapper;
56
57 if (mm == null)
58 {
59 var attrs = TypeHelper.GetAttributes(
60 mapMemberInfo.MemberAccessor.MemberInfo.DeclaringType, typeof(MemberMapperAttribute));
61
62 foreach (MemberMapperAttribute a in attrs)
63 {
64 if (a.MemberType == mapMemberInfo.Type)
65 {
66 mm = a.MemberMapper;
67 break;
68 }
69 }
70 }
71
72 if (mm == null)
73 mm = MemberMapper.CreateMemberMapper(mapMemberInfo);
74
75 mm.Init(mapMemberInfo);
76
77 return mm;
78 }
79
80 [SuppressMessage("Microsoft.Performance", "CA1807:AvoidUnnecessaryStringCreation", MessageId = "stack1")]
81 protected virtual void Add(MemberMapper memberMapper)
82 {
83 if (memberMapper == null) throw new ArgumentNullException("memberMapper");
84
85 memberMapper.SetOrdinal(_members.Count);
86
87 _members .Add(memberMapper);
88 _nameToMember .Add(memberMapper.Name.ToLower(), memberMapper);
89 _memberNameToMember.Add(memberMapper.MemberName, memberMapper);
90 }
91
92 protected virtual MetadataProviderBase CreateMetadataProvider()
93 {
94 return MetadataProviderBase.CreateProvider();
95 }
96
97 #endregion
98
99 #region Public Members
100
101 private readonly List<MemberMapper> _members = new List<MemberMapper>();
102 public MemberMapper this[int index]
103 {
104 get { return _members[index]; }
105 }
106
107 readonly List<Association> _associations = new List<Association>();
108 public List<Association> Associations
109 {
110 get { return _associations; }
111 }
112
113 readonly List<InheritanceMappingAttribute> _inheritanceMapping = new List<InheritanceMappingAttribute>();
114 public List<InheritanceMappingAttribute> InheritanceMapping
115 {
116 get { return _inheritanceMapping; }
117 }
118
119 [CLSCompliant(false)]
120 protected TypeExtension _extension;
121 public TypeExtension Extension
122 {
123 get { return _extension; }
124 set { _extension = value; }
125 }
126
127 private MetadataProviderBase _metadataProvider;
128 public MetadataProviderBase MetadataProvider
129 {
130 get { return _metadataProvider ?? (_metadataProvider = CreateMetadataProvider()); }
131 set { _metadataProvider = value; }
132 }
133
134 private string[] _fieldNames;
135 public string[] FieldNames
136 {
137 get
138 {
139 if (_fieldNames == null)
140 {
141 _fieldNames = new string[_members.Count];
142
143 for (var i = 0; i < _fieldNames.Length; i++)
144 {
145 _fieldNames[i] = _members[i].Name;
146 }
147 }
148
149 return _fieldNames;
150 }
151 }
152
153 private readonly Dictionary<string,MemberMapper> _nameToMember = new Dictionary<string,MemberMapper>();
154 private readonly Dictionary<string,MemberMapper> _memberNameToMember = new Dictionary<string,MemberMapper>();
155 public MemberMapper this[string name]
156 {
157 get
158 {
159 if (name == null) throw new ArgumentNullException("name");
160
161 lock (_nameToMember)
162 {
163 MemberMapper mm;
164
165 if (!_nameToMember.TryGetValue(name, out mm))
166 {
167 if (!_nameToMember.TryGetValue(name.ToLower(CultureInfo.CurrentCulture), out mm))
168 {
169 lock (_memberNameToMember)
170 if (_memberNameToMember.ContainsKey(name) || _memberNameToMember.ContainsKey(name.ToLower(CultureInfo.CurrentCulture)))
171 return null;
172
173 mm = GetComplexMapper(name, name);
174
175 if (mm != null)
176 {
177 if (_members.Contains(mm))
178 {
179 //throw new MappingException(string.Format(
180 // "Wrong mapping field name: '{0}', type: '{1}'. Use field name '{2}' instead.",
181 // name, _typeAccessor.OriginalType.Name, mm.Name));
182 return null;
183 }
184
185 Add(mm);
186 }
187 }
188 else
189 _nameToMember.Add(name, mm);
190 }
191
192 return mm;
193 }
194 }
195 }
196
197 public MemberMapper this[string name, bool byPropertyName]
198 {
199 get
200 {
201 MemberMapper mm;
202
203 if (byPropertyName)
204 lock (_memberNameToMember)
205 return _memberNameToMember.TryGetValue(name, out mm) ? mm : null;
206
207 return this[name];
208 }
209 }
210
211 public int GetOrdinal(string name, bool byPropertyName)
212 {
213 if (byPropertyName)
214 {
215 for (var i = 0; i < _members.Count; ++i)
216 if (_members[i].MemberName == name)
217 return i;
218
219 return -1;
220 }
221
222 return GetOrdinal(name);
223 }
224
225 [CLSCompliant(false)]
226 protected TypeAccessor _typeAccessor;
227 public TypeAccessor TypeAccessor
228 {
229 get { return _typeAccessor; }
230 }
231
232 private MappingSchema _mappingSchema;
233 public MappingSchema MappingSchema
234 {
235 get { return _mappingSchema; }
236 }
237
238 #endregion
239
240 #region Init Mapper
241
242 public virtual void Init(MappingSchema mappingSchema, Type type)
243 {
244 if (type == null) throw new ArgumentNullException("type");
245
246 _typeAccessor = TypeAccessor.GetAccessor(type);
247 _mappingSchema = mappingSchema;
248 _extension = TypeExtension.GetTypeExtension(_typeAccessor.OriginalType, mappingSchema.Extensions);
249
250 _inheritanceMapping.AddRange(GetInheritanceMapping());
251
252 foreach (MemberAccessor ma in _typeAccessor)
253 {
254 var a = GetAssociation(ma);
255
256 if (a != null)
257 {
258 _associations.Add(a);
259 continue;
260 }
261
262 if (GetMapIgnore(ma))
263 continue;
264
265 var mapFieldAttr = GetMapField(ma); // ma.GetAttribute<MapFieldAttribute>();
266
267 if (mapFieldAttr == null || (mapFieldAttr.OrigName == null && mapFieldAttr.Format == null))
268 {
269 var mi = new MapMemberInfo();
270
271 var dbTypeAttribute = GetDbType(ma); // ma.GetAttribute<DbTypeAttribute>();
272
273 if (dbTypeAttribute != null)
274 {
275 mi.DbType = dbTypeAttribute.DbType;
276 mi.IsDbTypeSet = true;
277
278 if (dbTypeAttribute.Size != null)
279 {
280 mi.DbSize = dbTypeAttribute.Size.Value;
281 mi.IsDbSizeSet = true;
282 }
283 }
284
285 mi.MemberAccessor = ma;
286 mi.Type = ma.Type;
287 mi.MappingSchema = mappingSchema;
288 mi.MemberExtension = _extension[ma.Name];
289 mi.Name = GetFieldName (ma);
290 mi.MemberName = ma.Name;
291 mi.Storage = GetFieldStorage(ma);
292 mi.IsInheritanceDiscriminator = GetInheritanceDiscriminator(ma);
293 mi.Trimmable = GetTrimmable (ma);
294 mi.SqlIgnore = GetSqlIgnore (ma);
295 mi.MapValues = GetMapValues (ma);
296 mi.DefaultValue = GetDefaultValue(ma);
297 mi.Nullable = GetNullable (ma);
298 mi.NullValue = GetNullValue (ma, mi.Nullable);
299
300 Add(CreateMemberMapper(mi));
301 }
302 else if (mapFieldAttr.OrigName != null)
303 {
304 EnsureMapper(mapFieldAttr.MapName, ma.Name + "." + mapFieldAttr.OrigName);
305 }
306 else //if (mapFieldAttr.Format != null)
307 {
308 foreach (MemberMapper inner in _mappingSchema.GetObjectMapper(ma.Type))
309 EnsureMapper(string.Format(mapFieldAttr.Format, inner.Name), ma.Name + "." + inner.MemberName);
310 }
311 }
312
313 foreach (var ae in _extension.Attributes["MapField"])
314 {
315 var mapName = (string)ae["MapName"];
316 var origName = (string)ae["OrigName"];
317
318 if (mapName == null || origName == null)
319 throw new MappingException(string.Format(
320 "Type '{0}' has invalid extension. MapField MapName='{1}' OrigName='{2}'.",
321 type.FullName, mapName, origName));
322
323 EnsureMapper(mapName, origName);
324 }
325
326 MetadataProvider.EnsureMapper(TypeAccessor, MappingSchema, EnsureMapper);
327 }
328
329 private MemberMapper EnsureMapper(string mapName, string origName)
330 {
331 var mm = this[mapName];
332
333 if (mm == null)
334 {
335 var name = mapName.ToLower();
336
337 foreach (var m in _members)
338 {
339 if (m.MemberAccessor.Name.ToLower() == name)
340 {
341 _nameToMember.Add(name, m);
342 return m;
343 }
344 }
345
346 mm = GetComplexMapper(mapName, origName);
347
348 if (mm != null)
349 Add(mm);
350 }
351
352 return mm;
353 }
354
355 private readonly Dictionary<string,MemberMapper> _nameToComplexMapper = new Dictionary<string,MemberMapper>();
356
357 [SuppressMessage("Microsoft.Performance", "CA1807:AvoidUnnecessaryStringCreation", MessageId = "stack0")]
358 [SuppressMessage("Microsoft.Performance", "CA1807:AvoidUnnecessaryStringCreation", MessageId = "origName")]
359 protected MemberMapper GetComplexMapper(string mapName, string origName)
360 {
361 if (origName == null) throw new ArgumentNullException("origName");
362
363 var name = origName.ToLower();
364 var idx = origName.IndexOf('.');
365
366 lock (_nameToComplexMapper)
367 {
368 MemberMapper mm;
369
370 if (_nameToComplexMapper.TryGetValue(name, out mm))
371 return mm;
372
373 if (idx > 0)
374 {
375 name = name.Substring(0, idx);
376
377 foreach (MemberAccessor ma in TypeAccessor)
378 {
379 if (ma.Name.Length == name.Length && ma.Name.ToLower() == name)
380 {
381 var om = MappingSchema.GetObjectMapper(ma.Type);
382
383 if (om != null)
384 {
385 mm = om.GetComplexMapper(mapName, origName.Substring(idx + 1));
386
387 if (mm != null)
388 {
389 var mi = new MapMemberInfo
390 {
391 MemberAccessor = ma,
392 ComplexMemberAccessor = mm.ComplexMemberAccessor,
393 Type = mm.Type,
394 MappingSchema = MappingSchema,
395 Name = mapName,
396 MemberName = origName
397 };
398
399 var mapper = new MemberMapper.ComplexMapper(mm);
400 var key = origName.ToLower();
401
402 mapper.Init(mi);
403
404 if (_nameToComplexMapper.ContainsKey(key))
405 _nameToComplexMapper[key] = mapper;
406 else
407 _nameToComplexMapper.Add(key, mapper);
408
409 return mapper;
410 }
411 }
412
413 break;
414 }
415 }
416 }
417 else
418 {
419 foreach (var m in _members)
420 if (m.MemberAccessor.Name.Length == name.Length && m.MemberAccessor.Name.ToLower() == name)
421 {
422 if (_nameToComplexMapper.ContainsKey(name))
423 _nameToComplexMapper[name] = m;
424 else
425 _nameToComplexMapper.Add(name, m);
426
427 return m;
428 }
429 }
430
431 // Under some conditions, this way lead to memory leaks.
432 // In other hand, shaking mappers up every time lead to performance loss.
433 // So we cache failed requests.
434 // If this optimization is a memory leak for you, just comment out next line.
435 //
436 if (_nameToComplexMapper.ContainsKey(name))
437 _nameToComplexMapper[name] = null;
438 else
439 _nameToComplexMapper.Add(name, null);
440
441 return null;
442 }
443
444 }
445
446 private MapValue[] GetMapValues(MemberAccessor member)
447 {
448 bool isSet;
449
450 var values = MetadataProvider.GetMapValues(Extension, member, out isSet);
451
452 return isSet? values: _mappingSchema.GetMapValues(member.Type);
453 }
454
455 protected virtual object GetDefaultValue(MemberAccessor memberAccessor)
456 {
457 bool isSet;
458
459 var value = MetadataProvider.GetDefaultValue(MappingSchema, Extension, memberAccessor, out isSet);
460
461 return isSet? value: _mappingSchema.GetDefaultValue(memberAccessor.Type);
462 }
463
464 protected virtual bool GetNullable(MemberAccessor memberAccessor)
465 {
466 bool isSet;
467 return MetadataProvider.GetNullable(MappingSchema, Extension, memberAccessor, out isSet);
468 }
469
470 protected virtual bool GetLazyInstance(MemberAccessor memberAccessor)
471 {
472 bool isSet;
473 return MetadataProvider.GetLazyInstance(MappingSchema, Extension, memberAccessor, out isSet);
474 }
475
476 protected virtual bool GetMapIgnore(MemberAccessor memberAccessor)
477 {
478 bool isSet;
479 return MetadataProvider.GetMapIgnore(Extension, memberAccessor, out isSet);
480 }
481
482 protected virtual MapFieldAttribute GetMapField(MemberAccessor memberAccessor)
483 {
484 bool isSet;
485 return MetadataProvider.GetMapField(Extension, memberAccessor, out isSet);
486 }
487
488 [CLSCompliant(false)]
489 protected virtual DbTypeAttribute GetDbType(MemberAccessor memberAccessor)
490 {
491 bool isSet;
492 return MetadataProvider.GetDbType(Extension, memberAccessor, out isSet);
493 }
494
495 protected virtual PrimaryKeyAttribute GetPrimaryKey(MemberAccessor memberAccessor)
496 {
497 bool isSet;
498 return MetadataProvider.GetPrimaryKey(Extension, memberAccessor, out isSet);
499 }
500
501 protected virtual bool GetSqlIgnore(MemberAccessor memberAccessor)
502 {
503 bool isSet;
504 return MetadataProvider.GetSqlIgnore(Extension, memberAccessor, out isSet);
505 }
506
507 protected virtual string GetFieldName(MemberAccessor memberAccessor)
508 {
509 bool isSet;
510 return MetadataProvider.GetFieldName(Extension, memberAccessor, out isSet);
511 }
512
513 protected virtual string GetFieldStorage(MemberAccessor memberAccessor)
514 {
515 bool isSet;
516 return MetadataProvider.GetFieldStorage(Extension, memberAccessor, out isSet);
517 }
518
519 protected virtual bool GetInheritanceDiscriminator(MemberAccessor memberAccessor)
520 {
521 bool isSet;
522 return MetadataProvider.GetInheritanceDiscriminator(Extension, memberAccessor, out isSet);
523 }
524
525 protected virtual bool GetTrimmable(MemberAccessor memberAccessor)
526 {
527 bool isSet;
528 return MetadataProvider.GetTrimmable(Extension, memberAccessor, out isSet);
529 }
530
531 protected virtual object GetNullValue(MemberAccessor memberAccessor, bool isNullable)
532 {
533 if (isNullable)
534 {
535 bool isSet;
536 return MetadataProvider.GetNullValue(MappingSchema, Extension, memberAccessor, out isSet);
537 }
538
539 return MappingSchema.GetNullValue(memberAccessor.Type);
540 }
541
542 protected virtual Association GetAssociation(MemberAccessor memberAccessor)
543 {
544 return MetadataProvider.GetAssociation(Extension, memberAccessor);
545 }
546
547 protected virtual InheritanceMappingAttribute[] GetInheritanceMapping()
548 {
549 return MetadataProvider.GetInheritanceMapping(_typeAccessor.OriginalType, Extension);
550 }
551
552 #endregion
553
554 #region IObjectMappper Members
555
556 public virtual object CreateInstance()
557 {
558 return _typeAccessor.CreateInstanceEx();
559 }
560
561 public virtual object CreateInstance(InitContext context)
562 {
563 return _typeAccessor.CreateInstanceEx(context);
564 }
565
566 #endregion
567
568 #region IMapDataSource Members
569
570 public override int Count
571 {
572 get { return _members.Count; }
573 }
574
575 public override Type GetFieldType(int index)
576 {
577 return _members[index].Type;
578 }
579
580 public override string GetName(int index)
581 {
582 return _members[index].Name;
583 }
584
585 public override object GetValue(object o, int index)
586 {
587 return _members[index].GetValue(o);
588 }
589
590 public override object GetValue(object o, string name)
591 {
592 MemberMapper mm;
593
594 lock (_nameToMember)
595 if (!_nameToMember.TryGetValue(name, out mm))
596 mm = this[name];
597
598 return mm == null? null: mm.GetValue(o);
599 }
600
601 public override bool IsNull (object o, int index) { return this[index].IsNull(o); }
602
603 public override bool SupportsTypedValues(int index) { return this[index].SupportsValue; }
604
605 // Simple type getters.
606 //
607 [CLSCompliant(false)]
608 public override SByte GetSByte (object o, int index) { return this[index].GetSByte (o); }
609 public override Int16 GetInt16 (object o, int index) { return this[index].GetInt16 (o); }
610 public override Int32 GetInt32 (object o, int index) { return this[index].GetInt32 (o); }
611 public override Int64 GetInt64 (object o, int index) { return this[index].GetInt64 (o); }
612
613 public override Byte GetByte (object o, int index) { return this[index].GetByte (o); }
614 [CLSCompliant(false)]
615 public override UInt16 GetUInt16 (object o, int index) { return this[index].GetUInt16 (o); }
616 [CLSCompliant(false)]
617 public override UInt32 GetUInt32 (object o, int index) { return this[index].GetUInt32 (o); }
618 [CLSCompliant(false)]
619 public override UInt64 GetUInt64 (object o, int index) { return this[index].GetUInt64 (o); }
620
621 public override Boolean GetBoolean (object o, int index) { return this[index].GetBoolean (o); }
622 public override Char GetChar (object o, int index) { return this[index].GetChar (o); }
623 public override Single GetSingle (object o, int index) { return this[index].GetSingle (o); }
624 public override Double GetDouble (object o, int index) { return this[index].GetDouble (o); }
625 public override Decimal GetDecimal (object o, int index) { return this[index].GetDecimal (o); }
626 public override Guid GetGuid (object o, int index) { return this[index].GetGuid (o); }
627 public override DateTime GetDateTime(object o, int index) { return this[index].GetDateTime(o); }
628 public override DateTimeOffset GetDateTimeOffset(object o, int index) { return this[index].GetDateTimeOffset(o); }
629
630 // Nullable type getters.
631 //
632 [CLSCompliant(false)]
633 public override SByte? GetNullableSByte (object o, int index) { return this[index].GetNullableSByte (o); }
634 public override Int16? GetNullableInt16 (object o, int index) { return this[index].GetNullableInt16 (o); }
635 public override Int32? GetNullableInt32 (object o, int index) { return this[index].GetNullableInt32 (o); }
636 public override Int64? GetNullableInt64 (object o, int index) { return this[index].GetNullableInt64 (o); }
637
638 public override Byte? GetNullableByte (object o, int index) { return this[index].GetNullableByte (o); }
639 [CLSCompliant(false)]
640 public override UInt16? GetNullableUInt16 (object o, int index) { return this[index].GetNullableUInt16 (o); }
641 [CLSCompliant(false)]
642 public override UInt32? GetNullableUInt32 (object o, int index) { return this[index].GetNullableUInt32 (o); }
643 [CLSCompliant(false)]
644 public override UInt64? GetNullableUInt64 (object o, int index) { return this[index].GetNullableUInt64 (o); }
645
646 public override Boolean? GetNullableBoolean (object o, int index) { return this[index].GetNullableBoolean (o); }
647 public override Char? GetNullableChar (object o, int index) { return this[index].GetNullableChar (o); }
648 public override Single? GetNullableSingle (object o, int index) { return this[index].GetNullableSingle (o); }
649 public override Double? GetNullableDouble (object o, int index) { return this[index].GetNullableDouble (o); }
650 public override Decimal? GetNullableDecimal (object o, int index) { return this[index].GetNullableDecimal (o); }
651 public override Guid? GetNullableGuid (object o, int index) { return this[index].GetNullableGuid (o); }
652 public override DateTime? GetNullableDateTime(object o, int index) { return this[index].GetNullableDateTime(o); }
653 public override DateTimeOffset? GetNullableDateTimeOffset(object o, int index) { return this[index].GetNullableDateTimeOffset(o); }
654
655 #if !SILVERLIGHT
656
657 // SQL type getters.
658 //
659 public override SqlByte GetSqlByte (object o, int index) { return this[index].GetSqlByte (o); }
660 public override SqlInt16 GetSqlInt16 (object o, int index) { return this[index].GetSqlInt16 (o); }
661 public override SqlInt32 GetSqlInt32 (object o, int index) { return this[index].GetSqlInt32 (o); }
662 public override SqlInt64 GetSqlInt64 (object o, int index) { return this[index].GetSqlInt64 (o); }
663 public override SqlSingle GetSqlSingle (object o, int index) { return this[index].GetSqlSingle (o); }
664 public override SqlBoolean GetSqlBoolean (object o, int index) { return this[index].GetSqlBoolean (o); }
665 public override SqlDouble GetSqlDouble (object o, int index) { return this[index].GetSqlDouble (o); }
666 public override SqlDateTime GetSqlDateTime(object o, int index) { return this[index].GetSqlDateTime(o); }
667 public override SqlDecimal GetSqlDecimal (object o, int index) { return this[index].GetSqlDecimal (o); }
668 public override SqlMoney GetSqlMoney (object o, int index) { return this[index].GetSqlMoney (o); }
669 public override SqlGuid GetSqlGuid (object o, int index) { return this[index].GetSqlGuid (o); }
670 public override SqlString GetSqlString (object o, int index) { return this[index].GetSqlString (o); }
671
672 #endif
673
674 #endregion
675
676 #region IMapDataDestination Members
677
678 public override int GetOrdinal(string name)
679 {
680 MemberMapper mm;
681
682 lock (_nameToMember)
683 if (!_nameToMember.TryGetValue(name, out mm))
684 mm = this[name];
685
686 return mm == null? -1: mm.Ordinal;
687 }
688
689 public override void SetValue(object o, int index, object value)
690 {
691 _members[index].SetValue(o, value);
692 }
693
694 public override void SetValue(object o, string name, object value)
695 {
696 SetValue(o, GetOrdinal(name), value);
697 }
698
699 public override void SetNull (object o, int index) { this[index].SetNull (o); }
700
701 // Simple types setters.
702 //
703 [CLSCompliant(false)]
704 public override void SetSByte (object o, int index, SByte value) { this[index].SetSByte (o, value); }
705 public override void SetInt16 (object o, int index, Int16 value) { this[index].SetInt16 (o, value); }
706 public override void SetInt32 (object o, int index, Int32 value) { this[index].SetInt32 (o, value); }
707 public override void SetInt64 (object o, int index, Int64 value) { this[index].SetInt64 (o, value); }
708
709 public override void SetByte (object o, int index, Byte value) { this[index].SetByte (o, value); }
710 [CLSCompliant(false)]
711 public override void SetUInt16 (object o, int index, UInt16 value) { this[index].SetUInt16 (o, value); }
712 [CLSCompliant(false)]
713 public override void SetUInt32 (object o, int index, UInt32 value) { this[index].SetUInt32 (o, value); }
714 [CLSCompliant(false)]
715 public override void SetUInt64 (object o, int index, UInt64 value) { this[index].SetUInt64 (o, value); }
716
717 public override void SetBoolean (object o, int index, Boolean value) { this[index].SetBoolean (o, value); }
718 public override void SetChar (object o, int index, Char value) { this[index].SetChar (o, value); }
719 public override void SetSingle (object o, int index, Single value) { this[index].SetSingle (o, value); }
720 public override void SetDouble (object o, int index, Double value) { this[index].SetDouble (o, value); }
721 public override void SetDecimal (object o, int index, Decimal value) { this[index].SetDecimal (o, value); }
722 public override void SetGuid (object o, int index, Guid value) { this[index].SetGuid (o, value); }
723 public override void SetDateTime(object o, int index, DateTime value) { this[index].SetDateTime(o, value); }
724 public override void SetDateTimeOffset(object o, int index, DateTimeOffset value) { this[index].SetDateTimeOffset(o, value); }
725
726 // Simple types setters.
727 //
728 [CLSCompliant(false)]
729 public override void SetNullableSByte (object o, int index, SByte? value) { this[index].SetNullableSByte (o, value); }
730 public override void SetNullableInt16 (object o, int index, Int16? value) { this[index].SetNullableInt16 (o, value); }
731 public override void SetNullableInt32 (object o, int index, Int32? value) { this[index].SetNullableInt32 (o, value); }
732 public override void SetNullableInt64 (object o, int index, Int64? value) { this[index].SetNullableInt64 (o, value); }
733
734 public override void SetNullableByte (object o, int index, Byte? value) { this[index].SetNullableByte (o, value); }
735 [CLSCompliant(false)]
736 public override void SetNullableUInt16 (object o, int index, UInt16? value) { this[index].SetNullableUInt16 (o, value); }
737 [CLSCompliant(false)]
738 public override void SetNullableUInt32 (object o, int index, UInt32? value) { this[index].SetNullableUInt32 (o, value); }
739 [CLSCompliant(false)]
740 public override void SetNullableUInt64 (object o, int index, UInt64? value) { this[index].SetNullableUInt64 (o, value); }
741
742 public override void SetNullableBoolean (object o, int index, Boolean? value) { this[index].SetNullableBoolean (o, value); }
743 public override void SetNullableChar (object o, int index, Char? value) { this[index].SetNullableChar (o, value); }
744 public override void SetNullableSingle (object o, int index, Single? value) { this[index].SetNullableSingle (o, value); }
745 public override void SetNullableDouble (object o, int index, Double? value) { this[index].SetNullableDouble (o, value); }
746 public override void SetNullableDecimal (object o, int index, Decimal? value) { this[index].SetNullableDecimal (o, value); }
747 public override void SetNullableGuid (object o, int index, Guid? value) { this[index].SetNullableGuid (o, value); }
748 public override void SetNullableDateTime(object o, int index, DateTime? value) { this[index].SetNullableDateTime(o, value); }
749 public override void SetNullableDateTimeOffset(object o, int index, DateTimeOffset? value) { this[index].SetNullableDateTimeOffset(o, value); }
750
751 #if !SILVERLIGHT
752
753 // SQL type setters.
754 //
755 public override void SetSqlByte (object o, int index, SqlByte value) { this[index].SetSqlByte (o, value); }
756 public override void SetSqlInt16 (object o, int index, SqlInt16 value) { this[index].SetSqlInt16 (o, value); }
757 public override void SetSqlInt32 (object o, int index, SqlInt32 value) { this[index].SetSqlInt32 (o, value); }
758 public override void SetSqlInt64 (object o, int index, SqlInt64 value) { this[index].SetSqlInt64 (o, value); }
759 public override void SetSqlSingle (object o, int index, SqlSingle value) { this[index].SetSqlSingle (o, value); }
760 public override void SetSqlBoolean (object o, int index, SqlBoolean value) { this[index].SetSqlBoolean (o, value); }
761 public override void SetSqlDouble (object o, int index, SqlDouble value) { this[index].SetSqlDouble (o, value); }
762 public override void SetSqlDateTime(object o, int index, SqlDateTime value) { this[index].SetSqlDateTime(o, value); }
763 public override void SetSqlDecimal (object o, int index, SqlDecimal value) { this[index].SetSqlDecimal (o, value); }
764 public override void SetSqlMoney (object o, int index, SqlMoney value) { this[index].SetSqlMoney (o, value); }
765 public override void SetSqlGuid (object o, int index, SqlGuid value) { this[index].SetSqlGuid (o, value); }
766 public override void SetSqlString (object o, int index, SqlString value) { this[index].SetSqlString (o, value); }
767
768 #endif
769
770 #endregion
771
772 #region IEnumerable Members
773
774 public IEnumerator GetEnumerator()
775 {
776 return _members.GetEnumerator();
777 }
778
779 IEnumerator<MemberMapper> IEnumerable<MemberMapper>.GetEnumerator()
780 {
781 return _members.GetEnumerator();
782 }
783
784 #endregion
785 }
786 }