- Timestamp:
- 04/15/08 16:41:18 (17 years ago)
- Location:
- branches/XmlReaderWriterBranch
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/XmlReaderWriterBranch/HeuristicLab.DataAnalysis/Dataset.cs
r119 r125 149 149 } 150 150 151 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 152 base.Populate(node, restoredObjects); 153 Name = node.Attributes["Name"].Value; 154 rows = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat); 155 columns = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat); 156 157 VariableNames = ParseVariableNamesString(node.Attributes["VariableNames"].Value); 158 159 string[] tokens = node.InnerText.Split(';'); 151 //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 152 // base.Populate(node, restoredObjects); 153 // Name = node.Attributes["Name"].Value; 154 // rows = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat); 155 // columns = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat); 156 157 // VariableNames = ParseVariableNamesString(node.Attributes["VariableNames"].Value); 158 159 // string[] tokens = node.InnerText.Split(';'); 160 // if(tokens.Length != rows * columns) throw new FormatException(); 161 // samples = new double[rows * columns]; 162 // for(int row = 0; row < rows; row++) { 163 // for(int column = 0; column < columns; column++) { 164 // if(double.TryParse(tokens[row * columns + column], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out samples[row * columns + column]) == false) { 165 // throw new FormatException("Can't parse " + tokens[row * columns + column] + " as double value."); 166 // } 167 // } 168 // } 169 // CreateDictionaries(); 170 //} 171 public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) { 172 base.Populate(reader, restoredObjects); 173 Name = reader["Name"]; 174 rows = int.Parse(reader["Dimension1"], CultureInfo.InvariantCulture.NumberFormat); 175 columns = int.Parse(reader["Dimension2"], CultureInfo.InvariantCulture.NumberFormat); 176 VariableNames = ParseVariableNamesString(reader["VariableNames"]); 177 string[] tokens = reader.ReadString().Split(';'); 178 160 179 if(tokens.Length != rows * columns) throw new FormatException(); 161 180 samples = new double[rows * columns]; 162 181 for(int row = 0; row < rows; row++) { 163 182 for(int column = 0; column < columns; column++) { 164 if(double.TryParse(tokens[row * columns + column], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out samples[row *columns + column]) == false) {183 if(double.TryParse(tokens[row * columns + column], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out samples[row * columns + column]) == false) { 165 184 throw new FormatException("Can't parse " + tokens[row * columns + column] + " as double value."); 166 185 }
Note: See TracChangeset
for help on using the changeset viewer.