Mercurial > pub > bltoolkit
comparison Source/Mapping/ScalarListMapper.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 | |
4 namespace BLToolkit.Mapping | |
5 { | |
6 public class ScalarListMapper : MapDataSourceDestinationBase | |
7 { | |
8 public ScalarListMapper(IList list, Type type) | |
9 { | |
10 _list = list; | |
11 _type = type; | |
12 } | |
13 | |
14 private readonly IList _list; | |
15 private readonly Type _type; | |
16 private int _index; | |
17 | |
18 #region Destination | |
19 | |
20 public override Type GetFieldType(int index) | |
21 { | |
22 return _type; | |
23 } | |
24 | |
25 public override int GetOrdinal(string name) | |
26 { | |
27 return 0; | |
28 } | |
29 | |
30 public override void SetValue(object o, int index, object value) | |
31 { | |
32 _list.Add(value); | |
33 } | |
34 | |
35 public override void SetValue(object o, string name, object value) | |
36 { | |
37 _list.Add(value); | |
38 } | |
39 | |
40 #endregion | |
41 | |
42 #region Source | |
43 | |
44 public override int Count | |
45 { | |
46 get { return _index < _list.Count? 1: 0; } | |
47 } | |
48 | |
49 public override string GetName(int index) | |
50 { | |
51 return string.Empty; | |
52 } | |
53 | |
54 public override object GetValue(object o, int index) | |
55 { | |
56 return _list[_index++]; | |
57 } | |
58 | |
59 public override object GetValue(object o, string name) | |
60 { | |
61 return _list[_index++]; | |
62 } | |
63 | |
64 #endregion | |
65 } | |
66 } |