Changeset 12969 for branches/gteufl/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs
- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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.