@@ -20,13 +20,11 namespace Implab { | |||
|
20 | 20 | public void Dispose() { |
|
21 | 21 | if (shared) |
|
22 | 22 | return; |
|
23 | if (cleanup != null) | |
|
24 |
|
|
|
25 |
|
|
|
26 | var d = service as IDisposable; | |
|
27 |
|
|
|
28 | d.Dispose(); | |
|
29 | } | |
|
23 | if (cleanup != null) { | |
|
24 | if (service != null) | |
|
25 | cleanup(service); | |
|
26 | } else | |
|
27 | Safe.Dispose(service); | |
|
30 | 28 | } |
|
31 | 29 | |
|
32 | 30 | #endregion |
@@ -173,10 +171,11 namespace Implab { | |||
|
173 | 171 | |
|
174 | 172 | Unregister(typeof(T)); |
|
175 | 173 | |
|
176 |
|
|
|
177 |
|
|
|
178 | cleanup = instance => cleanup((T)instance) | |
|
179 | }; | |
|
174 | var serviceEntry = new ServiceEntry(); | |
|
175 | serviceEntry.activator = () => activator(); | |
|
176 | if (cleanup != null) | |
|
177 | serviceEntry.cleanup = instance => cleanup((T)instance); | |
|
178 | m_services[typeof(T)] = serviceEntry; | |
|
180 | 179 | } |
|
181 | 180 | |
|
182 | 181 | public void Register<T>(Func<T> activator) { |
General Comments 0
You need to be logged in to leave comments.
Login now