| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Model\XmlModel\XmlCollectionMap.cs | 50,0 % | 57,1 % | 50,0 % | 53,8 % |
|
1 | #region Copyright | |
2 | /* | |
3 | ShowX. Maps business objects into presentation layer. | |
4 | Copyright (C) 2005 Jesus Diaz. | |
5 | ||
6 | This library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | This library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
17 | License along with this library; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
19 | ||
20 | For project details see: http://showx.sourceforge.net | |
21 | */ | |
22 | #endregion | |
23 | ||
24 | using System; | |
25 | using System.Xml; | |
26 | using log4net; | |
27 | ||
28 | namespace ShowX.Model.XmlModel | |
29 | { | |
30 | /// <summary> | |
31 | /// Represents a property that returns a collection of objects. | |
32 | /// </summary> | |
33 | public class XmlCollectionMap : XmlPropertyMap, ICollectionMap | |
34 | { | |
35 | private static readonly ILog log = LogManager.GetLogger( | |
36 | typeof(XmlCollectionMap)); | |
37 | ||
38 | /// <summary> | |
39 | /// Contained type of the collection. | |
40 | /// </summary> | |
41 | Type containedType; | |
42 | ||
43 | /// <summary> | |
44 | /// Constructor. | |
45 | /// </summary> | |
46 | 10 | public XmlCollectionMap (Type t, XmlNode propertyNode) : base(t,propertyNode) |
47 | { | |
48 | 10 | string containedTypeName = XmlPropertyMap.LoadValueFromAttribute( |
49 | propertyNode.Attributes[XmlMappingFileConst.collectionContainedTypeTag] | |
50 | ,""); | |
51 | ||
52 | 10 | if (containedTypeName == "") { |
53 | ||
54 | 0 | log.Fatal("Unspecified contained type."); |
55 | 0 | throw new ModelException("Unspecified contained type."); |
56 | } | |
57 | ||
58 | 10 | this.containedType = t.UnderlyingSystemType.Assembly |
59 | .GetType(containedTypeName,true); | |
60 | } | |
61 | ||
62 | /// <summary> | |
63 | /// Override the inherited IsPassword property, so the value of the field | |
64 | /// isPassword can't be altered. | |
65 | /// </summary> | |
66 | 0 | public override bool IsPassword |
67 | { | |
68 | set {} | |
69 | } | |
70 | ||
71 | #region ICollectionMap Members | |
72 | ||
73 | /// <summary> | |
74 | /// Reflex the contained type attribute. | |
75 | /// </summary> | |
76 | public Type ContainedType | |
77 | { | |
78 | 194 | get { return this.containedType; } |
79 | 0 | set { this.containedType = value; } |
80 | } | |
81 | ||
82 | #endregion | |
83 | } | |
84 | } | |
85 |
|