diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-11-11 12:40:51 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-11-11 12:40:51 -0800 |
| commit | 3f6e936c5e9d7a9df7e3e0ed1bc17001c53db5b3 (patch) | |
| tree | 7a2a0d3da7cecfa5c1a7ac45c20642d1c4632586 /src | |
| parent | f87ec715a88a78a6d7788503da2ebec786544e75 (diff) | |
| download | wix-3f6e936c5e9d7a9df7e3e0ed1bc17001c53db5b3.tar.gz wix-3f6e936c5e9d7a9df7e3e0ed1bc17001c53db5b3.tar.bz2 wix-3f6e936c5e9d7a9df7e3e0ed1bc17001c53db5b3.zip | |
Introduce IExtensionFactory as mechanism to create extensions
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Extensibility/IExtensionFactory.cs | 17 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/Services/IExtensionManager.cs | 28 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/WixToolset.Extensibility/IExtensionFactory.cs b/src/WixToolset.Extensibility/IExtensionFactory.cs new file mode 100644 index 00000000..234f64fa --- /dev/null +++ b/src/WixToolset.Extensibility/IExtensionFactory.cs | |||
| @@ -0,0 +1,17 @@ | |||
| 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 | |||
| 7 | public interface IExtensionFactory | ||
| 8 | { | ||
| 9 | /// <summary> | ||
| 10 | /// Request to create an extension of the specified type. | ||
| 11 | /// </summary> | ||
| 12 | /// <param name="extensionType">Extension type to create.</param> | ||
| 13 | /// <param name="extension">Extension created.</param> | ||
| 14 | /// <returns>True if extension was created; otherwise false.</returns> | ||
| 15 | bool TryCreateExtension(Type extensionType, out object extension); | ||
| 16 | } | ||
| 17 | } | ||
diff --git a/src/WixToolset.Extensibility/Services/IExtensionManager.cs b/src/WixToolset.Extensibility/Services/IExtensionManager.cs index 1d693ee4..32ee85a5 100644 --- a/src/WixToolset.Extensibility/Services/IExtensionManager.cs +++ b/src/WixToolset.Extensibility/Services/IExtensionManager.cs | |||
| @@ -7,10 +7,34 @@ namespace WixToolset.Extensibility.Services | |||
| 7 | 7 | ||
| 8 | public interface IExtensionManager | 8 | public interface IExtensionManager |
| 9 | { | 9 | { |
| 10 | Assembly Add(Assembly assembly); | 10 | /// <summary> |
| 11 | /// Adds an extension assembly directly to the manager. | ||
| 12 | /// </summary> | ||
| 13 | /// <param name="extensionAssembly">Extension assembly.</param> | ||
| 14 | void Add(Assembly extensionAssembly); | ||
| 11 | 15 | ||
| 12 | Assembly Load(string extension); | 16 | /// <summary> |
| 17 | /// Loads an extension assembly from a type description string. | ||
| 18 | /// </summary> | ||
| 19 | /// <param name="extension">The assembly type description string.</param> | ||
| 20 | /// <returns>The loaded assembly. This assembly can be ignored since the extension manager maintains the list of loaded assemblies internally.</returns> | ||
| 21 | /// <remarks> | ||
| 22 | /// <paramref name="extension"/> can be in several different forms: | ||
| 23 | /// <list type="number"> | ||
| 24 | /// <item><term>AssemblyName (MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089)</term></item> | ||
| 25 | /// <item><term>Absolute path to an assembly (C:\MyExtensions\ExtensionAssembly.dll)</term></item> | ||
| 26 | /// <item><term>Filename of an assembly in the application directory (ExtensionAssembly.dll)</term></item> | ||
| 27 | /// <item><term>Relative path to an assembly (..\..\MyExtensions\ExtensionAssembly.dll)</term></item> | ||
| 28 | /// </list> | ||
| 29 | /// </remarks> | ||
| 30 | void Load(string extensionPath); | ||
| 13 | 31 | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// Creates extension of specified type from factories loaded into the extension manager. | ||
| 35 | /// </summary> | ||
| 36 | /// <typeparam name="T">Type of extension to create.</typeparam> | ||
| 37 | /// <returns>Extensions created of the specified type.</returns> | ||
| 14 | IEnumerable<T> Create<T>() where T : class; | 38 | IEnumerable<T> Create<T>() where T : class; |
| 15 | } | 39 | } |
| 16 | } | 40 | } |
