Changeset 11677 for branches/ALPS/HeuristicLab.Persistence
- Timestamp:
- 12/10/14 10:31:41 (10 years ago)
- Location:
- branches/ALPS
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS
-
branches/ALPS/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence (added) merged: 11623,11650
- Property svn:mergeinfo changed
-
branches/ALPS/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
r11171 r11677 30 30 using HeuristicLab.Persistence.Interfaces; 31 31 using HeuristicLab.Tracing; 32 using ICSharpCode.SharpZipLib.Zip;33 32 34 33 namespace HeuristicLab.Persistence.Default.Xml { … … 286 285 /// <param name="filename">The filename.</param> 287 286 public static void Serialize(object o, string filename) { 288 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, 5);287 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, CompressionLevel.Optimal); 289 288 } 290 289 … … 297 296 /// <param name="filename">The filename.</param> 298 297 /// <param name="compression">ZIP file compression level</param> 299 public static void Serialize(object o, string filename, intcompression) {298 public static void Serialize(object o, string filename, CompressionLevel compression) { 300 299 Serialize(o, filename, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, compression); 301 300 } … … 309 308 /// <param name="config">The configuration.</param> 310 309 public static void Serialize(object obj, string filename, Configuration config) { 311 Serialize(obj, filename, config, false, 5);310 Serialize(obj, filename, config, false, CompressionLevel.Optimal); 312 311 } 313 312 … … 320 319 /// <param name="includeAssemblies">if set to <c>true</c> include needed assemblies.</param> 321 320 /// <param name="compression">The ZIP compression level.</param> 322 public static void Serialize(object obj, string filename, Configuration config, bool includeAssemblies, intcompression) {321 public static void Serialize(object obj, string filename, Configuration config, bool includeAssemblies, CompressionLevel compression) { 323 322 try { 324 323 string tempfile = Path.GetTempFileName(); … … 328 327 serializer.InterleaveTypeInformation = false; 329 328 XmlGenerator generator = new XmlGenerator(); 330 using (ZipOutputStream zipStream = new ZipOutputStream(stream)) { 331 zipStream.IsStreamOwner = false; 332 zipStream.SetLevel(compression); 333 zipStream.PutNextEntry(new ZipEntry("data.xml") { DateTime = DateTime.MinValue }); 334 StreamWriter writer = new StreamWriter(zipStream); 335 foreach (ISerializationToken token in serializer) { 336 string line = generator.Format(token); 337 writer.Write(line); 329 using (ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Create)) { 330 ZipArchiveEntry entry = zipArchive.CreateEntry("data.xml", compression); 331 using (StreamWriter writer = new StreamWriter(entry.Open())) { 332 foreach (ISerializationToken token in serializer) { 333 string line = generator.Format(token); 334 writer.Write(line); 335 } 338 336 } 339 writer.Flush(); 340 zipStream.PutNextEntry(new ZipEntry("typecache.xml") { DateTime = DateTime.MinValue }); 341 foreach (string line in generator.Format(serializer.TypeCache)) { 342 writer.Write(line); 337 entry = zipArchive.CreateEntry("typecache.xml", compression); 338 using (StreamWriter writer = new StreamWriter(entry.Open())) { 339 foreach (string line in generator.Format(serializer.TypeCache)) { 340 writer.Write(line); 341 } 343 342 } 344 writer.Flush();345 343 if (includeAssemblies) { 346 344 foreach (string name in serializer.RequiredFiles) { … … 350 348 continue; 351 349 } 352 zipStream.PutNextEntry(new ZipEntry(Path.GetFileName(uri.PathAndQuery))); 353 FileStream reader = File.OpenRead(uri.PathAndQuery); 354 byte[] buffer = new byte[1024 * 1024]; 355 while (true) { 356 int bytesRead = reader.Read(buffer, 0, 1024 * 1024); 357 if (bytesRead == 0) 358 break; 359 zipStream.Write(buffer, 0, bytesRead); 350 entry = zipArchive.CreateEntry(Path.GetFileName(uri.PathAndQuery), compression); 351 using (BinaryWriter bw = new BinaryWriter(entry.Open())) { 352 using (FileStream reader = File.OpenRead(uri.PathAndQuery)) { 353 byte[] buffer = new byte[1024 * 1024]; 354 while (true) { 355 int bytesRead = reader.Read(buffer, 0, 1024 * 1024); 356 if (bytesRead == 0) 357 break; 358 bw.Write(buffer, 0, bytesRead); 359 } 360 } 360 361 } 361 writer.Flush();362 362 } 363 363 } … … 407 407 Serializer serializer = new Serializer(obj, config); 408 408 Serialize(stream, serializer); 409 } catch (PersistenceException) { 409 } 410 catch (PersistenceException) { 410 411 throw; 411 } catch (Exception e) { 412 } 413 catch (Exception e) { 412 414 throw new PersistenceException("Unexpected exception during Serialization.", e); 413 415 } … … 427 429 Serialize(stream, serializer); 428 430 types = serializer.SerializedTypes; 429 } catch (PersistenceException) { 431 } 432 catch (PersistenceException) { 430 433 throw; 431 } catch (Exception e) { 434 } 435 catch (Exception e) { 432 436 throw new PersistenceException("Unexpected exception during Serialization.", e); 433 437 } -
branches/ALPS/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
r11171 r11677 29 29 using HeuristicLab.Persistence.Core.Tokens; 30 30 using HeuristicLab.Persistence.Interfaces; 31 using ICSharpCode.SharpZipLib.Zip;32 31 33 32 namespace HeuristicLab.Persistence.Default.Xml { … … 193 192 TimeSpan start = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime; 194 193 try { 195 using (ZipFile file = new ZipFile(filename)) { 196 return Deserialize(file); 194 using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { 195 using (ZipArchive zip = new ZipArchive(fs)) { 196 return Deserialize(zip); 197 } 197 198 } 198 199 } … … 247 248 } 248 249 249 private static object Deserialize(ZipFile zipFile) { 250 try { 251 ZipEntry typecache = zipFile.GetEntry("typecache.xml"); 252 if (typecache == null) 253 throw new PersistenceException("file does not contain typecache.xml"); 254 Deserializer deSerializer = new Deserializer(ParseTypeCache(new StreamReader(zipFile.GetInputStream(typecache)))); 255 ZipEntry data = zipFile.GetEntry("data.xml"); 256 if (data == null) 257 throw new PersistenceException("file does not contain data.xml"); 258 XmlParser parser = new XmlParser( 259 new StreamReader(zipFile.GetInputStream(data))); 260 object result = deSerializer.Deserialize(parser); 261 zipFile.Close(); 250 private static object Deserialize(ZipArchive zipFile) { 251 try { 252 ZipArchiveEntry typecache = zipFile.GetEntry("typecache.xml"); 253 if (typecache == null) throw new PersistenceException("file does not contain typecache.xml"); 254 Deserializer deSerializer; 255 using (StreamReader sr = new StreamReader(typecache.Open())) { 256 deSerializer = new Deserializer(ParseTypeCache(sr)); 257 } 258 259 ZipArchiveEntry data = zipFile.GetEntry("data.xml"); 260 if (data == null) throw new PersistenceException("file does not contain data.xml"); 261 object result; 262 using (StreamReader sr = new StreamReader(data.Open())) { 263 XmlParser parser = new XmlParser(sr); 264 result = deSerializer.Deserialize(parser); 265 } 266 262 267 return result; 263 268 } -
branches/ALPS/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
r11353 r11677 11 11 <RootNamespace>HeuristicLab.Persistence</RootNamespace> 12 12 <AssemblyName>HeuristicLab.Persistence-3.3</AssemblyName> 13 <TargetFrameworkVersion>v4. 0</TargetFrameworkVersion>13 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> 14 14 <TargetFrameworkProfile> 15 15 </TargetFrameworkProfile> … … 48 48 <WarningLevel>4</WarningLevel> 49 49 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 50 <Prefer32Bit>false</Prefer32Bit> 50 51 </PropertyGroup> 51 52 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> … … 60 61 <TreatWarningsAsErrors>false</TreatWarningsAsErrors> 61 62 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 63 <Prefer32Bit>false</Prefer32Bit> 62 64 </PropertyGroup> 63 65 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> … … 69 71 <ErrorReport>prompt</ErrorReport> 70 72 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 73 <Prefer32Bit>false</Prefer32Bit> 71 74 </PropertyGroup> 72 75 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> … … 80 83 </DocumentationFile> 81 84 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 85 <Prefer32Bit>false</Prefer32Bit> 82 86 </PropertyGroup> 83 87 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> … … 89 93 <ErrorReport>prompt</ErrorReport> 90 94 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 95 <Prefer32Bit>false</Prefer32Bit> 91 96 </PropertyGroup> 92 97 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> … … 100 105 </DocumentationFile> 101 106 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> 107 <Prefer32Bit>false</Prefer32Bit> 102 108 </PropertyGroup> 103 109 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> … … 110 116 --> 111 117 <ItemGroup> 112 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">113 <SpecificVersion>False</SpecificVersion>114 <HintPath>..\..\bin\ICSharpCode.SharpZipLib.dll</HintPath>115 <Private>False</Private>116 </Reference>117 118 <Reference Include="System" /> 118 119 <Reference Include="System.configuration" /> … … 122 123 <Reference Include="System.Data" /> 123 124 <Reference Include="System.Drawing" /> 125 <Reference Include="System.IO.Compression" /> 124 126 <Reference Include="System.Xml" /> 125 127 </ItemGroup> -
branches/ALPS/HeuristicLab.Persistence/3.3/Properties/Settings.Designer.cs
r4065 r11677 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319. 14 // Runtime Version:4.0.30319.34014 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 13 13 14 14 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "1 0.0.0.0")]15 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 16 internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 17 -
branches/ALPS/HeuristicLab.Persistence/3.3/app.config
r5163 r11677 16 16 </HeuristicLab.Persistence.Properties.Settings> 17 17 </userSettings> 18 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4. 0"/></startup></configuration>18 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
Note: See TracChangeset
for help on using the changeset viewer.