Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 namespace XMLStorage
00041 {
00042
00043
00044
00045
00046 public class XMLDecimal
00047 {
00048 public XMLDecimal(decimal value)
00049 {
00050 _value = value;
00051 }
00052
00053 public XMLDecimal(string value)
00054 {
00055 init(value, (decimal)0);
00056 }
00057
00058 public XMLDecimal(string value, decimal def)
00059 {
00060 init(value, def);
00061 }
00062
00063 private void init(string value, decimal def)
00064 {
00065 if (string.IsNullOrEmpty(value) || !decimal.TryParse(value, out _value))
00066 _value = def;
00067 }
00068
00069
00070 public XMLDecimal(AbstractXMLNode node, string attrName)
00071 {
00072 init(node, attrName, (decimal)0);
00073 }
00074
00075 public XMLDecimal(XMLPos pos, string attrName)
00076 {
00077 init(pos.cur(), attrName, (decimal)0);
00078 }
00079
00080 public XMLDecimal(XMLPos pos, string attrName, decimal def)
00081 {
00082 init(pos.cur(), attrName, def);
00083 }
00084
00085 public XMLDecimal(XMLStreamReader reader, string attrName)
00086 {
00087 init(reader.getNode(), attrName, (decimal)0);
00088 }
00089
00090 public XMLDecimal(XMLStreamReader reader, string attrName, decimal def)
00091 {
00092 init(reader.getNode(), attrName, def);
00093 }
00094
00095
00096 public XMLDecimal(AbstractXMLNode node, string attrName, decimal def)
00097 {
00098 init(node, attrName, def);
00099 }
00100
00101 private void init(AbstractXMLNode node, string attrName, decimal def)
00102 {
00103 string value = node.get(attrName);
00104
00105 if (string.IsNullOrEmpty(value) || !decimal.TryParse(value, out _value))
00106 _value = def;
00107 }
00108
00109 public decimal bigDecimalValue()
00110 {
00111 return _value;
00112 }
00113
00114 public override string ToString()
00115 {
00116 return _value.ToString();
00117 }
00118
00119 protected decimal _value;
00120 }
00121
00122
00123
00124
00125
00126 public class XMLNumberRef
00127 {
00128 public XMLNumberRef(XMLNode node, string attrName)
00129 {
00130 init(node, attrName, (decimal)0);
00131 }
00132
00133 public XMLNumberRef(XMLNode node, string attrName, decimal def)
00134 {
00135 init(node, attrName, def);
00136 }
00137
00138 private void init(XMLNode node, string attrName, decimal def)
00139 {
00140 _node = node;
00141 _attrName = attrName;
00142
00143 if (node != null)
00144 if (node.get(attrName).Length == 0)
00145 assign(def);
00146 }
00147
00148 public decimal decimalValue()
00149 {
00150 decimal value;
00151
00152 if (_node!=null && decimal.TryParse(_node.get(_attrName), out value))
00153 return value;
00154 else
00155 return (decimal)0;
00156 }
00157
00158 public void assign(decimal value)
00159 {
00160 if (_node != null)
00161 _node.put(_attrName, value.ToString());
00162 }
00163
00164 protected XMLNode _node;
00165 protected string _attrName;
00166 }
00167
00168 }