diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-08-20 14:22:07 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-08-20 14:25:49 -0700 |
| commit | 3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c (patch) | |
| tree | bbe907a4c5ebf7aa5e3f02141f6e3abd31cb7b5c /src/WixToolset.Extensibility/ExtensionData.cs | |
| parent | 6dee3b45cb679786bd49a5db8fde9006d283b3e2 (diff) | |
| download | wix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.tar.gz wix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.tar.bz2 wix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.zip | |
Move to .NET Core 2.0
Diffstat (limited to 'src/WixToolset.Extensibility/ExtensionData.cs')
| -rw-r--r-- | src/WixToolset.Extensibility/ExtensionData.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/ExtensionData.cs b/src/WixToolset.Extensibility/ExtensionData.cs new file mode 100644 index 00000000..4cf262b9 --- /dev/null +++ b/src/WixToolset.Extensibility/ExtensionData.cs | |||
| @@ -0,0 +1,75 @@ | |||
| 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 WixToolset.Extensibility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using System.Reflection; | ||
| 8 | using System.Xml; | ||
| 9 | using WixToolset.Data; | ||
| 10 | |||
| 11 | public abstract class ExtensionData : IExtensionData | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Gets the optional table definitions for this extension. | ||
| 15 | /// </summary> | ||
| 16 | /// <value>Table definisions for this extension or null if there are no table definitions.</value> | ||
| 17 | public virtual TableDefinitionCollection TableDefinitions | ||
| 18 | { | ||
| 19 | get { return null; } | ||
| 20 | } | ||
| 21 | |||
| 22 | /// <summary> | ||
| 23 | /// Gets the optional default culture. | ||
| 24 | /// </summary> | ||
| 25 | /// <value>The optional default culture.</value> | ||
| 26 | public virtual string DefaultCulture | ||
| 27 | { | ||
| 28 | get { return null; } | ||
| 29 | } | ||
| 30 | |||
| 31 | /// <summary> | ||
| 32 | /// Gets the optional library associated with this extension. | ||
| 33 | /// </summary> | ||
| 34 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
| 35 | /// <returns>The library for this extension or null if there is no library.</returns> | ||
| 36 | public virtual Library GetLibrary(TableDefinitionCollection tableDefinitions) | ||
| 37 | { | ||
| 38 | return null; | ||
| 39 | } | ||
| 40 | |||
| 41 | /// <summary> | ||
| 42 | /// Help for loading a library from an embedded resource. | ||
| 43 | /// </summary> | ||
| 44 | /// <param name="assembly">The assembly containing the embedded resource.</param> | ||
| 45 | /// <param name="resourceName">The name of the embedded resource being requested.</param> | ||
| 46 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
| 47 | /// <returns>The loaded library.</returns> | ||
| 48 | protected static Library LoadLibraryHelper(Assembly assembly, string resourceName, TableDefinitionCollection tableDefinitions) | ||
| 49 | { | ||
| 50 | using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) | ||
| 51 | { | ||
| 52 | UriBuilder uriBuilder = new UriBuilder(assembly.CodeBase); | ||
| 53 | uriBuilder.Scheme = "embeddedresource"; | ||
| 54 | uriBuilder.Fragment = resourceName; | ||
| 55 | |||
| 56 | return Library.Load(resourceStream, uriBuilder.Uri, tableDefinitions, false); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | /// <summary> | ||
| 61 | /// Helper for loading table definitions from an embedded resource. | ||
| 62 | /// </summary> | ||
| 63 | /// <param name="assembly">The assembly containing the embedded resource.</param> | ||
| 64 | /// <param name="resourceName">The name of the embedded resource being requested.</param> | ||
| 65 | /// <returns>The loaded table definitions.</returns> | ||
| 66 | protected static TableDefinitionCollection LoadTableDefinitionHelper(Assembly assembly, string resourceName) | ||
| 67 | { | ||
| 68 | using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) | ||
| 69 | using (XmlReader reader = XmlReader.Create(resourceStream)) | ||
| 70 | { | ||
| 71 | return TableDefinitionCollection.Load(reader); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
