aboutsummaryrefslogtreecommitdiff
path: root/src/wix/test/Example.Extension/ExampleExtensionFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wix/test/Example.Extension/ExampleExtensionFactory.cs')
-rw-r--r--src/wix/test/Example.Extension/ExampleExtensionFactory.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/wix/test/Example.Extension/ExampleExtensionFactory.cs b/src/wix/test/Example.Extension/ExampleExtensionFactory.cs
new file mode 100644
index 00000000..e54561ee
--- /dev/null
+++ b/src/wix/test/Example.Extension/ExampleExtensionFactory.cs
@@ -0,0 +1,54 @@
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
3namespace Example.Extension
4{
5 using System;
6 using WixToolset.Extensibility;
7 using WixToolset.Extensibility.Services;
8
9 public class ExampleExtensionFactory : IExtensionFactory
10 {
11 private ExamplePreprocessorExtensionAndCommandLine preprocessorExtension;
12
13 public ExampleExtensionFactory(IWixToolsetCoreServiceProvider serviceProvider)
14 {
15 this.ServiceProvider = serviceProvider;
16 }
17
18 /// <summary>
19 /// This exists just to show it is possible to get a service provider to the extension factory.
20 /// </summary>
21 private IWixToolsetCoreServiceProvider ServiceProvider { get; }
22
23 public bool TryCreateExtension(Type extensionType, out object extension)
24 {
25 if (extensionType == typeof(IExtensionCommandLine) || extensionType == typeof(IPreprocessorExtension))
26 {
27 if (this.preprocessorExtension == null)
28 {
29 this.preprocessorExtension = new ExamplePreprocessorExtensionAndCommandLine();
30 }
31
32 extension = this.preprocessorExtension;
33 }
34 else if (extensionType == typeof(ICompilerExtension))
35 {
36 extension = new ExampleCompilerExtension();
37 }
38 else if (extensionType == typeof(IExtensionData))
39 {
40 extension = new ExampleExtensionData();
41 }
42 else if (extensionType == typeof(IWindowsInstallerBackendBinderExtension))
43 {
44 extension = new ExampleWindowsInstallerBackendExtension();
45 }
46 else
47 {
48 extension = null;
49 }
50
51 return extension != null;
52 }
53 }
54}