From b6bf1604c32259757f75b4c35444cfe4ecc21a86 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 11 Nov 2017 12:41:56 -0800 Subject: Introduce IExtensionFactory as mechanism to create extensions --- src/WixToolset.Core.Burn/BackendFactory.cs | 31 ---------------------- src/WixToolset.Core.Burn/BurnBackendFactory.cs | 31 ++++++++++++++++++++++ src/WixToolset.Core.Burn/BurnExtensionFactory.cs | 22 +++++++++++++++ src/WixToolset.Core.Burn/StandardBackend.cs | 12 --------- .../WixToolsetStandardBackend.cs | 12 +++++++++ 5 files changed, 65 insertions(+), 43 deletions(-) delete mode 100644 src/WixToolset.Core.Burn/BackendFactory.cs create mode 100644 src/WixToolset.Core.Burn/BurnBackendFactory.cs create mode 100644 src/WixToolset.Core.Burn/BurnExtensionFactory.cs delete mode 100644 src/WixToolset.Core.Burn/StandardBackend.cs create mode 100644 src/WixToolset.Core.Burn/WixToolsetStandardBackend.cs (limited to 'src/WixToolset.Core.Burn') diff --git a/src/WixToolset.Core.Burn/BackendFactory.cs b/src/WixToolset.Core.Burn/BackendFactory.cs deleted file mode 100644 index a69c47b5..00000000 --- a/src/WixToolset.Core.Burn/BackendFactory.cs +++ /dev/null @@ -1,31 +0,0 @@ -// 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.Core.Burn -{ - using System; - using System.IO; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Services; - - internal class BackendFactory : IBackendFactory - { - public bool TryCreateBackend(string outputType, string outputFile, IBindContext context, out IBackend backend) - { - if (String.IsNullOrEmpty(outputType)) - { - outputType = Path.GetExtension(outputFile); - } - - switch (outputType.ToLowerInvariant()) - { - case "bundle": - case ".exe": - backend = new BundleBackend(); - return true; - } - - backend = null; - return false; - } - } -} diff --git a/src/WixToolset.Core.Burn/BurnBackendFactory.cs b/src/WixToolset.Core.Burn/BurnBackendFactory.cs new file mode 100644 index 00000000..8e2b3ce2 --- /dev/null +++ b/src/WixToolset.Core.Burn/BurnBackendFactory.cs @@ -0,0 +1,31 @@ +// 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.Core.Burn +{ + using System; + using System.IO; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; + + internal class BurnBackendFactory : IBackendFactory + { + public bool TryCreateBackend(string outputType, string outputFile, IBindContext context, out IBackend backend) + { + if (String.IsNullOrEmpty(outputType)) + { + outputType = Path.GetExtension(outputFile); + } + + switch (outputType.ToLowerInvariant()) + { + case "bundle": + case ".exe": + backend = new BundleBackend(); + return true; + } + + backend = null; + return false; + } + } +} diff --git a/src/WixToolset.Core.Burn/BurnExtensionFactory.cs b/src/WixToolset.Core.Burn/BurnExtensionFactory.cs new file mode 100644 index 00000000..b34d12c1 --- /dev/null +++ b/src/WixToolset.Core.Burn/BurnExtensionFactory.cs @@ -0,0 +1,22 @@ +// 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.Core.Burn +{ + using System; + using WixToolset.Extensibility; + + internal class BurnExtensionFactory : IExtensionFactory + { + public bool TryCreateExtension(Type extensionType, out object extension) + { + extension = null; + + if (extensionType == typeof(IBackendFactory)) + { + extension = new BurnBackendFactory(); + } + + return extension != null; + } + } +} diff --git a/src/WixToolset.Core.Burn/StandardBackend.cs b/src/WixToolset.Core.Burn/StandardBackend.cs deleted file mode 100644 index 2ab30776..00000000 --- a/src/WixToolset.Core.Burn/StandardBackend.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Core.Burn -{ - /// - /// Denotes this assembly contains a backend that is considered - /// a standard part of the WiX Toolset. - /// - public static class StandardBackend - { - } -} diff --git a/src/WixToolset.Core.Burn/WixToolsetStandardBackend.cs b/src/WixToolset.Core.Burn/WixToolsetStandardBackend.cs new file mode 100644 index 00000000..5f589d71 --- /dev/null +++ b/src/WixToolset.Core.Burn/WixToolsetStandardBackend.cs @@ -0,0 +1,12 @@ +// 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.Core.Burn +{ + /// + /// Denotes this assembly contains a backend that is considered + /// a standard part of the WiX Toolset. + /// + public static class WixToolsetStandardBackend + { + } +} -- cgit v1.2.3-55-g6feb