Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/14/08 21:51:15 (16 years ago)
Author:
gkronber
Message:

created a branch that uses XmlTextReader instead of XMLDocument to load documents. Investigating ticket #103. (...work in progress!)

Location:
branches/XmlTextReaderBranch
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/XmlTextReaderBranch/HeuristicLab.Data/BoolArrayData.cs

    r2 r121  
    4949      return node;
    5050    }
    51     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    52       base.Populate(node, restoredObjects);
    53       string[] tokens = node.InnerText.Split(';');
     51    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     52    //  base.Populate(node, restoredObjects);
     53    //  string[] tokens = node.InnerText.Split(';');
     54    //  bool[] data = new bool[tokens.Length];
     55    //  for(int i = 0; i < data.Length; i++)
     56    //    data[i] = bool.Parse(tokens[i]);
     57    //  Data = data;
     58    //}
     59    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     60      base.Populate(reader, restoredObjects);
     61      string[] tokens = reader.ReadString().Split(';');
    5462      bool[] data = new bool[tokens.Length];
    55       for (int i = 0; i < data.Length; i++)
     63      for(int i = 0; i < data.Length; i++)
    5664        data[i] = bool.Parse(tokens[i]);
    5765      Data = data;
  • branches/XmlTextReaderBranch/HeuristicLab.Data/BoolData.cs

    r2 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       Data = bool.Parse(node.InnerText);
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  Data = bool.Parse(node.InnerText);
     61    //}
     62    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     63      base.Populate(reader, restoredObjects);
     64      Data = bool.Parse(reader.ReadString());
    6165    }
    6266
  • branches/XmlTextReaderBranch/HeuristicLab.Data/BoolMatrixData.cs

    r2 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
    61       int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
    62       string[] tokens = node.InnerText.Split(';');
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
     61    //  int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
     62    //  string[] tokens = node.InnerText.Split(';');
     63    //  bool[,] data = new bool[dim1, dim2];
     64    //  for(int i = 0; i < dim1; i++) {
     65    //    for(int j = 0; j < dim2; j++) {
     66    //      data[i, j] = bool.Parse(tokens[i * dim2 + j]);
     67    //    }
     68    //  }
     69    //  Data = data;
     70    //}
     71    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     72      base.Populate(reader, restoredObjects);
     73      int dim1 = int.Parse(reader["Dimension1"], CultureInfo.InvariantCulture.NumberFormat);
     74      int dim2 = int.Parse(reader["Dimension2"], CultureInfo.InvariantCulture.NumberFormat);
     75      string[] tokens = reader.ReadString().Split(';');
    6376      bool[,] data = new bool[dim1, dim2];
    64       for (int i = 0; i < dim1; i++) {
    65         for (int j = 0; j < dim2; j++) {
     77      for(int i = 0; i < dim1; i++) {
     78        for(int j = 0; j < dim2; j++) {
    6679          data[i, j] = bool.Parse(tokens[i * dim2 + j]);
    6780        }
  • branches/XmlTextReaderBranch/HeuristicLab.Data/ConstrainedDoubleData.cs

    r2 r121  
    6161      return node;
    6262    }
    63     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    64       base.Populate(node, restoredObjects);
    65       base.Data = (DoubleData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects);
     63    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     64    //  base.Populate(node, restoredObjects);
     65    //  base.Data = (DoubleData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects);
     66    //}
     67    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     68      base.Populate(reader, restoredObjects);
     69      base.Data = (DoubleData)PersistenceManager.Restore(reader, "Value", restoredObjects);
    6670    }
    6771
  • branches/XmlTextReaderBranch/HeuristicLab.Data/ConstrainedIntData.cs

    r2 r121  
    6161      return node;
    6262    }
    63     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    64       base.Populate(node, restoredObjects);
    65       base.Data = (IntData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects);
     63    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     64    //  base.Populate(node, restoredObjects);
     65    //  base.Data = (IntData)PersistenceManager.Restore(node.SelectSingleNode("Value"), restoredObjects);
     66    //}
     67    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     68      base.Populate(reader, restoredObjects);
     69      base.Data = (IntData)PersistenceManager.Restore(reader, "Value", restoredObjects);
    6670    }
    6771
  • branches/XmlTextReaderBranch/HeuristicLab.Data/ConstrainedItemList.cs

    r2 r121  
    6767    }
    6868
    69     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    70       base.Populate(node, restoredObjects);
    71       XmlNode listNode = node.SelectSingleNode("ListItems");
     69    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     70    //  base.Populate(node, restoredObjects);
     71    //  XmlNode listNode = node.SelectSingleNode("ListItems");
     72    //  list = new List<IItem>();
     73    //  for(int i = 0; i < listNode.ChildNodes.Count; i++)
     74    //    list.Add((IItem)PersistenceManager.Restore(listNode.ChildNodes[i], restoredObjects));
     75    //  suspendConstraintCheck = bool.Parse(listNode.Attributes["SuspendConstraintCheck"].Value);
     76    //}
     77    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     78      base.Populate(reader, restoredObjects);
     79      reader.ReadStartElement("ListItems");
     80      suspendConstraintCheck = bool.Parse(reader["SuspendConstraintCheck"]);
    7281      list = new List<IItem>();
    73       for (int i = 0; i < listNode.ChildNodes.Count; i++)
    74         list.Add((IItem)PersistenceManager.Restore(listNode.ChildNodes[i], restoredObjects));
    75       suspendConstraintCheck = bool.Parse(listNode.Attributes["SuspendConstraintCheck"].Value);
     82      while(reader.IsStartElement())
     83        list.Add((IItem)PersistenceManager.Restore(reader, restoredObjects));
     84      reader.ReadEndElement();
    7685    }
    7786    #endregion
  • branches/XmlTextReaderBranch/HeuristicLab.Data/DoubleArrayData.cs

    r2 r121  
    5050      return node;
    5151    }
    52     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    53       base.Populate(node, restoredObjects);
    54       string[] tokens = node.InnerText.Split(';');
     52    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     53    //  base.Populate(node, restoredObjects);
     54    //  string[] tokens = node.InnerText.Split(';');
     55    //  double[] data = new double[tokens.Length];
     56    //  for(int i = 0; i < data.Length; i++)
     57    //    if(double.TryParse(tokens[i], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i]) == false) {
     58    //      throw new FormatException("Can't parse " + tokens[i] + " as double value.");
     59    //    }
     60    //  Data = data;
     61    //}
     62    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     63      base.Populate(reader, restoredObjects);
     64      string[] tokens = reader.ReadString().Split(';');
    5565      double[] data = new double[tokens.Length];
    5666      for(int i = 0; i < data.Length; i++)
  • branches/XmlTextReaderBranch/HeuristicLab.Data/DoubleData.cs

    r2 r121  
    5757      return node;
    5858    }
    59     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    60       base.Populate(node, restoredObjects);
     59    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     60    //  base.Populate(node, restoredObjects);
     61    //  double data;
     62    //  if(double.TryParse(node.InnerText, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data) == true) {
     63    //    Data = data;
     64    //  } else {
     65    //    throw new FormatException("Can't parse " + node.InnerText + " as double value.");
     66    //  }
     67    //}
     68    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     69      base.Populate(reader, restoredObjects);
    6170      double data;
    62       if(double.TryParse(node.InnerText, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data) == true) {
     71      if(double.TryParse(reader.ReadString(), NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data) == true) {
    6372        Data = data;
    6473      } else {
    65         throw new FormatException("Can't parse " + node.InnerText + " as double value.");       
     74        throw new FormatException("Can't parse " + reader.ReadString() + " as double value.");
    6675      }
    6776    }
  • branches/XmlTextReaderBranch/HeuristicLab.Data/DoubleMatrixData.cs

    r2 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
    61       int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
    62       string[] tokens = node.InnerText.Split(';');
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
     61    //  int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
     62    //  string[] tokens = node.InnerText.Split(';');
     63    //  double[,] data = new double[dim1, dim2];
     64    //  for(int i = 0; i < dim1; i++) {
     65    //    for(int j = 0; j < dim2; j++) {
     66    //      if(double.TryParse(tokens[i * dim2 + j], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i, j]) == false) {
     67    //        throw new FormatException("Can't parse " + tokens[i * dim2 + j] + " as double value.");
     68    //      }
     69    //    }
     70    //  }
     71    //  Data = data;
     72    //}
     73    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     74      base.Populate(reader, restoredObjects);
     75      int dim1 = int.Parse(reader["Dimension1"], CultureInfo.InvariantCulture.NumberFormat);
     76      int dim2 = int.Parse(reader["Dimension2"], CultureInfo.InvariantCulture.NumberFormat);
     77      string[] tokens = reader.ReadString().Split(';');
    6378      double[,] data = new double[dim1, dim2];
    64       for (int i = 0; i < dim1; i++) {
    65         for (int j = 0; j < dim2; j++) {
    66           if(double.TryParse(tokens[i * dim2 + j], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i, j])==false) {
     79      for(int i = 0; i < dim1; i++) {
     80        for(int j = 0; j < dim2; j++) {
     81          if(double.TryParse(tokens[i * dim2 + j], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i, j]) == false) {
    6782            throw new FormatException("Can't parse " + tokens[i * dim2 + j] + " as double value.");
    6883          }
  • branches/XmlTextReaderBranch/HeuristicLab.Data/IntArrayData.cs

    r2 r121  
    5050      return node;
    5151    }
    52     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    53       base.Populate(node, restoredObjects);
    54       if (!node.InnerText.Equals("")) {
    55         string[] tokens = node.InnerText.Split(';');
     52    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     53    //  base.Populate(node, restoredObjects);
     54    //  if(!node.InnerText.Equals("")) {
     55    //    string[] tokens = node.InnerText.Split(';');
     56    //    int[] data = new int[tokens.Length];
     57    //    for(int i = 0; i < data.Length; i++)
     58    //      data[i] = int.Parse(tokens[i], CultureInfo.InvariantCulture.NumberFormat);
     59    //    Data = data;
     60    //  }
     61    //}
     62    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     63      base.Populate(reader, restoredObjects);
     64      string innerText = reader.ReadString();
     65      if(!innerText.Equals("")) {
     66        string[] tokens = innerText.Split(';');
    5667        int[] data = new int[tokens.Length];
    57         for (int i = 0; i < data.Length; i++)
     68        for(int i = 0; i < data.Length; i++)
    5869          data[i] = int.Parse(tokens[i], CultureInfo.InvariantCulture.NumberFormat);
    5970        Data = data;
  • branches/XmlTextReaderBranch/HeuristicLab.Data/IntData.cs

    r2 r121  
    5757      return node;
    5858    }
    59     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    60       base.Populate(node, restoredObjects);
    61       Data = int.Parse(node.InnerText, CultureInfo.InvariantCulture.NumberFormat);
     59    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     60    //  base.Populate(node, restoredObjects);
     61    //  Data = int.Parse(node.InnerText, CultureInfo.InvariantCulture.NumberFormat);
     62    //}
     63    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     64      base.Populate(reader, restoredObjects);
     65      Data = int.Parse(reader.ReadString(), CultureInfo.InvariantCulture.NumberFormat);
    6266    }
    6367
  • branches/XmlTextReaderBranch/HeuristicLab.Data/IntMatrixData.cs

    r2 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
    61       int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
    62       string[] tokens = node.InnerText.Split(';');
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  int dim1 = int.Parse(node.Attributes["Dimension1"].Value, CultureInfo.InvariantCulture.NumberFormat);
     61    //  int dim2 = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat);
     62    //  string[] tokens = node.InnerText.Split(';');
     63    //  int[,] data = new int[dim1, dim2];
     64    //  for(int i = 0; i < dim1; i++) {
     65    //    for(int j = 0; j < dim2; j++) {
     66    //      data[i, j] = int.Parse(tokens[i * dim2 + j], CultureInfo.InvariantCulture.NumberFormat);
     67    //    }
     68    //  }
     69    //  Data = data;
     70    //}
     71    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     72      base.Populate(reader, restoredObjects);
     73      int dim1 = int.Parse(reader["Dimension1"], CultureInfo.InvariantCulture.NumberFormat);
     74      int dim2 = int.Parse(reader["Dimension2"], CultureInfo.InvariantCulture.NumberFormat);
     75      string[] tokens = reader.ReadString().Split(';');
    6376      int[,] data = new int[dim1, dim2];
    64       for (int i = 0; i < dim1; i++) {
    65         for (int j = 0; j < dim2; j++) {
     77      for(int i = 0; i < dim1; i++) {
     78        for(int j = 0; j < dim2; j++) {
    6679          data[i, j] = int.Parse(tokens[i * dim2 + j], CultureInfo.InvariantCulture.NumberFormat);
    6780        }
  • branches/XmlTextReaderBranch/HeuristicLab.Data/ItemList_T.cs

    r69 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       for (int i = 0; i < node.ChildNodes.Count; i++)
    61         list.Add((T) PersistenceManager.Restore(node.ChildNodes[i], restoredObjects));
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  for(int i = 0; i < node.ChildNodes.Count; i++)
     61    //    list.Add((T)PersistenceManager.Restore(node.ChildNodes[i], restoredObjects));
     62    //}
     63    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     64      base.Populate(reader, restoredObjects);
     65      while(reader.IsStartElement())
     66        list.Add((T)PersistenceManager.Restore(reader, restoredObjects));
    6267    }
    6368
  • branches/XmlTextReaderBranch/HeuristicLab.Data/StringData.cs

    r2 r121  
    5656      return node;
    5757    }
    58     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    59       base.Populate(node, restoredObjects);
    60       Data = node.InnerText;
     58    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     59    //  base.Populate(node, restoredObjects);
     60    //  Data = node.InnerText;
     61    //}
     62    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
     63      base.Populate(reader, restoredObjects);
     64      Data = reader.ReadString();
    6165    }
    6266
Note: See TracChangeset for help on using the changeset viewer.