diff options
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs index aa22c8b..2771ec9 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs | |||
@@ -1,85 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Tribal Media AB, http://tribalmedia.se/ | 2 | * Copyright (c) Tribal Media AB, http://tribalmedia.se/ |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are met: | 5 | * modification, are permitted provided that the following conditions are met: |
6 | * * Redistributions of source code must retain the above copyright | 6 | * * Redistributions of source code must retain the above copyright |
7 | * notice, this list of conditions and the following disclaimer. | 7 | * notice, this list of conditions and the following disclaimer. |
8 | * * Redistributions in binary form must reproduce the above copyright | 8 | * * Redistributions in binary form must reproduce the above copyright |
9 | * notice, this list of conditions and the following disclaimer in the | 9 | * notice, this list of conditions and the following disclaimer in the |
10 | * documentation and/or other materials provided with the distribution. | 10 | * documentation and/or other materials provided with the distribution. |
11 | * * The name of Tribal Media AB may not be used to endorse or promote products | 11 | * * The name of Tribal Media AB may not be used to endorse or promote products |
12 | * derived from this software without specific prior written permission. | 12 | * derived from this software without specific prior written permission. |
13 | * | 13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 14 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 17 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | using TribalMedia.Framework.Data; | 27 | using TribalMedia.Framework.Data; |
28 | 28 | ||
29 | namespace TribalMedia.Framework.Data | 29 | namespace TribalMedia.Framework.Data |
30 | { | 30 | { |
31 | public abstract class RowMapper | 31 | public abstract class RowMapper |
32 | { | 32 | { |
33 | public abstract void FillObject(DataReader reader); | 33 | public abstract void FillObject(DataReader reader); |
34 | } | 34 | } |
35 | 35 | ||
36 | public class ObjectMapper<TObj> : RowMapper | 36 | public class ObjectMapper<TObj> : RowMapper |
37 | { | 37 | { |
38 | private readonly Schema m_schema; | 38 | private readonly Schema m_schema; |
39 | private readonly TObj m_obj; | 39 | private readonly TObj m_obj; |
40 | 40 | ||
41 | public TObj Object | 41 | public TObj Object |
42 | { | 42 | { |
43 | get { return m_obj; } | 43 | get { return m_obj; } |
44 | } | 44 | } |
45 | 45 | ||
46 | public ObjectMapper(Schema schema, TObj obj) | 46 | public ObjectMapper(Schema schema, TObj obj) |
47 | { | 47 | { |
48 | m_schema = schema; | 48 | m_schema = schema; |
49 | m_obj = obj; | 49 | m_obj = obj; |
50 | } | 50 | } |
51 | 51 | ||
52 | public override void FillObject(DataReader reader) | 52 | public override void FillObject(DataReader reader) |
53 | { | 53 | { |
54 | foreach (FieldMapper fieldMapper in m_schema.Fields.Values) | 54 | foreach (FieldMapper fieldMapper in m_schema.Fields.Values) |
55 | { | 55 | { |
56 | fieldMapper.SetPropertyFromReader(m_obj, reader); | 56 | fieldMapper.SetPropertyFromReader(m_obj, reader); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | public class RowMapper<TObj> : RowMapper | 61 | public class RowMapper<TObj> : RowMapper |
62 | { | 62 | { |
63 | private readonly Schema m_schema; | 63 | private readonly Schema m_schema; |
64 | private readonly TObj m_obj; | 64 | private readonly TObj m_obj; |
65 | 65 | ||
66 | public TObj Object | 66 | public TObj Object |
67 | { | 67 | { |
68 | get { return m_obj; } | 68 | get { return m_obj; } |
69 | } | 69 | } |
70 | 70 | ||
71 | public RowMapper(Schema schema, TObj obj) | 71 | public RowMapper(Schema schema, TObj obj) |
72 | { | 72 | { |
73 | m_schema = schema; | 73 | m_schema = schema; |
74 | m_obj = obj; | 74 | m_obj = obj; |
75 | } | 75 | } |
76 | 76 | ||
77 | public override void FillObject(DataReader reader) | 77 | public override void FillObject(DataReader reader) |
78 | { | 78 | { |
79 | foreach (FieldMapper fieldMapper in m_schema.Fields.Values) | 79 | foreach (FieldMapper fieldMapper in m_schema.Fields.Values) |
80 | { | 80 | { |
81 | fieldMapper.SetPropertyFromReader(this, reader); | 81 | fieldMapper.SetPropertyFromReader(this, reader); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | } | 84 | } |
85 | } \ No newline at end of file | 85 | } \ No newline at end of file |