From 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 19 Dec 2017 12:25:40 -0800 Subject: Integrate simplified message handling --- src/WixToolset.Core/CommandLine/CommandLine.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/CommandLine.cs') diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index 9bedca9a..9db1b2f9 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs @@ -24,12 +24,10 @@ namespace WixToolset.Core internal class CommandLine : ICommandLine, IParseCommandLine { - public CommandLine() - { - } - private IServiceProvider ServiceProvider { get; set; } + private IMessaging Messaging { get; set; } + public static string ExpectedArgument { get; } = "expected argument"; public string ActiveCommand { get; private set; } @@ -48,6 +46,8 @@ namespace WixToolset.Core { this.ServiceProvider = context.ServiceProvider; + this.Messaging = context.Messaging ?? this.ServiceProvider.GetService(); + this.ExtensionManager = context.ExtensionManager ?? this.ServiceProvider.GetService(); var args = context.ParsedArguments ?? Array.Empty(); @@ -186,7 +186,7 @@ namespace WixToolset.Core } }); - Messaging.Instance.ShowVerboseMessages = verbose; + this.Messaging.ShowVerboseMessages = verbose; if (showVersion) { @@ -208,17 +208,17 @@ namespace WixToolset.Core case Commands.Build: { var sourceFiles = GatherSourceFiles(files, outputFolder); - var variables = GatherPreprocessorVariables(defines); - var bindPathList = GatherBindPaths(bindPaths); + var variables = this.GatherPreprocessorVariables(defines); + var bindPathList = this.GatherBindPaths(bindPaths); var type = CalculateOutputType(outputType, outputFile); - return new BuildCommand(this.ServiceProvider, this.ExtensionManager, sourceFiles, variables, locFiles, libraryFiles, outputFile, type, cabCachePath, cultures, bindFiles, bindPathList, intermediateFolder, contentsFile, outputsFile, builtOutputsFile, wixProjectFile); + return new BuildCommand(this.ServiceProvider, this.Messaging, this.ExtensionManager, sourceFiles, variables, locFiles, libraryFiles, outputFile, type, cabCachePath, cultures, bindFiles, bindPathList, intermediateFolder, contentsFile, outputsFile, builtOutputsFile, wixProjectFile); } case Commands.Compile: { var sourceFiles = GatherSourceFiles(files, outputFolder); var variables = GatherPreprocessorVariables(defines); - return new CompileCommand(this.ServiceProvider, this.ExtensionManager, sourceFiles, variables); + return new CompileCommand(this.ServiceProvider, this.Messaging, this.ExtensionManager, sourceFiles, variables); } } @@ -305,7 +305,7 @@ namespace WixToolset.Core return files; } - private static IDictionary GatherPreprocessorVariables(IEnumerable defineConstants) + private IDictionary GatherPreprocessorVariables(IEnumerable defineConstants) { var variables = new Dictionary(); @@ -315,7 +315,7 @@ namespace WixToolset.Core if (variables.ContainsKey(value[0])) { - Messaging.Instance.OnMessage(WixErrors.DuplicateVariableDefinition(value[0], (1 == value.Length) ? String.Empty : value[1], variables[value[0]])); + this.Messaging.Write(ErrorMessages.DuplicateVariableDefinition(value[0], (1 == value.Length) ? String.Empty : value[1], variables[value[0]])); continue; } @@ -325,7 +325,7 @@ namespace WixToolset.Core return variables; } - private static IEnumerable GatherBindPaths(IEnumerable bindPaths) + private IEnumerable GatherBindPaths(IEnumerable bindPaths) { var result = new List(); @@ -339,7 +339,7 @@ namespace WixToolset.Core } else if (File.Exists(bp.Path)) { - Messaging.Instance.OnMessage(WixErrors.ExpectedDirectoryGotFile("-bindpath", bp.Path)); + this.Messaging.Write(ErrorMessages.ExpectedDirectoryGotFile("-bindpath", bp.Path)); } } -- cgit v1.2.3-55-g6feb