Changeset 7667 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ResourceRegressionInstanceProvider.cs
- Timestamp:
- 03/27/12 16:58:22 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ResourceRegressionInstanceProvider.cs
r7666 r7667 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.IO; 23 25 using System.Linq; … … 30 32 31 33 protected abstract string FileExtension { get; } 34 35 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 36 var solutionsArchiveName = GetResourceName(FileExtension + @"\.zip"); 37 if (!String.IsNullOrEmpty(solutionsArchiveName)) { 38 using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) { 39 foreach (var entry in GetZipContents(solutionsZipFile).OrderBy(x => x)) 40 yield return new ResourceRegressionDataDescriptor(Path.GetFileNameWithoutExtension(entry), Description, entry); 41 } 42 } 43 } 32 44 33 45 public override RegressionData LoadData(IDataDescriptor id) { … … 44 56 return Assembly.GetExecutingAssembly().GetManifestResourceNames() 45 57 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 58 } 59 60 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) { 61 ZipEntry entry; 62 while ((entry = zipFile.GetNextEntry()) != null) { 63 yield return entry.Name; 64 } 46 65 } 47 66
Note: See TracChangeset
for help on using the changeset viewer.