Free cookie consent management tool by TermsFeed Policy Generator

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

bug fixes to make loading of OSGA-TSP work. Some non-working code remains

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/XmlTextReaderBranch/HeuristicLab.Core/ConstrainedItemBase.cs

    r121 r122  
    3939      ConstrainedItemBase clone = (ConstrainedItemBase)base.Clone(clonedObjects);
    4040      clone.myConstraints.Clear();
    41       foreach (IConstraint constraint in Constraints)
     41      foreach(IConstraint constraint in Constraints)
    4242        clone.AddConstraint((IConstraint)Auxiliary.Clone(constraint, clonedObjects));
    4343      return clone;
     
    4949    }
    5050    public virtual void RemoveConstraint(IConstraint constraint) {
    51       if (myConstraints.Remove(constraint))
     51      if(myConstraints.Remove(constraint))
    5252        OnConstraintRemoved(constraint);
    5353    }
     
    5555    public bool IsValid() {
    5656      bool result = true;
    57       foreach (IConstraint constraint in Constraints)
     57      foreach(IConstraint constraint in Constraints)
    5858        result = result && constraint.Check(this);
    5959      return result;
     
    6262      bool result = true;
    6363      violatedConstraints = new List<IConstraint>();
    64       foreach (IConstraint constraint in Constraints) {
    65         if (!constraint.Check(this)) {
     64      foreach(IConstraint constraint in Constraints) {
     65        if(!constraint.Check(this)) {
    6666          result = false;
    6767          violatedConstraints.Add(constraint);
     
    7777    public event EventHandler<ConstraintEventArgs> ConstraintAdded;
    7878    protected virtual void OnConstraintAdded(IConstraint constraint) {
    79       if (ConstraintAdded != null)
     79      if(ConstraintAdded != null)
    8080        ConstraintAdded(this, new ConstraintEventArgs(constraint));
    8181    }
    8282    public event EventHandler<ConstraintEventArgs> ConstraintRemoved;
    8383    protected virtual void OnConstraintRemoved(IConstraint constraint) {
    84       if (ConstraintRemoved != null)
     84      if(ConstraintRemoved != null)
    8585        ConstraintRemoved(this, new ConstraintEventArgs(constraint));
    8686    }
    8787
    8888    #region Persistence Methods
    89     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
     89    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    9090      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    91       if (Constraints.Count > 0) {
     91      if(Constraints.Count > 0) {
    9292        XmlNode constraintsNode = document.CreateNode(XmlNodeType.Element, "Constraints", null);
    93         foreach (IConstraint constraint in Constraints)
     93        foreach(IConstraint constraint in Constraints)
    9494          constraintsNode.AppendChild(PersistenceManager.Persist(constraint, document, persistedObjects));
    9595        node.AppendChild(constraintsNode);
     
    108108    public override void Populate(XmlReader reader, IDictionary<Guid, IStorable> restoredObjects) {
    109109      base.Populate(reader, restoredObjects);
    110       if(reader.IsStartElement()) {
    111         reader.ReadToDescendant("Constraints");
     110      reader.Read();
     111      if(reader.Name == "Constraints") {
    112112        myConstraints.Clear();
    113113        while(reader.IsStartElement())
Note: See TracChangeset for help on using the changeset viewer.