aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/WixToolsetServiceProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/WixToolsetServiceProvider.cs')
-rw-r--r--src/WixToolset.Core/WixToolsetServiceProvider.cs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs
index 2cd097a4..1d475d00 100644
--- a/src/WixToolset.Core/WixToolsetServiceProvider.cs
+++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs
@@ -96,8 +96,7 @@ namespace WixToolset.Core
96 return service != null; 96 return service != null;
97 } 97 }
98 98
99 public bool TryGetService<T>(out T service) 99 public bool TryGetService<T>(out T service) where T : class
100 where T : class
101 { 100 {
102 var success = this.TryGetService(typeof(T), out var untypedService); 101 var success = this.TryGetService(typeof(T), out var untypedService);
103 service = (T)untypedService; 102 service = (T)untypedService;
@@ -109,8 +108,7 @@ namespace WixToolset.Core
109 return this.TryGetService(serviceType, out var service) ? service : throw new ArgumentException($"Unknown service type: {serviceType.Name}", nameof(serviceType)); 108 return this.TryGetService(serviceType, out var service) ? service : throw new ArgumentException($"Unknown service type: {serviceType.Name}", nameof(serviceType));
110 } 109 }
111 110
112 public T GetService<T>() 111 public T GetService<T>() where T : class
113 where T : class
114 { 112 {
115 return (T)this.GetService(typeof(T)); 113 return (T)this.GetService(typeof(T));
116 } 114 }
@@ -120,14 +118,12 @@ namespace WixToolset.Core
120 this.CreationFunctions[serviceType] = creationFunction; 118 this.CreationFunctions[serviceType] = creationFunction;
121 } 119 }
122 120
123 public void AddService<T>(Func<IWixToolsetCoreServiceProvider, Dictionary<Type, object>, T> creationFunction) 121 public void AddService<T>(Func<IWixToolsetCoreServiceProvider, Dictionary<Type, object>, T> creationFunction) where T : class
124 where T : class
125 { 122 {
126 this.AddService(typeof(T), creationFunction); 123 this.AddService(typeof(T), creationFunction);
127 } 124 }
128 125
129 private static T AddSingleton<T>(Dictionary<Type, object> singletons, T service) 126 private static T AddSingleton<T>(Dictionary<Type, object> singletons, T service) where T : class
130 where T : class
131 { 127 {
132 singletons.Add(typeof(T), service); 128 singletons.Add(typeof(T), service);
133 return service; 129 return service;