aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-10-14 16:12:07 -0700
committerRob Mensching <rob@firegiant.com>2017-10-14 16:12:07 -0700
commitdbde9e7104b907bbbaea17e21247d8cafc8b3a4c (patch)
tree0f5fbbb6fe12c6b2e5e622a0e18ce4c5b4eb2b96 /src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
parentfbf986eb97f68396797a89fc7d40dec07b775440 (diff)
downloadwix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.gz
wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.bz2
wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.zip
Massive refactoring to introduce the concept of IBackend
Diffstat (limited to 'src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs')
-rw-r--r--src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
index 68bfd8d7..7de40fb8 100644
--- a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
+++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
@@ -1,19 +1,26 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Bind 3namespace WixToolset.Core.Bind
4{ 4{
5 using System.Collections.Generic;
5 using System.IO; 6 using System.IO;
7 using System.Linq;
6 using System.Reflection; 8 using System.Reflection;
7 using WixToolset.Data; 9 using WixToolset.Data;
10 using WixToolset.Extensibility;
8 11
9 internal class ExtractEmbeddedFilesCommand : ICommand 12 public class ExtractEmbeddedFilesCommand
10 { 13 {
11 public ExtractEmbeddedFiles FilesWithEmbeddedFiles { private get; set; } 14 public IEnumerable<IExpectedExtractFile> FilesWithEmbeddedFiles { private get; set; }
12 15
13 public void Execute() 16 public void Execute()
14 { 17 {
15 foreach (var baseUri in this.FilesWithEmbeddedFiles.Uris) 18 var group = this.FilesWithEmbeddedFiles.GroupBy(e => e.Uri);
19
20 foreach (var expectedEmbeddedFileByUri in group)
16 { 21 {
22 var baseUri = expectedEmbeddedFileByUri.Key;
23
17 Stream stream = null; 24 Stream stream = null;
18 try 25 try
19 { 26 {
@@ -34,18 +41,20 @@ namespace WixToolset.Bind
34 41
35 using (FileStructure fs = FileStructure.Read(stream)) 42 using (FileStructure fs = FileStructure.Read(stream))
36 { 43 {
37 foreach (var embeddedFile in this.FilesWithEmbeddedFiles.GetExtractFilesForUri(baseUri)) 44 var uniqueIndicies = new SortedSet<int>();
45
46 foreach (var embeddedFile in expectedEmbeddedFileByUri)
38 { 47 {
39 fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); 48 if (uniqueIndicies.Add(embeddedFile.EmbeddedFileIndex))
49 {
50 fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath);
51 }
40 } 52 }
41 } 53 }
42 } 54 }
43 finally 55 finally
44 { 56 {
45 if (null != stream) 57 stream?.Close();
46 {
47 stream.Close();
48 }
49 } 58 }
50 } 59 }
51 } 60 }