Changeset 12694 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs
- Timestamp:
- 07/09/15 13:07:30 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections.Generic; 24 24 using System.IO; 25 using System.IO.Compression; 25 26 using System.Linq; 26 27 using System.Reflection; 27 28 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip;29 29 30 30 namespace HeuristicLab.Problems.Instances.TSPLIB { … … 52 52 var solutionsArchiveName = GetResourceName(FileExtension + @"\.opt\.tour\.zip"); 53 53 if (!String.IsNullOrEmpty(solutionsArchiveName)) { 54 using (var solutionsZipFile = new Zip InputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {55 foreach (var entry in GetZipContents(solutionsZipFile))56 solutions.Add(entry. Substring(0, entry.Length - ".opt.tour".Length) + "." + FileExtension, entry);54 using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) { 55 foreach (var entry in solutionsZipFile.Entries) 56 solutions.Add(entry.Name.Substring(0, entry.Name.Length - ".opt.tour".Length) + "." + FileExtension, entry.Name); 57 57 } 58 58 } … … 60 60 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 61 61 62 using (var instanceStream = new Zip InputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {63 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) {62 using (var instanceStream = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) { 63 foreach (var entry in instanceStream.Entries.Select(x => x.Name).OrderBy(x => x)) { 64 64 yield return new TSPLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetInstanceDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty); 65 65 } … … 70 70 var descriptor = (TSPLIBDataDescriptor)id; 71 71 var instanceArchiveName = GetResourceName(FileExtension + @"\.zip"); 72 using (var instancesZipFile = new Zip File(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {72 using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) { 73 73 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 74 var stream = instancesZipFile.GetInputStream(entry);74 var stream = entry.Open(); 75 75 var parser = new TSPLIBParser(stream); 76 76 var instance = LoadInstance(parser); … … 78 78 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 79 79 var solutionsArchiveName = GetResourceName(FileExtension + @"\.opt\.tour\.zip"); 80 using (var solutionsZipFile = new Zip File(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {80 using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) { 81 81 entry = solutionsZipFile.GetEntry(descriptor.SolutionIdentifier); 82 stream = solutionsZipFile.GetInputStream(entry);82 stream = entry.Open(); 83 83 parser = new TSPLIBParser(stream); 84 84 LoadSolution(parser, instance); … … 105 105 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + "."; 106 106 } 107 108 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {109 ZipEntry entry;110 while ((entry = zipFile.GetNextEntry()) != null) {111 yield return entry.Name;112 }113 }114 107 } 115 108 }
Note: See TracChangeset
for help on using the changeset viewer.