| |||||||||||||||||
| Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
| Model\XmlModel\XmlXPercentMap.cs | - | 41,7 % | 9,1 % | 26,1 % |
|
||||||||||||
| 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 | ||
| 27 | namespace ShowX.Model.XmlModel | |
| 28 | { | |
| 29 | /// <summary> | |
| 30 | /// Represents a property that returns a collection of objects. | |
| 31 | /// </summary> | |
| 32 | public class XmlXPercentMap : XmlPropertyMap, IXPercentMap | |
| 33 | { | |
| 34 | /// <summary> | |
| 35 | /// Represent the name of the property who hold the 100% of this quantity. | |
| 36 | /// </summary> | |
| 37 | protected string maxProp = string.Empty; | |
| 38 | ||
| 39 | /// <summary> | |
| 40 | /// Keep track whether we want to display attribute as a percent. | |
| 41 | /// </summary> | |
| 42 | protected bool showLikePercent = true; | |
| 43 | ||
| 44 | /// <summary> | |
| 45 | /// Constructor. | |
| 46 | /// </summary> | |
| 47 | /// <param name="t">Type to map.</param> | |
| 48 | /// <param name="propertyNode">Xml node that represents property mapping info. | |
| 49 | /// </param> | |
| 50 | 1 | public XmlXPercentMap(Type t, XmlNode propertyNode) : base (t,propertyNode) |
| 51 | { | |
| 52 | //Name attribute is mandatory | |
| 53 | 1 | this.name = propertyNode.Attributes[ |
| 54 | XmlMappingFileConst.propertyMappingNameAttr].Value; | |
| 55 | ||
| 56 | //If not especified a heading, assign property name value by default. | |
| 57 | 1 | this.heading = XmlPropertyMap.LoadValueFromAttribute( |
| 58 | propertyNode.Attributes[XmlMappingFileConst.propertyHeadingAttr] | |
| 59 | ,this.name); | |
| 60 | ||
| 61 | //Max property is mandatory | |
| 62 | 1 | this.maxProp = propertyNode.Attributes[ |
| 63 | XmlMappingFileConst.xpercentMaxPropertyAttr].Value; | |
| 64 | ||
| 65 | 1 | this.showLikePercent = XmlPropertyMap.LoadValueFromAttribute( |
| 66 | propertyNode.Attributes[XmlMappingFileConst.xpercentShowLikePercentAttr] | |
| 67 | ,this.showLikePercent); | |
| 68 | ||
| 69 | 1 | this.show = XmlPropertyMap.LoadValueFromAttribute( |
| 70 | propertyNode.Attributes[XmlMappingFileConst.propertyShowAttr] | |
| 71 | ,this.show); | |
| 72 | } | |
| 73 | ||
| 74 | #region IXPercentMap Members | |
| 75 | ||
| 76 | /// <summary> | |
| 77 | /// Reflex the property who store the maximum value. | |
| 78 | /// </summary> | |
| 79 | 0 | public string MaxPoperty |
| 80 | { | |
| 81 | get { return this.maxProp; } | |
| 82 | set { maxProp = value; } | |
| 83 | } | |
| 84 | ||
| 85 | /// <summary> | |
| 86 | /// Expose the showLikePercent attribute. | |
| 87 | /// </summary> | |
| 88 | 0 | public bool ShowLikePercent |
| 89 | { | |
| 90 | get { return this.showLikePercent; } | |
| 91 | set { showLikePercent = value; } | |
| 92 | } | |
| 93 | ||
| 94 | #endregion | |
| 95 | ||
| 96 | #region IPropertyMap Members | |
| 97 | ||
| 98 | /// <summary> | |
| 99 | /// Reflex readonly-ness of the property. | |
| 100 | /// </summary> | |
| 101 | 0 | public override bool ReadOnly |
| 102 | { | |
| 103 | get { return true; } | |
| 104 | set {} | |
| 105 | } | |
| 106 | ||
| 107 | /// <summary> | |
| 108 | /// Reflex whether the property should be edited on insertion. | |
| 109 | /// </summary> | |
| 110 | 0 | public override bool EditOnInsert |
| 111 | { | |
| 112 | get { return false; } | |
| 113 | set {} | |
| 114 | } | |
| 115 | ||
| 116 | /// <summary> | |
| 117 | /// Reflex whether the property value should be treated as a password. | |
| 118 | /// </summary> | |
| 119 | 0 | public override bool IsPassword |
| 120 | { | |
| 121 | get { return false; } | |
| 122 | set {} | |
| 123 | } | |
| 124 | ||
| 125 | #endregion | |
| 126 | } | |
| 127 | } | |
| 128 |
|
||||||||