aboutsummaryrefslogtreecommitdiff
path: root/src/test/Example.Extension/ExampleSymbolDefinitions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/Example.Extension/ExampleSymbolDefinitions.cs')
-rw-r--r--src/test/Example.Extension/ExampleSymbolDefinitions.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/test/Example.Extension/ExampleSymbolDefinitions.cs b/src/test/Example.Extension/ExampleSymbolDefinitions.cs
new file mode 100644
index 00000000..f13d716d
--- /dev/null
+++ b/src/test/Example.Extension/ExampleSymbolDefinitions.cs
@@ -0,0 +1,67 @@
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.Data;
7 using WixToolset.Data.Burn;
8
9 public enum ExampleSymbolDefinitionType
10 {
11 Example,
12 ExampleSearch,
13 }
14
15 public static class ExampleSymbolDefinitions
16 {
17 public static readonly IntermediateSymbolDefinition Example = new IntermediateSymbolDefinition(
18 ExampleSymbolDefinitionType.Example.ToString(),
19 new[]
20 {
21 new IntermediateFieldDefinition(nameof(ExampleSymbolFields.Value), IntermediateFieldType.String),
22 },
23 typeof(ExampleSymbol));
24
25 public static readonly IntermediateSymbolDefinition ExampleSearch = new IntermediateSymbolDefinition(
26 ExampleSymbolDefinitionType.ExampleSearch.ToString(),
27 new[]
28 {
29 new IntermediateFieldDefinition(nameof(ExampleSearchSymbolFields.SearchFor), IntermediateFieldType.String),
30 },
31 typeof(ExampleSearchSymbol));
32
33 static ExampleSymbolDefinitions()
34 {
35 ExampleSearch.AddTag(BurnConstants.BundleExtensionSearchSymbolDefinitionTag);
36 }
37
38 public static bool TryGetSymbolType(string name, out ExampleSymbolDefinitionType type)
39 {
40 return Enum.TryParse(name, out type);
41 }
42
43 public static IntermediateSymbolDefinition ByName(string name)
44 {
45 if (!TryGetSymbolType(name, out var type))
46 {
47 return null;
48 }
49 return ByType(type);
50 }
51
52 public static IntermediateSymbolDefinition ByType(ExampleSymbolDefinitionType type)
53 {
54 switch (type)
55 {
56 case ExampleSymbolDefinitionType.Example:
57 return ExampleSymbolDefinitions.Example;
58
59 case ExampleSymbolDefinitionType.ExampleSearch:
60 return ExampleSymbolDefinitions.ExampleSearch;
61
62 default:
63 throw new ArgumentOutOfRangeException(nameof(type));
64 }
65 }
66 }
67}