Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8108


Ignore:
Timestamp:
06/25/12 17:21:36 (12 years ago)
Author:
abeham
Message:

#1869:

  • Removed ToEnumerable extension method (I agree with gkronber and it's just one occurrence)
  • Reset rowNumber to 0 when rebuilding the combined data table
  • Some minor changes (moved ctor below variable/property declaration, replaced some obvious variable types with var)
Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs

    r7981 r8108  
    3131namespace HeuristicLab.Common {
    3232  public static class ObjectExtensions {
    33     public static IEnumerable<T> ToEnumerable<T>(this T item) {
    34       return new[] { item };
    35     }
    36 
    3733    public static IEnumerable<object> GetObjectGraphObjects(this object obj, HashSet<string> excludedMembers = null, bool excludeStaticMembers = false) {
    3834      if (obj == null) return Enumerable.Empty<object>();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionDataTableView.cs

    r7986 r8108  
    2626using HeuristicLab.Analysis;
    2727using HeuristicLab.Collections;
    28 using HeuristicLab.Common;
    2928using HeuristicLab.Core.Views;
    3029using HeuristicLab.MainForm;
     
    3635    private const string AllDataRows = "All DataRows";
    3736
    38     public RunCollectionDataTableView() {
    39       InitializeComponent();
    40       runMapping = new Dictionary<IRun, IEnumerable<DataRow>>();
    41       combinedDataTable = new DataTable("Combined DataTable", "A data table containing all data rows from all run.");
    42       viewHost.Content = combinedDataTable;
    43       suppressUpdates = false;
    44     }
    45 
    4637    public new RunCollection Content {
    4738      get { return (RunCollection)base.Content; }
     
    4940    }
    5041
     42    private int rowNumber = 0;
    5143    private bool suppressUpdates;
    5244    private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping;
     
    5446    public DataTable CombinedDataTable {
    5547      get { return combinedDataTable; }
     48    }
     49
     50    public RunCollectionDataTableView() {
     51      InitializeComponent();
     52      runMapping = new Dictionary<IRun, IEnumerable<DataRow>>();
     53      combinedDataTable = new DataTable("Combined DataTable", "A data table containing data rows from multiple runs.");
     54      viewHost.Content = combinedDataTable;
     55      suppressUpdates = false;
    5656    }
    5757
     
    111111    private void run_Changed(object sender, EventArgs e) {
    112112      if (suppressUpdates) return;
    113       IRun run = (IRun)sender;
    114       UpdateRuns(run.ToEnumerable());
    115 
     113      var run = (IRun)sender;
     114      UpdateRuns(new IRun[] { run });
    116115    }
    117116    #endregion
     
    131130    private void RebuildCombinedDataTable() {
    132131      RemoveRuns(Content);
     132      rowNumber = 0;
    133133      AddRuns(Content);
    134134    }
     
    142142      combinedDataTable.Rows.AddRange(dataRows);
    143143    }
     144
    144145    private void RemoveRuns(IEnumerable<IRun> runs) {
    145146      var dataRows = runs.Where(r => runMapping.ContainsKey(r)).SelectMany(r => runMapping[r]).ToList();
     
    165166    }
    166167
    167     private int rowNumber = 0;
    168168    private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) {
    169       string resultName = (string)dataTableComboBox.SelectedItem;
    170       string rowName = (string)dataRowComboBox.SelectedItem;
     169      var resultName = (string)dataTableComboBox.SelectedItem;
     170      var rowName = (string)dataRowComboBox.SelectedItem;
    171171      if (!run.Results.ContainsKey(resultName)) yield break;
    172172
    173       DataTable dataTable = (DataTable)run.Results[resultName];
     173      var dataTable = (DataTable)run.Results[resultName];
    174174      foreach (var dataRow in dataTable.Rows) {
    175175        if (dataRow.Name != rowName && rowName != AllDataRows) continue;
     
    197197    private void UpdateDataRowComboBox() {
    198198      dataRowComboBox.Items.Clear();
    199       string resultName = (string)dataTableComboBox.SelectedItem;
     199      var resultName = (string)dataTableComboBox.SelectedItem;
    200200      var dataTables = from run in Content
    201201                       where run.Results.ContainsKey(resultName)
Note: See TracChangeset for help on using the changeset viewer.