aboutsummaryrefslogtreecommitdiff
path: root/src/test/Example.Extension
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/Example.Extension')
-rw-r--r--src/test/Example.Extension/ExampleExtensionFactory.cs11
-rw-r--r--src/test/Example.Extension/ExamplePreprocessorExtension.cs55
-rw-r--r--src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs46
3 files changed, 55 insertions, 57 deletions
diff --git a/src/test/Example.Extension/ExampleExtensionFactory.cs b/src/test/Example.Extension/ExampleExtensionFactory.cs
index 9539ee85..b91d06e9 100644
--- a/src/test/Example.Extension/ExampleExtensionFactory.cs
+++ b/src/test/Example.Extension/ExampleExtensionFactory.cs
@@ -7,11 +7,18 @@ namespace Example.Extension
7 7
8 public class ExampleExtensionFactory : IExtensionFactory 8 public class ExampleExtensionFactory : IExtensionFactory
9 { 9 {
10 private ExamplePreprocessorExtensionAndCommandLine preprocessorExtension;
11
10 public bool TryCreateExtension(Type extensionType, out object extension) 12 public bool TryCreateExtension(Type extensionType, out object extension)
11 { 13 {
12 if (extensionType == typeof(IPreprocessorExtension)) 14 if (extensionType == typeof(IExtensionCommandLine) || extensionType == typeof(IPreprocessorExtension))
13 { 15 {
14 extension = new ExamplePreprocessorExtension(); 16 if (preprocessorExtension == null)
17 {
18 preprocessorExtension = new ExamplePreprocessorExtensionAndCommandLine();
19 }
20
21 extension = preprocessorExtension;
15 } 22 }
16 else if (extensionType == typeof(ICompilerExtension)) 23 else if (extensionType == typeof(ICompilerExtension))
17 { 24 {
diff --git a/src/test/Example.Extension/ExamplePreprocessorExtension.cs b/src/test/Example.Extension/ExamplePreprocessorExtension.cs
deleted file mode 100644
index c16c8b5a..00000000
--- a/src/test/Example.Extension/ExamplePreprocessorExtension.cs
+++ /dev/null
@@ -1,55 +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
3namespace Example.Extension
4{
5 using System;
6 using System.Xml.Linq;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
9
10 internal class ExamplePreprocessorExtension : IPreprocessorExtension
11 {
12 public ExamplePreprocessorExtension()
13 {
14 }
15
16 public IPreprocessorCore Core { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
17
18 public string[] Prefixes => throw new NotImplementedException();
19
20 public string EvaluateFunction(string prefix, string function, string[] args)
21 {
22 throw new NotImplementedException();
23 }
24
25 public void Finish()
26 {
27 throw new NotImplementedException();
28 }
29
30 public string GetVariableValue(string prefix, string name)
31 {
32 throw new NotImplementedException();
33 }
34
35 public void Initialize()
36 {
37 throw new NotImplementedException();
38 }
39
40 public void PreprocessDocument(XDocument document)
41 {
42 throw new NotImplementedException();
43 }
44
45 public string PreprocessParameter(string name)
46 {
47 throw new NotImplementedException();
48 }
49
50 public bool ProcessPragma(SourceLineNumber sourceLineNumbers, string prefix, string pragma, string args, XContainer parent)
51 {
52 throw new NotImplementedException();
53 }
54 }
55} \ No newline at end of file
diff --git a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs
new file mode 100644
index 00000000..53394ea3
--- /dev/null
+++ b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs
@@ -0,0 +1,46 @@
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 System.Collections.Generic;
7 using WixToolset.Extensibility;
8 using WixToolset.Extensibility.Services;
9
10 internal class ExamplePreprocessorExtensionAndCommandLine : BasePreprocessorExtension, IExtensionCommandLine
11 {
12 private string exampleValueFromCommandLine;
13
14 public IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches => throw new NotImplementedException();
15
16 public ExamplePreprocessorExtensionAndCommandLine()
17 {
18 this.Prefixes = new[] { "ex" };
19 }
20
21 public void PreParse(ICommandLineContext context)
22 {
23 }
24
25 public bool TryParseArgument(IParseCommandLine parseCommandLine, string arg)
26 {
27 if (parseCommandLine.IsSwitch(arg) && arg.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase))
28 {
29 parseCommandLine.GetNextArgumentOrError(ref this.exampleValueFromCommandLine);
30 return true;
31 }
32
33 return false;
34 }
35
36 public override string GetVariableValue(string prefix, string name)
37 {
38 if (prefix == "ex" && "test".Equals(name, StringComparison.OrdinalIgnoreCase))
39 {
40 return String.IsNullOrWhiteSpace(this.exampleValueFromCommandLine) ? "(null)" : this.exampleValueFromCommandLine;
41 }
42
43 return null;
44 }
45 }
46} \ No newline at end of file