Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/02/12 16:07:35 (12 years ago)
Author:
sforsten
Message:

#1782:

  • added CanSave property to IProblemInstanceProvider to know if it can save its data
  • ProblemInstanceConsumerViewGeneric only shows the export button if an IProblemInstanceExporter is available and the selected SelectedProvider has the CanSave property set to true
  • added a default implementation for CanSave and SaveData to ProblemInstanceProvider, so classes which inherit from it, don't have to implement it.
  • Classes in Problems.Instances.DataAnalysis which implemented the IProblemInstanceProvider now inherit from the class ProblemInstanceProvider, so some code is obsolete now and had been deleted
Location:
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs

    r7860 r8180  
    2323using System;
    2424using System.Collections.Generic;
     25using System.IO;
     26using System.Text;
    2527using HeuristicLab.Problems.DataAnalysis;
    2628namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4143    }
    4244
     45    public override bool CanSaveData {
     46      get { return true; }
     47    }
     48
    4349    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    4450      return new List<IDataDescriptor>();
     51    }
     52
     53    public override void SaveData(IRegressionProblemData instance, string path) {
     54      StringBuilder strBuilder = new StringBuilder();
     55
     56      foreach (var variable in instance.InputVariables) {
     57        strBuilder.Append(variable + ";");
     58      }
     59      strBuilder.Remove(strBuilder.Length - 1, 1);
     60      strBuilder.AppendLine();
     61
     62      Dataset dataset = instance.Dataset;
     63
     64      for (int i = 0; i < dataset.Rows; i++) {
     65        for (int j = 0; j < dataset.Columns; j++) {
     66          strBuilder.Append(dataset.GetValue(i, j) + ";");
     67        }
     68        strBuilder.Remove(strBuilder.Length - 1, 1);
     69        strBuilder.AppendLine();
     70      }
     71
     72      using (StreamWriter writer = new StreamWriter(path)) {
     73        writer.Write(strBuilder);
     74      }
    4575    }
    4676
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs

    r7965 r8180  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections;
    2423using System.Collections.Generic;
    25 using System.IO;
    2624using System.Linq;
    27 using System.Text;
    2825using HeuristicLab.Problems.DataAnalysis;
    2926
    3027namespace HeuristicLab.Problems.Instances.DataAnalysis {
    31   public abstract class RegressionInstanceProvider : IProblemInstanceProvider<IRegressionProblemData> {
     28  public abstract class RegressionInstanceProvider : ProblemInstanceProvider<IRegressionProblemData> {
    3229
    33     public IRegressionProblemData LoadData(string path) {
     30    public override IRegressionProblemData LoadData(string path) {
    3431      TableFileParser csvFileParser = new TableFileParser();
    3532      csvFileParser.Parse(path);
     
    5754      return regData;
    5855    }
    59 
    60     public void SaveData(IRegressionProblemData instance, string path) {
    61       StringBuilder strBuilder = new StringBuilder();
    62 
    63       foreach (var variable in instance.InputVariables) {
    64         strBuilder.Append(variable + ";");
    65       }
    66       strBuilder.Remove(strBuilder.Length - 1, 1);
    67       strBuilder.AppendLine();
    68 
    69       Dataset dataset = instance.Dataset;
    70 
    71       for (int i = 0; i < dataset.Rows; i++) {
    72         for (int j = 0; j < dataset.Columns; j++) {
    73           strBuilder.Append(dataset.GetValue(i, j) + ";");
    74         }
    75         strBuilder.Remove(strBuilder.Length - 1, 1);
    76         strBuilder.AppendLine();
    77       }
    78 
    79       using (StreamWriter writer = new StreamWriter(path)) {
    80         writer.Write(strBuilder);
    81       }
    82     }
    83 
    84     public abstract IEnumerable<IDataDescriptor> GetDataDescriptors();
    85     public abstract IRegressionProblemData LoadData(IDataDescriptor descriptor);
    86 
    87     public abstract string Name { get; }
    88     public abstract string Description { get; }
    89     public abstract Uri WebLink { get; }
    90     public abstract string ReferencePublication { get; }
    9156  }
    9257}
Note: See TracChangeset for help on using the changeset viewer.