| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Model\XmlModel\XmlView.cs | 50,0 % | 61,5 % | 66,7 % | 60,0 % |
|
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.Collections; | |
25 | using System.Xml; | |
26 | using log4net; | |
27 | ||
28 | namespace ShowX.Model.XmlModel | |
29 | { | |
30 | /// <summary> | |
31 | /// XmlView represent a view in the xml model. | |
32 | /// </summary> | |
33 | public class XmlView : IView | |
34 | { | |
35 | private static readonly ILog log = LogManager.GetLogger( | |
36 | typeof(XmlView)); | |
37 | ||
38 | string name; | |
39 | ArrayList properties; | |
40 | ||
41 | /// <summary> | |
42 | /// Constructor. | |
43 | /// </summary> | |
44 | /// <param name="viewNode">Xml node from wich to build view.</param> | |
45 | 20 | public XmlView (XmlNode viewNode) |
46 | { | |
47 | 20 | this.name = viewNode |
48 | .Attributes[XmlMappingFileConst.singleViewTagViewNameAttr].Value; | |
49 | ||
50 | 20 | if (name == "") { |
51 | ||
52 | 0 | log.Fatal("Name of view required."); |
53 | 0 | throw new ModelException("Name of view required."); |
54 | } | |
55 | ||
56 | 20 | properties = new ArrayList(); |
57 | ||
58 | 20 | foreach (XmlNode node in viewNode.SelectSingleNode(XmlMappingFileConst |
59 | .propertySetTag).ChildNodes) { | |
60 | ||
61 | 50 | string propertyName = node.Attributes[XmlMappingFileConst |
62 | .propertySetPropertyTagNameAttr].Value; | |
63 | ||
64 | 50 | if (propertyName == "") { |
65 | ||
66 | 0 | log.Fatal("Property name cannot be empty."); |
67 | 0 | throw new ModelException("Property name cannot be empty."); |
68 | } | |
69 | ||
70 | 50 | properties.Add(propertyName); |
71 | } | |
72 | } | |
73 | ||
74 | #region IView Members | |
75 | ||
76 | /// <summary> | |
77 | /// Properties included in this view. | |
78 | /// </summary> | |
79 | 0 | public ArrayList Properties |
80 | { | |
81 | get | |
82 | { | |
83 | return this.properties; | |
84 | } | |
85 | } | |
86 | ||
87 | /// <summary> | |
88 | /// Name of this view. | |
89 | /// </summary> | |
90 | public string Name | |
91 | { | |
92 | 20 | get |
93 | { | |
94 | 20 | return this.name; |
95 | } | |
96 | } | |
97 | ||
98 | #endregion | |
99 | } | |
100 | } |
|