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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r8084 r8180  
    2222using System;
    2323using System.Collections.Generic;
     24using System.IO;
     25using System.Text;
    2426using HeuristicLab.Problems.DataAnalysis;
    2527
     
    4547    }
    4648
     49    public override bool CanSaveData {
     50      get { return true; }
     51    }
     52
     53    public override void SaveData(IClusteringProblemData instance, string path) {
     54      var 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      var 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 (var writer = new StreamWriter(path)) {
     73        writer.Write(strBuilder);
     74      }
     75    }
     76
    4777    public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
    4878      throw new NotImplementedException();
Note: See TracChangeset for help on using the changeset viewer.