diff options
-rw-r--r-- | src/WixToolset.Extensibility/BaseBinderExtension.cs | 15 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Data/BindResult.cs | 2 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Data/FileTransfer.cs | 114 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Data/FileTransferType.cs | 17 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Data/IFileTransfer.cs | 30 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Data/ILayoutContext.cs | 2 | ||||
-rw-r--r-- | src/WixToolset.Extensibility/Services/IBackendHelper.cs | 23 |
7 files changed, 87 insertions, 116 deletions
diff --git a/src/WixToolset.Extensibility/BaseBinderExtension.cs b/src/WixToolset.Extensibility/BaseBinderExtension.cs index 51d63694..d533b0cb 100644 --- a/src/WixToolset.Extensibility/BaseBinderExtension.cs +++ b/src/WixToolset.Extensibility/BaseBinderExtension.cs | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
4 | { | 4 | { |
5 | using WixToolset.Extensibility.Data; | 5 | using WixToolset.Extensibility.Data; |
6 | using WixToolset.Extensibility.Services; | ||
6 | 7 | ||
7 | /// <summary> | 8 | /// <summary> |
8 | /// Base class for creating a resolver extension. | 9 | /// Base class for creating a resolver extension. |
@@ -15,11 +16,25 @@ namespace WixToolset.Extensibility | |||
15 | protected IBindContext Context { get; private set; } | 16 | protected IBindContext Context { get; private set; } |
16 | 17 | ||
17 | /// <summary> | 18 | /// <summary> |
19 | /// Messaging for use by the extension. | ||
20 | /// </summary> | ||
21 | protected IMessaging Messaging { get; private set; } | ||
22 | |||
23 | /// <summary> | ||
24 | /// BackendHelper for use by the extension. | ||
25 | /// </summary> | ||
26 | protected IBackendHelper BackendHelper { get; private set; } | ||
27 | |||
28 | /// <summary> | ||
18 | /// Called at the beginning of bind. | 29 | /// Called at the beginning of bind. |
19 | /// </summary> | 30 | /// </summary> |
20 | public virtual void PreBind(IBindContext context) | 31 | public virtual void PreBind(IBindContext context) |
21 | { | 32 | { |
22 | this.Context = context; | 33 | this.Context = context; |
34 | |||
35 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); | ||
36 | |||
37 | this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>(); | ||
23 | } | 38 | } |
24 | 39 | ||
25 | /// <summary> | 40 | /// <summary> |
diff --git a/src/WixToolset.Extensibility/Data/BindResult.cs b/src/WixToolset.Extensibility/Data/BindResult.cs index ec97154f..0ccaa08b 100644 --- a/src/WixToolset.Extensibility/Data/BindResult.cs +++ b/src/WixToolset.Extensibility/Data/BindResult.cs | |||
@@ -6,7 +6,7 @@ namespace WixToolset.Extensibility.Data | |||
6 | 6 | ||
7 | public class BindResult | 7 | public class BindResult |
8 | { | 8 | { |
9 | public IEnumerable<FileTransfer> FileTransfers { get; set; } | 9 | public IEnumerable<IFileTransfer> FileTransfers { get; set; } |
10 | 10 | ||
11 | public IEnumerable<string> ContentFilePaths { get; set; } | 11 | public IEnumerable<string> ContentFilePaths { get; set; } |
12 | } | 12 | } |
diff --git a/src/WixToolset.Extensibility/Data/FileTransfer.cs b/src/WixToolset.Extensibility/Data/FileTransfer.cs deleted file mode 100644 index 0356ac4c..00000000 --- a/src/WixToolset.Extensibility/Data/FileTransfer.cs +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
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 | |||
3 | namespace WixToolset.Extensibility.Data | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using WixToolset.Data; | ||
8 | |||
9 | /// <summary> | ||
10 | /// Structure used for all file transfer information. | ||
11 | /// </summary> | ||
12 | public class FileTransfer | ||
13 | { | ||
14 | /// <summary>Source path to file.</summary> | ||
15 | public string Source { get; set; } | ||
16 | |||
17 | /// <summary>Destination path for file.</summary> | ||
18 | public string Destination { get; set; } | ||
19 | |||
20 | /// <summary>Flag if file should be moved (optimal).</summary> | ||
21 | public bool Move { get; set; } | ||
22 | |||
23 | /// <summary>Optional source line numbers where this file transfer orginated.</summary> | ||
24 | public SourceLineNumber SourceLineNumbers { get; set; } | ||
25 | |||
26 | /// <summary>Optional type of file this transfer is moving or copying.</summary> | ||
27 | public string Type { get; set; } | ||
28 | |||
29 | /// <summary>Indicates whether the file transer was a built by this build or copied from other some build.</summary> | ||
30 | public bool Built { get; set; } | ||
31 | |||
32 | /// <summary>Set during layout of media when the file transfer when the source and target resolve to the same path.</summary> | ||
33 | public bool Redundant { get; set; } | ||
34 | |||
35 | /// <summary> | ||
36 | /// Prefer the TryCreate() method to create FileTransfer objects. | ||
37 | /// </summary> | ||
38 | /// <param name="source">Source path to file.</param> | ||
39 | /// <param name="destination">Destination path for file.</param> | ||
40 | /// <param name="move">File if file should be moved (optimal).</param> | ||
41 | /// <param name="type">Optional type of file this transfer is transferring.</param> | ||
42 | /// <param name="sourceLineNumbers">Optional source line numbers wher this transfer originated.</param> | ||
43 | public FileTransfer(string source, string destination, bool move, string type = null, SourceLineNumber sourceLineNumbers = null) | ||
44 | { | ||
45 | this.Source = source; | ||
46 | this.Destination = destination; | ||
47 | this.Move = move; | ||
48 | |||
49 | this.Type = type; | ||
50 | this.SourceLineNumbers = sourceLineNumbers; | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Creates a file transfer if the source and destination are different. | ||
55 | /// </summary> | ||
56 | /// <param name="source">Source path to file.</param> | ||
57 | /// <param name="destination">Destination path for file.</param> | ||
58 | /// <param name="move">File if file should be moved (optimal).</param> | ||
59 | /// <param name="type">Optional type of file this transfer is transferring.</param> | ||
60 | /// <param name="sourceLineNumbers">Optional source line numbers where this transfer originated.</param> | ||
61 | /// <returns>true if the source and destination are the different, false if no file transfer is created.</returns> | ||
62 | public static bool TryCreate(string source, string destination, bool move, string type, SourceLineNumber sourceLineNumbers, out FileTransfer transfer) | ||
63 | { | ||
64 | //string sourceFullPath = GetValidatedFullPath(sourceLineNumbers, source); | ||
65 | |||
66 | //string fileLayoutFullPath = GetValidatedFullPath(sourceLineNumbers, destination); | ||
67 | |||
68 | ////// if the current source path (where we know that the file already exists) and the resolved | ||
69 | ////// path as dictated by the Directory table are not the same, then propagate the file. The | ||
70 | ////// image that we create may have already been done by some other process other than the linker, so | ||
71 | ////// there is no reason to copy the files to the resolved source if they are already there. | ||
72 | ////if (String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase)) | ||
73 | ////{ | ||
74 | //// transfer = null; | ||
75 | //// return false; | ||
76 | ////} | ||
77 | |||
78 | //transfer = new FileTransfer(source, destination, move, type, sourceLineNumbers); | ||
79 | //transfer.Redundant = String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase); | ||
80 | //return true; | ||
81 | throw new NotImplementedException(); | ||
82 | } | ||
83 | |||
84 | //private static string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path) | ||
85 | //{ | ||
86 | // string result; | ||
87 | |||
88 | // try | ||
89 | // { | ||
90 | // result = Path.GetFullPath(path); | ||
91 | |||
92 | // var filename = Path.GetFileName(result); | ||
93 | |||
94 | // foreach (var reservedName in Common.ReservedFileNames) | ||
95 | // { | ||
96 | // if (reservedName.Equals(filename, StringComparison.OrdinalIgnoreCase)) | ||
97 | // { | ||
98 | // throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
99 | // } | ||
100 | // } | ||
101 | // } | ||
102 | // catch (ArgumentException) | ||
103 | // { | ||
104 | // throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
105 | // } | ||
106 | // catch (PathTooLongException) | ||
107 | // { | ||
108 | // throw new WixException(ErrorMessages.PathTooLong(sourceLineNumbers, path)); | ||
109 | // } | ||
110 | |||
111 | // return result; | ||
112 | //} | ||
113 | } | ||
114 | } | ||
diff --git a/src/WixToolset.Extensibility/Data/FileTransferType.cs b/src/WixToolset.Extensibility/Data/FileTransferType.cs new file mode 100644 index 00000000..b00a00c4 --- /dev/null +++ b/src/WixToolset.Extensibility/Data/FileTransferType.cs | |||
@@ -0,0 +1,17 @@ | |||
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 | |||
3 | namespace WixToolset.Extensibility.Data | ||
4 | { | ||
5 | public enum FileTransferType | ||
6 | { | ||
7 | /// <summary> | ||
8 | /// Transfer of a file built during this build. | ||
9 | /// </summary> | ||
10 | Built, | ||
11 | |||
12 | /// <summary> | ||
13 | /// Transfer of a file contained in the output. | ||
14 | /// </summary> | ||
15 | Content, | ||
16 | } | ||
17 | } | ||
diff --git a/src/WixToolset.Extensibility/Data/IFileTransfer.cs b/src/WixToolset.Extensibility/Data/IFileTransfer.cs new file mode 100644 index 00000000..ca936219 --- /dev/null +++ b/src/WixToolset.Extensibility/Data/IFileTransfer.cs | |||
@@ -0,0 +1,30 @@ | |||
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 | |||
3 | namespace WixToolset.Extensibility.Data | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | |||
7 | /// <summary> | ||
8 | /// Structure used for all file transfer information. | ||
9 | /// </summary> | ||
10 | public interface IFileTransfer | ||
11 | { | ||
12 | /// <summary>Destination path for file.</summary> | ||
13 | string Destination { get; set; } | ||
14 | |||
15 | /// <summary>Flag if file should be moved (optimal).</summary> | ||
16 | bool Move { get; set; } | ||
17 | |||
18 | /// <summary>Set during layout of media when the file transfer when the source and target resolve to the same path.</summary> | ||
19 | bool Redundant { get; set; } | ||
20 | |||
21 | /// <summary>Source path to file.</summary> | ||
22 | string Source { get; set; } | ||
23 | |||
24 | /// <summary>Optional source line numbers where this file transfer orginated.</summary> | ||
25 | SourceLineNumber SourceLineNumbers { get; set; } | ||
26 | |||
27 | /// <summary>Type of file this transfer is moving or copying.</summary> | ||
28 | FileTransferType Type { get; set; } | ||
29 | } | ||
30 | } | ||
diff --git a/src/WixToolset.Extensibility/Data/ILayoutContext.cs b/src/WixToolset.Extensibility/Data/ILayoutContext.cs index c3555268..7011fcf6 100644 --- a/src/WixToolset.Extensibility/Data/ILayoutContext.cs +++ b/src/WixToolset.Extensibility/Data/ILayoutContext.cs | |||
@@ -13,7 +13,7 @@ namespace WixToolset.Extensibility.Data | |||
13 | 13 | ||
14 | IEnumerable<string> ContentFilePaths { get; set; } | 14 | IEnumerable<string> ContentFilePaths { get; set; } |
15 | 15 | ||
16 | IEnumerable<FileTransfer> FileTransfers { get; set; } | 16 | IEnumerable<IFileTransfer> FileTransfers { get; set; } |
17 | 17 | ||
18 | string ContentsFile { get; set; } | 18 | string ContentsFile { get; set; } |
19 | 19 | ||
diff --git a/src/WixToolset.Extensibility/Services/IBackendHelper.cs b/src/WixToolset.Extensibility/Services/IBackendHelper.cs new file mode 100644 index 00000000..83f57e35 --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IBackendHelper.cs | |||
@@ -0,0 +1,23 @@ | |||
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 | |||
3 | namespace WixToolset.Extensibility.Services | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Extensibility.Data; | ||
7 | |||
8 | /// <summary> | ||
9 | /// Interface provided to help backend extensions. | ||
10 | /// </summary> | ||
11 | public interface IBackendHelper | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// Creates a file transfer and marks it redundant if the source and destination are identical. | ||
15 | /// </summary> | ||
16 | /// <param name="source">Source for the file transfer.</param> | ||
17 | /// <param name="destination">Destiation for the file transfer.</param> | ||
18 | /// <param name="move">Indicates whether to move or copy the source file.</param> | ||
19 | /// <param name="type">Type of file transfer to create.</param> | ||
20 | /// <param name="sourceLineNumbers">Optional source line numbers that requested the file transfer.</param> | ||
21 | IFileTransfer CreateFileTransfer(string source, string destination, bool move, FileTransferType type, SourceLineNumber sourceLineNumbers = null); | ||
22 | } | ||
23 | } | ||