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