#region License Information /* HeuristicLab * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.IO; using System.Linq; using System.Reflection; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Problems.DataAnalysis.Benchmarks { public abstract class Benchmark : NamedItem { protected Benchmark() { } protected Benchmark(Benchmark original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { throw new System.NotImplementedException(); } #region Helpers protected static TableFileParser getParserForFile(string fileName) { Assembly assembly = Assembly.GetExecutingAssembly(); string file = assembly.GetManifestResourceNames().Where(x => x.EndsWith(fileName)).First(); string path = Path.GetTempFileName(); using (Stream stream = assembly.GetManifestResourceStream(file)) { WriteStreamToTempFile(stream, path); } TableFileParser csvFileParser = new TableFileParser(); csvFileParser.Parse(path); return csvFileParser; } private static void WriteStreamToTempFile(Stream stream, string path) { using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) { int cnt = 0; byte[] buffer = new byte[32 * 1024]; while ((cnt = stream.Read(buffer, 0, buffer.Length)) != 0) output.Write(buffer, 0, cnt); } } #endregion } }