diff options
Diffstat (limited to 'src/test/Example.Extension')
13 files changed, 0 insertions, 595 deletions
diff --git a/src/test/Example.Extension/Data/example.txt b/src/test/Example.Extension/Data/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/Example.Extension/Data/example.txt +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | This is example.txt. \ No newline at end of file | ||
diff --git a/src/test/Example.Extension/Data/example.wxs b/src/test/Example.Extension/Data/example.wxs deleted file mode 100644 index af5d5086..00000000 --- a/src/test/Example.Extension/Data/example.wxs +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Fragment> | ||
| 3 | <Property Id="PropertyFromExampleWir" Value="FromWir" /> | ||
| 4 | |||
| 5 | <Binary Id="BinFromWir" SourceFile="example.txt" /> | ||
| 6 | </Fragment> | ||
| 7 | <Fragment> | ||
| 8 | <BootstrapperApplication Id="fakeba"> | ||
| 9 | <BootstrapperApplicationDll SourceFile="example.txt" /> | ||
| 10 | </BootstrapperApplication> | ||
| 11 | </Fragment> | ||
| 12 | <Fragment> | ||
| 13 | <BundleExtension Id="ExampleBundleExtension" SourceFile="example.txt" /> | ||
| 14 | </Fragment> | ||
| 15 | </Wix> | ||
diff --git a/src/test/Example.Extension/Example.Extension.csproj b/src/test/Example.Extension/Example.Extension.csproj deleted file mode 100644 index 9be10d35..00000000 --- a/src/test/Example.Extension/Example.Extension.csproj +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| 7 | <IsPackable>false</IsPackable> | ||
| 8 | <DebugType>embedded</DebugType> | ||
| 9 | </PropertyGroup> | ||
| 10 | |||
| 11 | <ItemGroup> | ||
| 12 | <!-- This .wixlib is built by CompileCoreTestExtensionWixlib.csproj --> | ||
| 13 | <EmbeddedResource Include="$(BaseOutputPath)TestData\$(Configuration)\Example.wixlib" /> | ||
| 14 | </ItemGroup> | ||
| 15 | |||
| 16 | <ItemGroup> | ||
| 17 | <ProjectReference Include="..\CompileCoreTestExtensionWixlib\CompileCoreTestExtensionWixlib.csproj" /> | ||
| 18 | </ItemGroup> | ||
| 19 | |||
| 20 | <ItemGroup> | ||
| 21 | <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" /> | ||
| 22 | </ItemGroup> | ||
| 23 | |||
| 24 | </Project> | ||
diff --git a/src/test/Example.Extension/ExampleCompilerExtension.cs b/src/test/Example.Extension/ExampleCompilerExtension.cs deleted file mode 100644 index 5b8d4b3f..00000000 --- a/src/test/Example.Extension/ExampleCompilerExtension.cs +++ /dev/null | |||
| @@ -1,195 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Xml.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Extensibility; | ||
| 10 | |||
| 11 | internal class ExampleCompilerExtension : BaseCompilerExtension | ||
| 12 | { | ||
| 13 | public override XNamespace Namespace => "http://www.example.com/scheams/v1/wxs"; | ||
| 14 | public string BundleExtensionId => "ExampleBundleExtension"; | ||
| 15 | |||
| 16 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
| 17 | { | ||
| 18 | var processed = false; | ||
| 19 | |||
| 20 | switch (parentElement.Name.LocalName) | ||
| 21 | { | ||
| 22 | case "Bundle": | ||
| 23 | case "Fragment": | ||
| 24 | switch (element.Name.LocalName) | ||
| 25 | { | ||
| 26 | case "ExampleEnsureTable": | ||
| 27 | this.ParseExampleEnsureTableElement(intermediate, section, element); | ||
| 28 | processed = true; | ||
| 29 | break; | ||
| 30 | case "ExampleSearch": | ||
| 31 | this.ParseExampleSearchElement(intermediate, section, element); | ||
| 32 | processed = true; | ||
| 33 | break; | ||
| 34 | case "ExampleSearchRef": | ||
| 35 | this.ParseExampleSearchRefElement(intermediate, section, element); | ||
| 36 | processed = true; | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | break; | ||
| 40 | case "Component": | ||
| 41 | switch (element.Name.LocalName) | ||
| 42 | { | ||
| 43 | case "Example": | ||
| 44 | this.ParseExampleElement(intermediate, section, element); | ||
| 45 | processed = true; | ||
| 46 | break; | ||
| 47 | } | ||
| 48 | break; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (!processed) | ||
| 52 | { | ||
| 53 | base.ParseElement(intermediate, section, parentElement, element, context); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element) | ||
| 58 | { | ||
| 59 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
| 60 | Identifier id = null; | ||
| 61 | string value = null; | ||
| 62 | |||
| 63 | foreach (var attrib in element.Attributes()) | ||
| 64 | { | ||
| 65 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
| 66 | { | ||
| 67 | switch (attrib.Name.LocalName) | ||
| 68 | { | ||
| 69 | case "Id": | ||
| 70 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | ||
| 71 | break; | ||
| 72 | |||
| 73 | case "Value": | ||
| 74 | value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 75 | break; | ||
| 76 | |||
| 77 | default: | ||
| 78 | this.ParseHelper.UnexpectedAttribute(element, attrib); | ||
| 79 | break; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | else | ||
| 83 | { | ||
| 84 | this.ParseAttribute(intermediate, section, element, attrib, null); | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | if (null == id) | ||
| 89 | { | ||
| 90 | //this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | ||
| 91 | } | ||
| 92 | |||
| 93 | if (!this.Messaging.EncounteredError) | ||
| 94 | { | ||
| 95 | var symbol = this.ParseHelper.CreateSymbol(section, sourceLineNumbers, "Example", id); | ||
| 96 | symbol.Set(0, value); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | private void ParseExampleEnsureTableElement(Intermediate intermediate, IntermediateSection section, XElement element) | ||
| 101 | { | ||
| 102 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
| 103 | this.ParseHelper.EnsureTable(section, sourceLineNumbers, ExampleTableDefinitions.NotInAll); | ||
| 104 | } | ||
| 105 | |||
| 106 | private void ParseExampleSearchElement(Intermediate intermediate, IntermediateSection section, XElement element) | ||
| 107 | { | ||
| 108 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
| 109 | Identifier id = null; | ||
| 110 | string searchFor = null; | ||
| 111 | string variable = null; | ||
| 112 | string condition = null; | ||
| 113 | string after = null; | ||
| 114 | |||
| 115 | foreach (var attrib in element.Attributes()) | ||
| 116 | { | ||
| 117 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
| 118 | { | ||
| 119 | switch (attrib.Name.LocalName) | ||
| 120 | { | ||
| 121 | case "Id": | ||
| 122 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | ||
| 123 | break; | ||
| 124 | case "Variable": | ||
| 125 | variable = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 126 | break; | ||
| 127 | case "Condition": | ||
| 128 | condition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 129 | break; | ||
| 130 | case "After": | ||
| 131 | after = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 132 | break; | ||
| 133 | case "SearchFor": | ||
| 134 | searchFor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 135 | break; | ||
| 136 | |||
| 137 | default: | ||
| 138 | this.ParseHelper.UnexpectedAttribute(element, attrib); | ||
| 139 | break; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | else | ||
| 143 | { | ||
| 144 | this.ParseAttribute(intermediate, section, element, attrib, null); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | if (null == id) | ||
| 149 | { | ||
| 150 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | ||
| 151 | } | ||
| 152 | |||
| 153 | if (!this.Messaging.EncounteredError) | ||
| 154 | { | ||
| 155 | this.ParseHelper.CreateWixSearchSymbol(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, this.BundleExtensionId); | ||
| 156 | } | ||
| 157 | |||
| 158 | if (!this.Messaging.EncounteredError) | ||
| 159 | { | ||
| 160 | var symbol = section.AddSymbol(new ExampleSearchSymbol(sourceLineNumbers, id) | ||
| 161 | { | ||
| 162 | SearchFor = searchFor, | ||
| 163 | }); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | private void ParseExampleSearchRefElement(Intermediate intermediate, IntermediateSection section, XElement element) | ||
| 168 | { | ||
| 169 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
| 170 | |||
| 171 | foreach (var attrib in element.Attributes()) | ||
| 172 | { | ||
| 173 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
| 174 | { | ||
| 175 | switch (attrib.Name.LocalName) | ||
| 176 | { | ||
| 177 | case "Id": | ||
| 178 | var refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | ||
| 179 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, ExampleSymbolDefinitions.ExampleSearch, refId); | ||
| 180 | break; | ||
| 181 | default: | ||
| 182 | this.ParseHelper.UnexpectedAttribute(element, attrib); | ||
| 183 | break; | ||
| 184 | } | ||
| 185 | } | ||
| 186 | else | ||
| 187 | { | ||
| 188 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
diff --git a/src/test/Example.Extension/ExampleExtensionData.cs b/src/test/Example.Extension/ExampleExtensionData.cs deleted file mode 100644 index 91d60eb9..00000000 --- a/src/test/Example.Extension/ExampleExtensionData.cs +++ /dev/null | |||
| @@ -1,23 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Extensibility; | ||
| 7 | |||
| 8 | internal class ExampleExtensionData : IExtensionData | ||
| 9 | { | ||
| 10 | public string DefaultCulture => null; | ||
| 11 | |||
| 12 | public Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) | ||
| 13 | { | ||
| 14 | return Intermediate.Load(typeof(ExampleExtensionData).Assembly, "Example.Extension.Example.wixlib", symbolDefinitions); | ||
| 15 | } | ||
| 16 | |||
| 17 | public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) | ||
| 18 | { | ||
| 19 | symbolDefinition = ExampleSymbolDefinitions.ByName(name); | ||
| 20 | return symbolDefinition != null; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } \ No newline at end of file | ||
diff --git a/src/test/Example.Extension/ExampleExtensionFactory.cs b/src/test/Example.Extension/ExampleExtensionFactory.cs deleted file mode 100644 index e54561ee..00000000 --- a/src/test/Example.Extension/ExampleExtensionFactory.cs +++ /dev/null | |||
| @@ -1,54 +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 | |||
| 3 | namespace 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 | } | ||
diff --git a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs deleted file mode 100644 index 7244798a..00000000 --- a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs +++ /dev/null | |||
| @@ -1,57 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using WixToolset.Extensibility; | ||
| 8 | using WixToolset.Extensibility.Data; | ||
| 9 | using WixToolset.Extensibility.Services; | ||
| 10 | |||
| 11 | internal class ExamplePreprocessorExtensionAndCommandLine : BasePreprocessorExtension, IExtensionCommandLine | ||
| 12 | { | ||
| 13 | private string exampleValueFromCommandLine; | ||
| 14 | |||
| 15 | public IReadOnlyCollection<ExtensionCommandLineSwitch> CommandLineSwitches => throw new NotImplementedException(); | ||
| 16 | |||
| 17 | public ExamplePreprocessorExtensionAndCommandLine() | ||
| 18 | { | ||
| 19 | this.Prefixes = new[] { "ex" }; | ||
| 20 | } | ||
| 21 | |||
| 22 | public void PreParse(ICommandLineContext context) | ||
| 23 | { | ||
| 24 | } | ||
| 25 | |||
| 26 | public bool TryParseArgument(ICommandLineParser parser, string argument) | ||
| 27 | { | ||
| 28 | if (parser.IsSwitch(argument) && argument.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase)) | ||
| 29 | { | ||
| 30 | this.exampleValueFromCommandLine = parser.GetNextArgumentOrError(argument); | ||
| 31 | return true; | ||
| 32 | } | ||
| 33 | |||
| 34 | return false; | ||
| 35 | } | ||
| 36 | |||
| 37 | public bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command) | ||
| 38 | { | ||
| 39 | command = null; | ||
| 40 | return false; | ||
| 41 | } | ||
| 42 | |||
| 43 | public void PostParse() | ||
| 44 | { | ||
| 45 | } | ||
| 46 | |||
| 47 | public override string GetVariableValue(string prefix, string name) | ||
| 48 | { | ||
| 49 | if (prefix == "ex" && "test".Equals(name, StringComparison.OrdinalIgnoreCase)) | ||
| 50 | { | ||
| 51 | return String.IsNullOrWhiteSpace(this.exampleValueFromCommandLine) ? "(null)" : this.exampleValueFromCommandLine; | ||
| 52 | } | ||
| 53 | |||
| 54 | return null; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
diff --git a/src/test/Example.Extension/ExampleRow.cs b/src/test/Example.Extension/ExampleRow.cs deleted file mode 100644 index fc20c6c9..00000000 --- a/src/test/Example.Extension/ExampleRow.cs +++ /dev/null | |||
| @@ -1,32 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Data.WindowsInstaller; | ||
| 7 | |||
| 8 | public class ExampleRow : Row | ||
| 9 | { | ||
| 10 | public ExampleRow(SourceLineNumber sourceLineNumbers, Table table) | ||
| 11 | : base(sourceLineNumbers, table) | ||
| 12 | { | ||
| 13 | } | ||
| 14 | |||
| 15 | public ExampleRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition) | ||
| 16 | : base(sourceLineNumbers, tableDefinition) | ||
| 17 | { | ||
| 18 | } | ||
| 19 | |||
| 20 | public string Example | ||
| 21 | { | ||
| 22 | get { return (string)this.Fields[0].Data; } | ||
| 23 | set { this.Fields[0].Data = value; } | ||
| 24 | } | ||
| 25 | |||
| 26 | public string Value | ||
| 27 | { | ||
| 28 | get { return (string)this.Fields[1].Data; } | ||
| 29 | set { this.Fields[1].Data = value; } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/src/test/Example.Extension/ExampleSearchSymbol.cs b/src/test/Example.Extension/ExampleSearchSymbol.cs deleted file mode 100644 index 40a39292..00000000 --- a/src/test/Example.Extension/ExampleSearchSymbol.cs +++ /dev/null | |||
| @@ -1,30 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | |||
| 7 | public enum ExampleSearchSymbolFields | ||
| 8 | { | ||
| 9 | SearchFor, | ||
| 10 | } | ||
| 11 | |||
| 12 | public class ExampleSearchSymbol : IntermediateSymbol | ||
| 13 | { | ||
| 14 | public ExampleSearchSymbol() : base(ExampleSymbolDefinitions.ExampleSearch, null, null) | ||
| 15 | { | ||
| 16 | } | ||
| 17 | |||
| 18 | public ExampleSearchSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(ExampleSymbolDefinitions.ExampleSearch, sourceLineNumber, id) | ||
| 19 | { | ||
| 20 | } | ||
| 21 | |||
| 22 | public IntermediateField this[ExampleSymbolFields index] => this.Fields[(int)index]; | ||
| 23 | |||
| 24 | public string SearchFor | ||
| 25 | { | ||
| 26 | get => this.Fields[(int)ExampleSearchSymbolFields.SearchFor]?.AsString(); | ||
| 27 | set => this.Set((int)ExampleSearchSymbolFields.SearchFor, value); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
diff --git a/src/test/Example.Extension/ExampleSymbol.cs b/src/test/Example.Extension/ExampleSymbol.cs deleted file mode 100644 index 314087e9..00000000 --- a/src/test/Example.Extension/ExampleSymbol.cs +++ /dev/null | |||
| @@ -1,30 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | |||
| 7 | public enum ExampleSymbolFields | ||
| 8 | { | ||
| 9 | Value, | ||
| 10 | } | ||
| 11 | |||
| 12 | public class ExampleSymbol : IntermediateSymbol | ||
| 13 | { | ||
| 14 | public ExampleSymbol() : base(ExampleSymbolDefinitions.Example, null, null) | ||
| 15 | { | ||
| 16 | } | ||
| 17 | |||
| 18 | public ExampleSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(ExampleSymbolDefinitions.Example, sourceLineNumber, id) | ||
| 19 | { | ||
| 20 | } | ||
| 21 | |||
| 22 | public IntermediateField this[ExampleSymbolFields index] => this.Fields[(int)index]; | ||
| 23 | |||
| 24 | public string Value | ||
| 25 | { | ||
| 26 | get => this.Fields[(int)ExampleSymbolFields.Value]?.AsString(); | ||
| 27 | set => this.Set((int)ExampleSymbolFields.Value, value); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
diff --git a/src/test/Example.Extension/ExampleSymbolDefinitions.cs b/src/test/Example.Extension/ExampleSymbolDefinitions.cs deleted file mode 100644 index f13d716d..00000000 --- a/src/test/Example.Extension/ExampleSymbolDefinitions.cs +++ /dev/null | |||
| @@ -1,67 +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 | |||
| 3 | namespace 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 | } | ||
diff --git a/src/test/Example.Extension/ExampleTableDefinitions.cs b/src/test/Example.Extension/ExampleTableDefinitions.cs deleted file mode 100644 index a2b81698..00000000 --- a/src/test/Example.Extension/ExampleTableDefinitions.cs +++ /dev/null | |||
| @@ -1,34 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using WixToolset.Data.WindowsInstaller; | ||
| 6 | |||
| 7 | public static class ExampleTableDefinitions | ||
| 8 | { | ||
| 9 | public static readonly TableDefinition ExampleTable = new TableDefinition( | ||
| 10 | "Wix4Example", | ||
| 11 | ExampleSymbolDefinitions.Example, | ||
| 12 | new[] | ||
| 13 | { | ||
| 14 | new ColumnDefinition("Example", ColumnType.String, 72, true, false, ColumnCategory.Identifier), | ||
| 15 | new ColumnDefinition("Value", ColumnType.String, 0, false, false, ColumnCategory.Formatted), | ||
| 16 | }, | ||
| 17 | strongRowType: typeof(ExampleRow), | ||
| 18 | symbolIdIsPrimaryKey: true | ||
| 19 | ); | ||
| 20 | |||
| 21 | public static readonly TableDefinition NotInAll = new TableDefinition( | ||
| 22 | "TableDefinitionNotExposedByExtension", | ||
| 23 | null, | ||
| 24 | new[] | ||
| 25 | { | ||
| 26 | new ColumnDefinition("Example", ColumnType.String, 72, true, false, ColumnCategory.Identifier), | ||
| 27 | new ColumnDefinition("Value", ColumnType.String, 0, false, false, ColumnCategory.Formatted), | ||
| 28 | }, | ||
| 29 | symbolIdIsPrimaryKey: true | ||
| 30 | ); | ||
| 31 | |||
| 32 | public static readonly TableDefinition[] All = new[] { ExampleTable }; | ||
| 33 | } | ||
| 34 | } | ||
diff --git a/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs b/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs deleted file mode 100644 index afccc56f..00000000 --- a/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs +++ /dev/null | |||
| @@ -1,33 +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 | |||
| 3 | namespace Example.Extension | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using WixToolset.Data; | ||
| 7 | using WixToolset.Data.WindowsInstaller; | ||
| 8 | using WixToolset.Extensibility; | ||
| 9 | |||
| 10 | internal class ExampleWindowsInstallerBackendExtension : BaseWindowsInstallerBackendBinderExtension | ||
| 11 | { | ||
| 12 | public override IReadOnlyCollection<TableDefinition> TableDefinitions => ExampleTableDefinitions.All; | ||
| 13 | |||
| 14 | public override bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData output, TableDefinitionCollection tableDefinitions) | ||
| 15 | { | ||
| 16 | if (ExampleSymbolDefinitions.TryGetSymbolType(symbol.Definition.Name, out var symbolType)) | ||
| 17 | { | ||
| 18 | switch (symbolType) | ||
| 19 | { | ||
| 20 | case ExampleSymbolDefinitionType.Example: | ||
| 21 | { | ||
| 22 | var row = (ExampleRow)this.BackendHelper.CreateRow(section, symbol, output, ExampleTableDefinitions.ExampleTable); | ||
| 23 | row.Example = symbol.Id.Id; | ||
| 24 | row.Value = symbol[0].AsString(); | ||
| 25 | } | ||
| 26 | return true; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | return base.TryProcessSymbol(section, symbol, output, tableDefinitions); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | } | ||
