diff options
Diffstat (limited to 'OpenSim/Framework/Data.Base/BaseRowMapper.cs')
-rw-r--r-- | OpenSim/Framework/Data.Base/BaseRowMapper.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/OpenSim/Framework/Data.Base/BaseRowMapper.cs b/OpenSim/Framework/Data.Base/BaseRowMapper.cs new file mode 100644 index 0000000..e8292fd --- /dev/null +++ b/OpenSim/Framework/Data.Base/BaseRowMapper.cs | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright (c) Tribal Media AB, http://tribalmedia.se/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
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 | ||
12 | * derived from this software without specific prior written permission. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
17 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | using TribalMedia.Framework.Data; | ||
28 | |||
29 | namespace TribalMedia.Framework.Data | ||
30 | { | ||
31 | public abstract class BaseRowMapper | ||
32 | { | ||
33 | public abstract void FillObject(BaseDataReader reader); | ||
34 | } | ||
35 | |||
36 | public class BaseRowMapper<TObj> : BaseRowMapper | ||
37 | { | ||
38 | private readonly BaseSchema m_schema; | ||
39 | private readonly TObj m_obj; | ||
40 | |||
41 | public TObj Object | ||
42 | { | ||
43 | get { return m_obj; } | ||
44 | } | ||
45 | |||
46 | public BaseRowMapper(BaseSchema schema, TObj obj) | ||
47 | { | ||
48 | m_schema = schema; | ||
49 | m_obj = obj; | ||
50 | } | ||
51 | |||
52 | public override void FillObject(BaseDataReader reader) | ||
53 | { | ||
54 | foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) | ||
55 | { | ||
56 | fieldMapper.SetPropertyFromReader(this, reader); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | } \ No newline at end of file | ||