diff options
14 files changed, 100 insertions, 28 deletions
diff --git a/src/WixToolset.Extensibility/Data/IBindContext.cs b/src/WixToolset.Extensibility/Data/IBindContext.cs index fd5a3ee4..ee165671 100644 --- a/src/WixToolset.Extensibility/Data/IBindContext.cs +++ b/src/WixToolset.Extensibility/Data/IBindContext.cs | |||
| @@ -2,50 +2,109 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 9 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | /// <summary> |
| 11 | /// Bind context. | ||
| 12 | /// </summary> | ||
| 11 | public interface IBindContext | 13 | public interface IBindContext |
| 12 | { | 14 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 15 | /// <summary> |
| 14 | 16 | /// Service provider. | |
| 17 | /// </summary> | ||
| 18 | IServiceProvider ServiceProvider { get; } | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Counnt of threads to use in cabbing. | ||
| 22 | /// </summary> | ||
| 15 | int CabbingThreadCount { get; set; } | 23 | int CabbingThreadCount { get; set; } |
| 16 | 24 | ||
| 25 | /// <summary> | ||
| 26 | /// Cabinet cache path. | ||
| 27 | /// </summary> | ||
| 17 | string CabCachePath { get; set; } | 28 | string CabCachePath { get; set; } |
| 18 | 29 | ||
| 30 | /// <summary> | ||
| 31 | /// Codepage for result. | ||
| 32 | /// </summary> | ||
| 19 | int Codepage { get; set; } | 33 | int Codepage { get; set; } |
| 20 | 34 | ||
| 35 | /// <summary> | ||
| 36 | /// Default compression level. | ||
| 37 | /// </summary> | ||
| 21 | CompressionLevel? DefaultCompressionLevel { get; set; } | 38 | CompressionLevel? DefaultCompressionLevel { get; set; } |
| 22 | 39 | ||
| 40 | /// <summary> | ||
| 41 | /// Delayed fields that need to be resolved again. | ||
| 42 | /// </summary> | ||
| 23 | IEnumerable<IDelayedField> DelayedFields { get; set; } | 43 | IEnumerable<IDelayedField> DelayedFields { get; set; } |
| 24 | 44 | ||
| 45 | /// <summary> | ||
| 46 | /// Embedded files to extract. | ||
| 47 | /// </summary> | ||
| 25 | IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; } | 48 | IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; } |
| 26 | 49 | ||
| 50 | /// <summary> | ||
| 51 | /// Binder extensions. | ||
| 52 | /// </summary> | ||
| 27 | IEnumerable<IBinderExtension> Extensions { get; set; } | 53 | IEnumerable<IBinderExtension> Extensions { get; set; } |
| 28 | 54 | ||
| 55 | /// <summary> | ||
| 56 | /// File system extensions. | ||
| 57 | /// </summary> | ||
| 29 | IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; } | 58 | IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; } |
| 30 | 59 | ||
| 60 | /// <summary> | ||
| 61 | /// Set of ICEs to execute. | ||
| 62 | /// </summary> | ||
| 31 | IEnumerable<string> Ices { get; set; } | 63 | IEnumerable<string> Ices { get; set; } |
| 32 | 64 | ||
| 65 | /// <summary> | ||
| 66 | /// Intermedaite folder. | ||
| 67 | /// </summary> | ||
| 33 | string IntermediateFolder { get; set; } | 68 | string IntermediateFolder { get; set; } |
| 34 | 69 | ||
| 70 | /// <summary> | ||
| 71 | /// Intermediate representation to bind. | ||
| 72 | /// </summary> | ||
| 35 | Intermediate IntermediateRepresentation { get; set; } | 73 | Intermediate IntermediateRepresentation { get; set; } |
| 36 | 74 | ||
| 75 | /// <summary> | ||
| 76 | /// Output path to bind to. | ||
| 77 | /// </summary> | ||
| 37 | string OutputPath { get; set; } | 78 | string OutputPath { get; set; } |
| 38 | 79 | ||
| 80 | /// <summary> | ||
| 81 | /// Type of PDB to create. | ||
| 82 | /// </summary> | ||
| 39 | PdbType PdbType { get; set; } | 83 | PdbType PdbType { get; set; } |
| 40 | 84 | ||
| 85 | /// <summary> | ||
| 86 | /// Output path for PDB. | ||
| 87 | /// </summary> | ||
| 41 | string PdbPath { get; set; } | 88 | string PdbPath { get; set; } |
| 42 | 89 | ||
| 90 | /// <summary> | ||
| 91 | /// Set of ICEs to skip. | ||
| 92 | /// </summary> | ||
| 43 | IEnumerable<string> SuppressIces { get; set; } | 93 | IEnumerable<string> SuppressIces { get; set; } |
| 44 | 94 | ||
| 95 | /// <summary> | ||
| 96 | /// Skip all ICEs. | ||
| 97 | /// </summary> | ||
| 45 | bool SuppressValidation { get; set; } | 98 | bool SuppressValidation { get; set; } |
| 46 | 99 | ||
| 100 | /// <summary> | ||
| 101 | /// Skip creation of output. | ||
| 102 | /// </summary> | ||
| 47 | bool SuppressLayout { get; set; } | 103 | bool SuppressLayout { get; set; } |
| 48 | 104 | ||
| 105 | /// <summary> | ||
| 106 | /// Cancellation token. | ||
| 107 | /// </summary> | ||
| 49 | CancellationToken CancellationToken { get; set; } | 108 | CancellationToken CancellationToken { get; set; } |
| 50 | } | 109 | } |
| 51 | } | 110 | } |
diff --git a/src/WixToolset.Extensibility/Data/ICommandLineContext.cs b/src/WixToolset.Extensibility/Data/ICommandLineContext.cs index fbaa84d1..d8c9469e 100644 --- a/src/WixToolset.Extensibility/Data/ICommandLineContext.cs +++ b/src/WixToolset.Extensibility/Data/ICommandLineContext.cs | |||
| @@ -8,7 +8,7 @@ namespace WixToolset.Extensibility.Data | |||
| 8 | #pragma warning disable 1591 // TODO: add documentation | 8 | #pragma warning disable 1591 // TODO: add documentation |
| 9 | public interface ICommandLineContext | 9 | public interface ICommandLineContext |
| 10 | { | 10 | { |
| 11 | IWixToolsetServiceProvider ServiceProvider { get; } | 11 | IServiceProvider ServiceProvider { get; } |
| 12 | 12 | ||
| 13 | IExtensionManager ExtensionManager { get; set; } | 13 | IExtensionManager ExtensionManager { get; set; } |
| 14 | 14 | ||
diff --git a/src/WixToolset.Extensibility/Data/ICompileContext.cs b/src/WixToolset.Extensibility/Data/ICompileContext.cs index 5da5ca84..a86fee1a 100644 --- a/src/WixToolset.Extensibility/Data/ICompileContext.cs +++ b/src/WixToolset.Extensibility/Data/ICompileContext.cs | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using System.Xml.Linq; | 8 | using System.Xml.Linq; |
| 8 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 9 | using WixToolset.Extensibility.Services; | ||
| 10 | 10 | ||
| 11 | /// <summary> | 11 | /// <summary> |
| 12 | /// Context provided to the compiler. | 12 | /// Context provided to the compiler. |
| @@ -16,7 +16,7 @@ namespace WixToolset.Extensibility.Data | |||
| 16 | /// <summary> | 16 | /// <summary> |
| 17 | /// Service provider made available to the compiler and its extensions. | 17 | /// Service provider made available to the compiler and its extensions. |
| 18 | /// </summary> | 18 | /// </summary> |
| 19 | IWixToolsetServiceProvider ServiceProvider { get; } | 19 | IServiceProvider ServiceProvider { get; } |
| 20 | 20 | ||
| 21 | /// <summary> | 21 | /// <summary> |
| 22 | /// Unique identifier for the compilation. | 22 | /// Unique identifier for the compilation. |
diff --git a/src/WixToolset.Extensibility/Data/IDecompileContext.cs b/src/WixToolset.Extensibility/Data/IDecompileContext.cs index f783a31e..63ed27d5 100644 --- a/src/WixToolset.Extensibility/Data/IDecompileContext.cs +++ b/src/WixToolset.Extensibility/Data/IDecompileContext.cs | |||
| @@ -10,7 +10,7 @@ namespace WixToolset.Extensibility.Data | |||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | #pragma warning disable 1591 // TODO: add documentation |
| 11 | public interface IDecompileContext | 11 | public interface IDecompileContext |
| 12 | { | 12 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 13 | IServiceProvider ServiceProvider { get; } |
| 14 | 14 | ||
| 15 | string DecompilePath { get; set; } | 15 | string DecompilePath { get; set; } |
| 16 | 16 | ||
diff --git a/src/WixToolset.Extensibility/Data/IFileSystemContext.cs b/src/WixToolset.Extensibility/Data/IFileSystemContext.cs index 321fa83c..2e58059a 100644 --- a/src/WixToolset.Extensibility/Data/IFileSystemContext.cs +++ b/src/WixToolset.Extensibility/Data/IFileSystemContext.cs | |||
| @@ -9,7 +9,7 @@ namespace WixToolset.Extensibility.Data | |||
| 9 | #pragma warning disable 1591 // TODO: add documentation | 9 | #pragma warning disable 1591 // TODO: add documentation |
| 10 | public interface IFileSystemContext | 10 | public interface IFileSystemContext |
| 11 | { | 11 | { |
| 12 | IWixToolsetServiceProvider ServiceProvider { get; } | 12 | IServiceProvider ServiceProvider { get; } |
| 13 | 13 | ||
| 14 | string CabCachePath { get; set; } | 14 | string CabCachePath { get; set; } |
| 15 | 15 | ||
diff --git a/src/WixToolset.Extensibility/Data/IInscribeContext.cs b/src/WixToolset.Extensibility/Data/IInscribeContext.cs index 79d4d1f5..31c66aad 100644 --- a/src/WixToolset.Extensibility/Data/IInscribeContext.cs +++ b/src/WixToolset.Extensibility/Data/IInscribeContext.cs | |||
| @@ -8,7 +8,7 @@ namespace WixToolset.Extensibility.Data | |||
| 8 | #pragma warning disable 1591 // TODO: add documentation | 8 | #pragma warning disable 1591 // TODO: add documentation |
| 9 | public interface IInscribeContext | 9 | public interface IInscribeContext |
| 10 | { | 10 | { |
| 11 | IWixToolsetServiceProvider ServiceProvider { get; } | 11 | IServiceProvider ServiceProvider { get; } |
| 12 | 12 | ||
| 13 | string InputFilePath { get; set; } | 13 | string InputFilePath { get; set; } |
| 14 | 14 | ||
diff --git a/src/WixToolset.Extensibility/Data/ILayoutContext.cs b/src/WixToolset.Extensibility/Data/ILayoutContext.cs index 89d61d5c..6b6c280a 100644 --- a/src/WixToolset.Extensibility/Data/ILayoutContext.cs +++ b/src/WixToolset.Extensibility/Data/ILayoutContext.cs | |||
| @@ -2,14 +2,14 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Extensibility.Services; | ||
| 8 | 8 | ||
| 9 | #pragma warning disable 1591 // TODO: add documentation | 9 | #pragma warning disable 1591 // TODO: add documentation |
| 10 | public interface ILayoutContext | 10 | public interface ILayoutContext |
| 11 | { | 11 | { |
| 12 | IWixToolsetServiceProvider ServiceProvider { get; } | 12 | IServiceProvider ServiceProvider { get; } |
| 13 | 13 | ||
| 14 | IEnumerable<ILayoutExtension> Extensions { get; set; } | 14 | IEnumerable<ILayoutExtension> Extensions { get; set; } |
| 15 | 15 | ||
diff --git a/src/WixToolset.Extensibility/Data/ILibraryContext.cs b/src/WixToolset.Extensibility/Data/ILibraryContext.cs index 68a9faa9..d6359ffc 100644 --- a/src/WixToolset.Extensibility/Data/ILibraryContext.cs +++ b/src/WixToolset.Extensibility/Data/ILibraryContext.cs | |||
| @@ -2,15 +2,15 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 9 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | #pragma warning disable 1591 // TODO: add documentation |
| 11 | public interface ILibraryContext | 11 | public interface ILibraryContext |
| 12 | { | 12 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 13 | IServiceProvider ServiceProvider { get; } |
| 14 | 14 | ||
| 15 | bool BindFiles { get; set; } | 15 | bool BindFiles { get; set; } |
| 16 | 16 | ||
diff --git a/src/WixToolset.Extensibility/Data/ILinkContext.cs b/src/WixToolset.Extensibility/Data/ILinkContext.cs index c6c9cf7d..7524d18c 100644 --- a/src/WixToolset.Extensibility/Data/ILinkContext.cs +++ b/src/WixToolset.Extensibility/Data/ILinkContext.cs | |||
| @@ -2,15 +2,15 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 9 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | #pragma warning disable 1591 // TODO: add documentation |
| 11 | public interface ILinkContext | 11 | public interface ILinkContext |
| 12 | { | 12 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 13 | IServiceProvider ServiceProvider { get; } |
| 14 | 14 | ||
| 15 | IEnumerable<ILinkerExtension> Extensions { get; set; } | 15 | IEnumerable<ILinkerExtension> Extensions { get; set; } |
| 16 | 16 | ||
diff --git a/src/WixToolset.Extensibility/Data/IPreprocessContext.cs b/src/WixToolset.Extensibility/Data/IPreprocessContext.cs index b07fb81f..c6bdfe3a 100644 --- a/src/WixToolset.Extensibility/Data/IPreprocessContext.cs +++ b/src/WixToolset.Extensibility/Data/IPreprocessContext.cs | |||
| @@ -2,15 +2,15 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 9 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | #pragma warning disable 1591 // TODO: add documentation |
| 11 | public interface IPreprocessContext | 11 | public interface IPreprocessContext |
| 12 | { | 12 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 13 | IServiceProvider ServiceProvider { get; } |
| 14 | 14 | ||
| 15 | IEnumerable<IPreprocessorExtension> Extensions { get; set; } | 15 | IEnumerable<IPreprocessorExtension> Extensions { get; set; } |
| 16 | 16 | ||
diff --git a/src/WixToolset.Extensibility/Data/IResolveContext.cs b/src/WixToolset.Extensibility/Data/IResolveContext.cs index 2c775932..79191a15 100644 --- a/src/WixToolset.Extensibility/Data/IResolveContext.cs +++ b/src/WixToolset.Extensibility/Data/IResolveContext.cs | |||
| @@ -2,15 +2,15 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.Threading; | 7 | using System.Threading; |
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 9 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 10 | #pragma warning disable 1591 // TODO: add documentation |
| 11 | public interface IResolveContext | 11 | public interface IResolveContext |
| 12 | { | 12 | { |
| 13 | IWixToolsetServiceProvider ServiceProvider { get; } | 13 | IServiceProvider ServiceProvider { get; } |
| 14 | 14 | ||
| 15 | IEnumerable<IBindPath> BindPaths { get; set; } | 15 | IEnumerable<IBindPath> BindPaths { get; set; } |
| 16 | 16 | ||
diff --git a/src/WixToolset.Extensibility/Data/IUnbindContext.cs b/src/WixToolset.Extensibility/Data/IUnbindContext.cs index faf77f5d..6427422f 100644 --- a/src/WixToolset.Extensibility/Data/IUnbindContext.cs +++ b/src/WixToolset.Extensibility/Data/IUnbindContext.cs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | namespace WixToolset.Extensibility.Data | 3 | namespace WixToolset.Extensibility.Data |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using WixToolset.Extensibility.Services; | ||
| 7 | 6 | ||
| 8 | #pragma warning disable 1591 // TODO: add documentation | 7 | #pragma warning disable 1591 // TODO: add documentation |
| 9 | public interface IUnbindContext | 8 | public interface IUnbindContext |
| 10 | { | 9 | { |
| 11 | IWixToolsetServiceProvider ServiceProvider { get; } | 10 | IServiceProvider ServiceProvider { get; } |
| 12 | 11 | ||
| 13 | string ExportBasePath { get; set; } | 12 | string ExportBasePath { get; set; } |
| 14 | 13 | ||
diff --git a/src/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs b/src/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs index 2d0450dc..f5fb28fb 100644 --- a/src/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs +++ b/src/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs | |||
| @@ -8,7 +8,7 @@ namespace WixToolset.Extensibility.Services | |||
| 8 | /// <summary> | 8 | /// <summary> |
| 9 | /// The core of the service provider used to add services to the service provider. | 9 | /// The core of the service provider used to add services to the service provider. |
| 10 | /// </summary> | 10 | /// </summary> |
| 11 | public interface IWixToolsetCoreServiceProvider : IWixToolsetServiceProvider | 11 | public interface IWixToolsetCoreServiceProvider : IServiceProvider |
| 12 | { | 12 | { |
| 13 | /// <summary> | 13 | /// <summary> |
| 14 | /// Adds a service to the service locator. | 14 | /// Adds a service to the service locator. |
diff --git a/src/WixToolset.Extensibility/Services/IWixToolsetServiceProvider.cs b/src/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs index 0315f7ed..68484d09 100644 --- a/src/WixToolset.Extensibility/Services/IWixToolsetServiceProvider.cs +++ b/src/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs | |||
| @@ -5,30 +5,44 @@ namespace WixToolset.Extensibility.Services | |||
| 5 | using System; | 5 | using System; |
| 6 | 6 | ||
| 7 | /// <summary> | 7 | /// <summary> |
| 8 | /// Service provider. | 8 | /// Service provider extensions. |
| 9 | /// </summary> | 9 | /// </summary> |
| 10 | public interface IWixToolsetServiceProvider : IServiceProvider | 10 | public static class ServiceProviderExtensions |
| 11 | { | 11 | { |
| 12 | /// <summary> | 12 | /// <summary> |
| 13 | /// Gets a service from the service provider. | 13 | /// Gets a service from the service provider. |
| 14 | /// </summary> | 14 | /// </summary> |
| 15 | /// <typeparam name="T">Type of service to get.</typeparam> | 15 | /// <typeparam name="T">Type of service to get.</typeparam> |
| 16 | T GetService<T>() where T : class; | 16 | /// <param name="provider">Service provider.</param> |
| 17 | public static T GetService<T>(this IServiceProvider provider) where T : class | ||
| 18 | { | ||
| 19 | return provider.GetService(typeof(T)) as T; | ||
| 20 | } | ||
| 17 | 21 | ||
| 18 | /// <summary> | 22 | /// <summary> |
| 19 | /// Gets a service from the service provider. | 23 | /// Gets a service from the service provider. |
| 20 | /// </summary> | 24 | /// </summary> |
| 25 | /// <param name="provider">Service provider.</param> | ||
| 21 | /// <param name="serviceType">Type of service to get.</param> | 26 | /// <param name="serviceType">Type of service to get.</param> |
| 22 | /// <param name="service">Retrieved service.</param> | 27 | /// <param name="service">Retrieved service.</param> |
| 23 | /// <returns>True if the service was found, otherwise false</returns> | 28 | /// <returns>True if the service was found, otherwise false</returns> |
| 24 | bool TryGetService(Type serviceType, out object service); | 29 | public static bool TryGetService(this IServiceProvider provider, Type serviceType, out object service) |
| 30 | { | ||
| 31 | service = provider.GetService(serviceType); | ||
| 32 | return service != null; | ||
| 33 | } | ||
| 25 | 34 | ||
| 26 | /// <summary> | 35 | /// <summary> |
| 27 | /// Gets a service from the service provider. | 36 | /// Gets a service from the service provider. |
| 28 | /// </summary> | 37 | /// </summary> |
| 29 | /// <typeparam name="T">Type of service to get.</typeparam> | 38 | /// <typeparam name="T">Type of service to get.</typeparam> |
| 39 | /// <param name="provider">Service provider.</param> | ||
| 30 | /// <param name="service">Retrieved service.</param> | 40 | /// <param name="service">Retrieved service.</param> |
| 31 | /// <returns>True if the service was found, otherwise false</returns> | 41 | /// <returns>True if the service was found, otherwise false</returns> |
| 32 | bool TryGetService<T>(out T service) where T : class; | 42 | public static bool TryGetService<T>(this IServiceProvider provider, out T service) where T : class |
| 43 | { | ||
| 44 | service = provider.GetService(typeof(T)) as T; | ||
| 45 | return service != null; | ||
| 46 | } | ||
| 33 | } | 47 | } |
| 34 | } | 48 | } |
