- Timestamp:
- 05/16/12 16:28:49 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 21 deleted
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs
r7548 r7842 26 26 using System.Reflection; 27 27 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip; 28 29 29 30 namespace HeuristicLab.Problems.Instances.CordeauGQAP { … … 49 50 } 50 51 52 private const string FileName = "CordeauGQAP"; 53 51 54 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 52 return Assembly.GetExecutingAssembly() 53 .GetManifestResourceNames() 54 .Where(x => x.EndsWith(".txt")) 55 .OrderBy(x => x) 56 .Select(x => new CordeauGQAPDataDescriptor(GetPrettyName(x), GetDescription(), x)); 55 var instanceArchiveName = GetResourceName(FileName + @"\.zip"); 56 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 57 58 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 59 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 60 yield return new CordeauGQAPDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry); 61 } 62 } 57 63 } 58 64 59 65 public override GQAPData LoadData(IDataDescriptor id) { 60 66 var descriptor = (CordeauGQAPDataDescriptor)id; 61 using (var stream = Assembly.GetExecutingAssembly() 62 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 63 var parser = new CordeauGQAPParser(); 64 parser.Parse(stream); 65 var instance = Load(parser); 67 var instanceArchiveName = GetResourceName(FileName + @"\.zip"); 68 using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 69 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 70 using (var stream = instancesZipFile.GetInputStream(entry)) { 71 var parser = new CordeauGQAPParser(); 72 parser.Parse(stream); 73 var instance = Load(parser); 66 74 67 instance.Name = id.Name;68 instance.Description = id.Description;75 instance.Name = id.Name; 76 instance.Description = id.Description; 69 77 70 return instance; 78 return instance; 79 } 71 80 } 72 81 } … … 100 109 } 101 110 102 private string GetPrettyName(string instanceIdentifier) {103 return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.txt").Groups[1].Captures[0].Value;104 }105 106 111 private string GetDescription() { 107 112 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + "."; 108 113 } 114 115 protected virtual string GetResourceName(string fileName) { 116 return Assembly.GetExecutingAssembly().GetManifestResourceNames() 117 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 118 } 119 120 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) { 121 ZipEntry entry; 122 while ((entry = zipFile.GetNextEntry()) != null) { 123 yield return entry.Name; 124 } 125 } 109 126 } 110 127 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/HeuristicLab.Problems.Instances.CordeauGQAP-3.3.csproj
r7600 r7842 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL"> 105 <Private>False</Private> 106 </Reference> 104 107 <Reference Include="System" /> 105 108 <Reference Include="System.Core" /> … … 107 110 </ItemGroup> 108 111 <ItemGroup> 112 <EmbeddedResource Include="Data\CordeauGQAP.zip" /> 109 113 <None Include="Plugin.cs.frame" /> 110 114 <Compile Include="CordeauGQAPParser.cs" /> … … 122 126 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 123 127 <Name>HeuristicLab.Common-3.3</Name> 128 <Private>False</Private> 124 129 </ProjectReference> 125 130 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 126 131 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 127 132 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 133 <Private>False</Private> 128 134 </ProjectReference> 129 135 <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj"> 130 136 <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project> 131 137 <Name>HeuristicLab.Problems.Instances-3.3</Name> 138 <Private>False</Private> 132 139 </ProjectReference> 133 </ItemGroup>134 <ItemGroup>135 <EmbeddedResource Include="Data\20-15-35.txt" />136 <EmbeddedResource Include="Data\20-15-55.txt" />137 <EmbeddedResource Include="Data\20-15-75.txt" />138 <EmbeddedResource Include="Data\30-06-95.txt" />139 <EmbeddedResource Include="Data\30-07-75.txt" />140 <EmbeddedResource Include="Data\30-08-55.txt" />141 <EmbeddedResource Include="Data\30-10-65.txt" />142 <EmbeddedResource Include="Data\30-20-35.txt" />143 <EmbeddedResource Include="Data\30-20-55.txt" />144 <EmbeddedResource Include="Data\30-20-75.txt" />145 <EmbeddedResource Include="Data\30-20-95.txt" />146 <EmbeddedResource Include="Data\35-15-35.txt" />147 <EmbeddedResource Include="Data\35-15-55.txt" />148 <EmbeddedResource Include="Data\35-15-75.txt" />149 <EmbeddedResource Include="Data\35-15-95.txt" />150 <EmbeddedResource Include="Data\40-07-75.txt" />151 <EmbeddedResource Include="Data\40-09-95.txt" />152 <EmbeddedResource Include="Data\40-10-65.txt" />153 <EmbeddedResource Include="Data\50-10-65.txt" />154 <EmbeddedResource Include="Data\50-10-75.txt" />155 <EmbeddedResource Include="Data\50-10-95.txt" />156 140 </ItemGroup> 157 141 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset
for help on using the changeset viewer.