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/ClusteringInstanceProvider.cs

    r8084 r8180  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.IO;
    25 using System.Text;
    2622using HeuristicLab.Problems.DataAnalysis;
    2723
    2824namespace HeuristicLab.Problems.Instances.DataAnalysis {
    29   public abstract class ClusteringInstanceProvider : IProblemInstanceProvider<IClusteringProblemData> {
    30     public IClusteringProblemData LoadData(string path) {
     25  public abstract class ClusteringInstanceProvider : ProblemInstanceProvider<IClusteringProblemData> {
     26    public override IClusteringProblemData LoadData(string path) {
    3127      var csvFileParser = new TableFileParser();
    3228
     
    5147      return claData;
    5248    }
    53 
    54     public void SaveData(IClusteringProblemData instance, string path) {
    55       var strBuilder = new StringBuilder();
    56 
    57       foreach (var variable in instance.InputVariables) {
    58         strBuilder.Append(variable + ";");
    59       }
    60       strBuilder.Remove(strBuilder.Length - 1, 1);
    61       strBuilder.AppendLine();
    62 
    63       var dataset = instance.Dataset;
    64 
    65       for (int i = 0; i < dataset.Rows; i++) {
    66         for (int j = 0; j < dataset.Columns; j++) {
    67           strBuilder.Append(dataset.GetValue(i, j) + ";");
    68         }
    69         strBuilder.Remove(strBuilder.Length - 1, 1);
    70         strBuilder.AppendLine();
    71       }
    72 
    73       using (var writer = new StreamWriter(path)) {
    74         writer.Write(strBuilder);
    75       }
    76     }
    77 
    78     public abstract IEnumerable<IDataDescriptor> GetDataDescriptors();
    79     public abstract IClusteringProblemData LoadData(IDataDescriptor descriptor);
    80 
    81     public abstract string Name { get; }
    82     public abstract string Description { get; }
    83     public abstract Uri WebLink { get; }
    84     public abstract string ReferencePublication { get; }
    8549  }
    8650}
Note: See TracChangeset for help on using the changeset viewer.