Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/15 11:23:56 (10 years ago)
Author:
mkommend
Message:

#2174: Updated HL.Optimization with trunk changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/ResultCollection.cs

    r11171 r11812  
    4444      get { return HeuristicLab.Common.Resources.VSImageLibrary.Object; }
    4545    }
     46
     47    public virtual void CollectResultValues(IDictionary<string, IItem> values) {
     48      CollectResultValues(values, string.Empty);
     49    }
     50
     51    public virtual void CollectResultValues(IDictionary<string, IItem> values, string rootPath) {
     52      foreach (IResult result in this) {
     53        var children = GetCollectedResults(result);
     54        string path = string.Empty;
     55        if (!string.IsNullOrWhiteSpace(rootPath))
     56          path = rootPath + ".";
     57        foreach (var c in children) {
     58          if (string.IsNullOrEmpty(c.Key))
     59            values.Add(path + result.Name, c.Value);
     60          else values.Add(path + result.Name + "." + c.Key, c.Value);
     61        }
     62      }
     63    }
     64
     65    protected virtual IEnumerable<KeyValuePair<string, IItem>> GetCollectedResults(IResult result) {
     66      if (result.Value == null) yield break;
     67      yield return new KeyValuePair<string, IItem>(string.Empty, result.Value);
     68
     69      var resultCollection = result.Value as ResultCollection;
     70      if (resultCollection != null) {
     71        var children = new Dictionary<string, IItem>();
     72        resultCollection.CollectResultValues(children);
     73        foreach (var child in children) yield return child;
     74      }
     75    }
     76
    4677  }
    4778}
Note: See TracChangeset for help on using the changeset viewer.