diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-18 14:43:31 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-18 21:31:28 +1000 |
commit | a6091afa5bd24fe65e7fc20f179ed888301afdf8 (patch) | |
tree | 020cf8336d4f282bac818d2d7a5d2a6b0ae10ff0 /src/test/Example.Extension/ExampleTupleDefinitions.cs | |
parent | c7f9ef7e7bcceb670b56a70fc9aa92152fd55573 (diff) | |
download | wix-a6091afa5bd24fe65e7fc20f179ed888301afdf8.tar.gz wix-a6091afa5bd24fe65e7fc20f179ed888301afdf8.tar.bz2 wix-a6091afa5bd24fe65e7fc20f179ed888301afdf8.zip |
Test ability for an extension to have a custom strongly typed row during binding.
Diffstat (limited to 'src/test/Example.Extension/ExampleTupleDefinitions.cs')
-rw-r--r-- | src/test/Example.Extension/ExampleTupleDefinitions.cs | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/test/Example.Extension/ExampleTupleDefinitions.cs b/src/test/Example.Extension/ExampleTupleDefinitions.cs index dd8b5bbf..446c2c45 100644 --- a/src/test/Example.Extension/ExampleTupleDefinitions.cs +++ b/src/test/Example.Extension/ExampleTupleDefinitions.cs | |||
@@ -2,15 +2,20 @@ | |||
2 | 2 | ||
3 | namespace Example.Extension | 3 | namespace Example.Extension |
4 | { | 4 | { |
5 | using System; | ||
5 | using WixToolset.Data; | 6 | using WixToolset.Data; |
6 | using WixToolset.Data.Burn; | 7 | using WixToolset.Data.Burn; |
7 | 8 | ||
8 | public static class ExampleTupleDefinitions | 9 | public enum ExampleTupleDefinitionType |
9 | { | 10 | { |
10 | public const string ExampleName = "Example"; | 11 | Example, |
12 | ExampleSearch, | ||
13 | } | ||
11 | 14 | ||
15 | public static class ExampleTupleDefinitions | ||
16 | { | ||
12 | public static readonly IntermediateTupleDefinition Example = new IntermediateTupleDefinition( | 17 | public static readonly IntermediateTupleDefinition Example = new IntermediateTupleDefinition( |
13 | ExampleName, | 18 | ExampleTupleDefinitionType.Example.ToString(), |
14 | new[] | 19 | new[] |
15 | { | 20 | { |
16 | new IntermediateFieldDefinition(nameof(ExampleTupleFields.Value), IntermediateFieldType.String), | 21 | new IntermediateFieldDefinition(nameof(ExampleTupleFields.Value), IntermediateFieldType.String), |
@@ -18,7 +23,7 @@ namespace Example.Extension | |||
18 | typeof(ExampleTuple)); | 23 | typeof(ExampleTuple)); |
19 | 24 | ||
20 | public static readonly IntermediateTupleDefinition ExampleSearch = new IntermediateTupleDefinition( | 25 | public static readonly IntermediateTupleDefinition ExampleSearch = new IntermediateTupleDefinition( |
21 | nameof(ExampleSearch), | 26 | ExampleTupleDefinitionType.ExampleSearch.ToString(), |
22 | new[] | 27 | new[] |
23 | { | 28 | { |
24 | new IntermediateFieldDefinition(nameof(ExampleSearchTupleFields.SearchFor), IntermediateFieldType.String), | 29 | new IntermediateFieldDefinition(nameof(ExampleSearchTupleFields.SearchFor), IntermediateFieldType.String), |
@@ -29,5 +34,34 @@ namespace Example.Extension | |||
29 | { | 34 | { |
30 | ExampleSearch.AddTag(BurnConstants.BundleExtensionSearchTupleDefinitionTag); | 35 | ExampleSearch.AddTag(BurnConstants.BundleExtensionSearchTupleDefinitionTag); |
31 | } | 36 | } |
37 | |||
38 | public static bool TryGetTupleType(string name, out ExampleTupleDefinitionType type) | ||
39 | { | ||
40 | return Enum.TryParse(name, out type); | ||
41 | } | ||
42 | |||
43 | public static IntermediateTupleDefinition ByName(string name) | ||
44 | { | ||
45 | if (!TryGetTupleType(name, out var type)) | ||
46 | { | ||
47 | return null; | ||
48 | } | ||
49 | return ByType(type); | ||
50 | } | ||
51 | |||
52 | public static IntermediateTupleDefinition ByType(ExampleTupleDefinitionType type) | ||
53 | { | ||
54 | switch (type) | ||
55 | { | ||
56 | case ExampleTupleDefinitionType.Example: | ||
57 | return ExampleTupleDefinitions.Example; | ||
58 | |||
59 | case ExampleTupleDefinitionType.ExampleSearch: | ||
60 | return ExampleTupleDefinitions.ExampleSearch; | ||
61 | |||
62 | default: | ||
63 | throw new ArgumentOutOfRangeException(nameof(type)); | ||
64 | } | ||
65 | } | ||
32 | } | 66 | } |
33 | } | 67 | } |