diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-03-14 07:38:48 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-03-14 07:47:48 -0700 |
| commit | 3ccd5e439da4296d6f2b66ce47075ab20d039676 (patch) | |
| tree | b5546552613b869367d09f444492a0bbcfadcfe0 /src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs | |
| parent | 574785ab1421c9b67336c13ade5c2263e665ca07 (diff) | |
| download | wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.gz wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.bz2 wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.zip | |
Minimize public surface area of Core
Fixes wixtoolset/issues#6374
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs')
| -rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs b/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs index 7b20286c..3dcc0ce9 100644 --- a/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs | |||
| @@ -3,8 +3,12 @@ | |||
| 3 | namespace WixToolset.Core.ExtensibilityServices | 3 | namespace WixToolset.Core.ExtensibilityServices |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | ||
| 6 | using System.IO; | 7 | using System.IO; |
| 8 | using WixToolset.Core.Bind; | ||
| 7 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 10 | using WixToolset.Data.Symbols; | ||
| 11 | using WixToolset.Data.WindowsInstaller.Rows; | ||
| 8 | using WixToolset.Extensibility.Data; | 12 | using WixToolset.Extensibility.Data; |
| 9 | using WixToolset.Extensibility.Services; | 13 | using WixToolset.Extensibility.Services; |
| 10 | 14 | ||
| @@ -15,12 +19,24 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 15 | public BackendHelper(IWixToolsetServiceProvider serviceProvider) | 19 | public BackendHelper(IWixToolsetServiceProvider serviceProvider) |
| 16 | { | 20 | { |
| 17 | this.Messaging = serviceProvider.GetService<IMessaging>(); | 21 | this.Messaging = serviceProvider.GetService<IMessaging>(); |
| 18 | this.ParseHelper = serviceProvider.GetService<IParseHelper>(); | ||
| 19 | } | 22 | } |
| 20 | 23 | ||
| 21 | private IMessaging Messaging { get; } | 24 | private IMessaging Messaging { get; } |
| 22 | 25 | ||
| 23 | private IParseHelper ParseHelper { get; } | 26 | public IFileFacade CreateFileFacade(FileSymbol file, AssemblySymbol assembly) |
| 27 | { | ||
| 28 | return new FileFacade(file, assembly); | ||
| 29 | } | ||
| 30 | |||
| 31 | public IFileFacade CreateFileFacade(FileRow fileRow) | ||
| 32 | { | ||
| 33 | return new FileFacade(fileRow); | ||
| 34 | } | ||
| 35 | |||
| 36 | public IFileFacade CreateFileFacadeFromMergeModule(FileSymbol fileSymbol) | ||
| 37 | { | ||
| 38 | return new FileFacade(true, fileSymbol); | ||
| 39 | } | ||
| 24 | 40 | ||
| 25 | public IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null) | 41 | public IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null) |
| 26 | { | 42 | { |
| @@ -38,6 +54,11 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 38 | }; | 54 | }; |
| 39 | } | 55 | } |
| 40 | 56 | ||
| 57 | public string CreateGuid() | ||
| 58 | { | ||
| 59 | return Common.GenerateGuid(); | ||
| 60 | } | ||
| 61 | |||
| 41 | public string CreateGuid(Guid namespaceGuid, string value) | 62 | public string CreateGuid(Guid namespaceGuid, string value) |
| 42 | { | 63 | { |
| 43 | return Uuid.NewUuid(namespaceGuid, value).ToString("B").ToUpperInvariant(); | 64 | return Uuid.NewUuid(namespaceGuid, value).ToString("B").ToUpperInvariant(); |
| @@ -52,9 +73,43 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 52 | }; | 73 | }; |
| 53 | } | 74 | } |
| 54 | 75 | ||
| 76 | public IEnumerable<ITrackedFile> ExtractEmbeddedFiles(IEnumerable<IExpectedExtractFile> embeddedFiles) | ||
| 77 | { | ||
| 78 | var command = new ExtractEmbeddedFilesCommand(this, embeddedFiles); | ||
| 79 | command.Execute(); | ||
| 80 | |||
| 81 | return command.TrackedFiles; | ||
| 82 | } | ||
| 83 | |||
| 84 | public string GenerateIdentifier(string prefix, params string[] args) | ||
| 85 | { | ||
| 86 | return Common.GenerateIdentifier(prefix, args); | ||
| 87 | } | ||
| 88 | |||
| 55 | public string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath) | 89 | public string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath) |
| 56 | { | 90 | { |
| 57 | return this.ParseHelper.GetCanonicalRelativePath(sourceLineNumbers, elementName, attributeName, relativePath); | 91 | return Common.GetCanonicalRelativePath(sourceLineNumbers, elementName, attributeName, relativePath, this.Messaging); |
| 92 | } | ||
| 93 | |||
| 94 | public int GetValidCodePage(string value, bool allowNoChange = false, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null) | ||
| 95 | { | ||
| 96 | return Common.GetValidCodePage(value, allowNoChange, onlyAnsi, sourceLineNumbers); | ||
| 97 | } | ||
| 98 | |||
| 99 | public string GetMsiFileName(string value, bool source, bool longName) | ||
| 100 | { | ||
| 101 | return Common.GetName(value, source, longName); | ||
| 102 | } | ||
| 103 | |||
| 104 | public void ResolveDelayedFields(IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache) | ||
| 105 | { | ||
| 106 | var command = new ResolveDelayedFieldsCommand(this.Messaging, delayedFields, variableCache); | ||
| 107 | command.Execute(); | ||
| 108 | } | ||
| 109 | |||
| 110 | public string[] SplitMsiFileName(string value) | ||
| 111 | { | ||
| 112 | return Common.GetNames(value); | ||
| 58 | } | 113 | } |
| 59 | 114 | ||
| 60 | public ITrackedFile TrackFile(string path, TrackedFileType type, SourceLineNumber sourceLineNumbers = null) | 115 | public ITrackedFile TrackFile(string path, TrackedFileType type, SourceLineNumber sourceLineNumbers = null) |
| @@ -62,6 +117,31 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 62 | return new TrackedFile(path, type, sourceLineNumbers); | 117 | return new TrackedFile(path, type, sourceLineNumbers); |
| 63 | } | 118 | } |
| 64 | 119 | ||
| 120 | public bool IsValidBinderVariable(string variable) | ||
| 121 | { | ||
| 122 | return Common.IsValidBinderVariable(variable); | ||
| 123 | } | ||
| 124 | |||
| 125 | public bool IsValidFourPartVersion(string version) | ||
| 126 | { | ||
| 127 | return Common.IsValidFourPartVersion(version); | ||
| 128 | } | ||
| 129 | |||
| 130 | public bool IsValidIdentifier(string id) | ||
| 131 | { | ||
| 132 | return Common.IsIdentifier(id); | ||
| 133 | } | ||
| 134 | |||
| 135 | public bool IsValidLongFilename(string filename, bool allowWildcards, bool allowRelative) | ||
| 136 | { | ||
| 137 | return Common.IsValidLongFilename(filename, allowWildcards, allowRelative); | ||
| 138 | } | ||
| 139 | |||
| 140 | public bool IsValidShortFilename(string filename, bool allowWildcards) | ||
| 141 | { | ||
| 142 | return Common.IsValidShortFilename(filename, allowWildcards); | ||
| 143 | } | ||
| 144 | |||
| 65 | private string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path) | 145 | private string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path) |
| 66 | { | 146 | { |
| 67 | try | 147 | try |
