From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs | 36 +++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs') diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs index 0ecd0096..28fc4817 100644 --- a/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs +++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs @@ -1,6 +1,6 @@ // 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. -namespace WixToolset.Bind +namespace WixToolset.Core.Bind { using System; using System.Collections.Generic; @@ -13,11 +13,11 @@ namespace WixToolset.Bind /// /// Internal helper class used to extract embedded files. /// - internal sealed class ExtractEmbeddedFiles + internal class ExtractEmbeddedFiles { private Dictionary> filesWithEmbeddedFiles = new Dictionary>(); - public IEnumerable Uris { get { return this.filesWithEmbeddedFiles.Keys; } } + public IEnumerable Uris => this.filesWithEmbeddedFiles.Keys; /// /// Adds an embedded file index to track and returns the path where the embedded file will be extracted. Duplicates will return the same extract path. @@ -53,15 +53,30 @@ namespace WixToolset.Bind return extractPath; } - public IEnumerable GetExtractFilesForUri(Uri uri) + public IEnumerable GetExpectedEmbeddedFiles() { - SortedList extracts; - if (!filesWithEmbeddedFiles.TryGetValue(uri, out extracts)) + foreach (var uriWithExtracts in filesWithEmbeddedFiles) + { + foreach (var extracts in uriWithExtracts.Value) + { + yield return new ExpectedExtractFile + { + Uri = uriWithExtracts.Key, + EmbeddedFileIndex = extracts.Key, + OutputPath = extracts.Value, + }; + } + } + } + + public IEnumerable GetExtractFilesForUri(Uri uri) + { + if (!filesWithEmbeddedFiles.TryGetValue(uri, out var extracts)) { extracts = new SortedList(); } - return extracts.Select(e => new ExtractFile() { EmbeddedFileIndex = e.Key, OutputPath = e.Value }); + return extracts.Select(e => new ExpectedExtractFile() { Uri = uri, EmbeddedFileIndex = e.Key, OutputPath = e.Value }); } private string HashUri(string uri) @@ -72,12 +87,5 @@ namespace WixToolset.Bind return Convert.ToBase64String(hash).TrimEnd('=').Replace('+', '-').Replace('/', '_'); } } - - internal struct ExtractFile - { - public int EmbeddedFileIndex { get; set; } - - public string OutputPath { get; set; } - } } } -- cgit v1.2.3-55-g6feb