annotate Implab/ServiceLocator.cs @ 79:05e6468f066f v2

sync
author cin
date Mon, 22 Sep 2014 18:20:49 +0400
parents 48763f3b5db8
children b33832ab0262
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
1 using System;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
2 using System.Collections.Generic;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
3 using System.Linq;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
4 using System.Web;
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
5 using System.Diagnostics;
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
6
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
7 namespace Implab {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
8 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
9 /// Коллекция сервисов, позволяет регистрировать и получать сервисы.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
10 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
11 public class ServiceLocator: Component, IServiceLocator, IServiceProvider {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
12 // запись об сервисе
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
13 struct ServiceEntry {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
14 public object service; // сервис
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
15 public bool shared; // признак того, что сервис НЕ нужно освобождать
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
16 public Func<object> activator; // активатор сервиса при первом обращении
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
17 public List<Type> associated; // ссылки на текущую запись
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
18 public Type origin; // ссылка на оригинальную запись о сервисе
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
19 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
20
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
21 // словарь существующих сервисов
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
22 readonly Dictionary<Type, ServiceEntry> m_services = new Dictionary<Type,ServiceEntry>();
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
23
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
24 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
25 /// Получает объект предоставляющий сервис <typeparamref name="T"/>.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
26 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
27 /// <typeparam name="T">Тип запрашиваемого сервиса</typeparam>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
28 /// <returns>Объект, реализующий сервис</returns>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
29 /// <exception cref="KeyNotFoundException">Сервис не зарегистрирован</exception>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
30 public T GetService<T>() {
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
31 object result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
32 if (TryGetService(typeof(T), out result))
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
33 return (T)result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
34 throw new ApplicationException (String.Format ("{0} doesn't provide {1} service", this, typeof(T)));
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
35 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
36
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
37
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
38 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
39 /// Пытается получить указанный сервис, в случае, если компонента не предоставляет требуемый сервис
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
40 /// не возникает исключений.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
41 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
42 /// <typeparam name="T">Тип требуемого сервиса.</typeparam>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
43 /// <param name="service">Объект реализующий сервис, или <c>default(T)</c> если такового нет.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
44 /// <returns><c>true</c> - сервис найден, <c>false</c> - сервис не зарегистрирован.</returns>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
45 public bool TryGetService<T>(out T service) {
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
46 object result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
47 if (TryGetService(typeof(T), out result)) {
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
48 service = (T)result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
49 return true;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
50 }
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
51 service = default(T);
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
52 return false;
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
53 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
54
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
55 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
56 /// Получает объект предоставляющий сервис <paramref name="serviceType"/>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
57 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
58 /// <param name="serviceType">Тип запрашиваемого сервиса</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
59 /// <returns>Объект, реализующий сервис</returns>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
60 /// <exception cref="KeyNotFoundException">Сервис не зарегистрирован</exception>
68
9dd6a896a385 ServiceLocator: small refactoring, GetService method is made virtual
cin
parents: 40
diff changeset
61 public object GetService(Type serviceType) {
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
62 object result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
63 if (TryGetService(serviceType, out result))
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
64 return result;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
65 throw new ApplicationException (String.Format ("{0} doesn't provide {1} service", this, serviceType));
68
9dd6a896a385 ServiceLocator: small refactoring, GetService method is made virtual
cin
parents: 40
diff changeset
66 }
9dd6a896a385 ServiceLocator: small refactoring, GetService method is made virtual
cin
parents: 40
diff changeset
67
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
68 /// <summary>
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
69 /// Пытается получить требуемый сервис или совместимый с ним.
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
70 /// </summary>
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
71 /// <returns><c>true</c>, если сервис был найден, <c>false</c> в противном случае..</returns>
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
72 /// <param name="serviceType">Тип запрашиваемого сервиса.</param>
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
73 /// <param name="service">Искомый сервис.</param>
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
74 public virtual bool TryGetService(Type serviceType, out object service) {
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
75 if (serviceType == null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
76 throw new ArgumentNullException("serviceType");
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
77 AssertNotDisposed();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
78
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
79 ServiceEntry se;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
80 if (!m_services.TryGetValue(serviceType, out se)) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
81 // ищем ближайщий объект, реализующий нужный сервис
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
82 Type pt = null;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
83 foreach (var t in m_services.Keys)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
84 if (serviceType.IsAssignableFrom(t) && (pt == null || t.IsAssignableFrom(pt)))
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
85 pt = t;
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
86
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
87 if (pt == null) {
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
88 // нет нужного сервиса
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
89 service = null;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
90 return false;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
91 }
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
92
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
93 var pe = m_services[pt];
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
94
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
95 // найденная запись может ссылаться на оригинальную запись с сервисом
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
96 if(pe.origin != null) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
97 pt = pe.origin;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
98 pe = m_services[pt];
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
99 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
100
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
101 // добавляем список с обратными ссылками
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
102 if (pe.associated == null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
103 pe.associated = new List<Type>();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
104
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
105 pe.associated.Add(serviceType);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
106
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
107 // обновляем родительскую запись
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
108 m_services[pt] = pe;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
109
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
110 // создаем запись со ссылкой
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
111 se = new ServiceEntry {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
112 service = pe.service,
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
113 origin = pt,
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
114 shared = true // предотвращаем множественные попытки освобождения
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
115 };
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
116
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
117 m_services[serviceType] = se;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
118 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
119
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
120 // запись содержит в себе информацию о сервисе
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
121 if (se.service != null) {
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
122 service = se.service;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
123 return true;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
124 }
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
125
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
126 // текущая запись является ссылкой
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
127 if (se.origin != null) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
128 se.service = GetService(se.origin);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
129 m_services[serviceType] = se;
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
130 service = se.service;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
131 return true;
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
132 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
133
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
134 // текущая запись не является ссылкой и не имеет информации о сервисе
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
135 // она должна сожержать информацию об активации
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
136 if (se.activator != null) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
137 se.service = se.activator();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
138
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
139 m_services[serviceType] = se;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
140
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
141 service = se.service;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
142 return true;
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
143 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
144
69
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
145 service = null;
48763f3b5db8 service locator refactoring
cin
parents: 68
diff changeset
146 return false;
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
147 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
148
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
149 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
150 /// Регистрирует фабрику для активации сервиса по первому требованию.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
151 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
152 /// <typeparam name="T">Тип регистрируемого сервиса.</typeparam>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
153 /// <param name="activator">Фабрика для создания/получения объекта, предоставляющего сервис.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
154 /// <exception cref="InvalidOperationException">Указанный сервис уже зарегистрирован.</exception>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
155 /// <remarks>При освобождении сервис-локатора, сервисы полученные в результате активации также будут освобождены.</remarks>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
156 public void Register<T>(Func<T> activator) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
157 if (activator == null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
158 throw new ArgumentNullException("activator");
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
159
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
160 AssertNotDisposed();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
161
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
162 Unregister(typeof(T));
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
163
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
164 m_services[typeof(T)] = new ServiceEntry {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
165 activator = () => activator() as object
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
166 };
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
167 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
168
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
169 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
170 /// Регистрирует объект, предоставляющий сервис.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
171 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
172 /// <typeparam name="T">Тип регистрируемого сервиса.</typeparam>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
173 /// <param name="service">Объект, предоставляющий сервис.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
174 /// <exception cref="InvalidOperationException">Указанный сервис уже зарегистрирован.</exception>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
175 /// <remarks>Сервис-локатором не управляет временем жизни объекта для зарегистрированного сервиса.</remarks>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
176 public void Register<T>(T service) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
177 Register(service, true);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
178 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
179
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
180 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
181 /// Регистрирует объект, предоставляющий сервис.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
182 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
183 /// <typeparam name="T">Тип регистрируемого сервиса.</typeparam>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
184 /// <param name="service">Объект, предоставляющий сервис.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
185 /// <param name="shared">Признак того, что объект является разделяемым и сервис-локатор не должен его освобождать.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
186 /// <exception cref="InvalidOperationException">Указанный сервис уже зарегистрирован.</exception>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
187 public void Register<T>(T service, bool shared) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
188 if (service == null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
189 throw new ArgumentNullException("service");
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
190
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
191 AssertNotDisposed();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
192
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
193 Unregister(typeof(T));
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
194
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
195 m_services[typeof(T)] = new ServiceEntry { service = service, shared = shared };
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
196 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
197
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
198 public void Unregister(Type serviceType) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
199 if (serviceType == null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
200 throw new ArgumentNullException("serviceType");
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
201
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
202 AssertNotDisposed();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
203
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
204 ServiceEntry se;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
205 if (m_services.TryGetValue(serviceType, out se)) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
206 // освобождаем ресурсы
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
207 if (se.service != null && !se.shared)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
208 ((IDisposable)se.service).Dispose();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
209 m_services.Remove(serviceType);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
210
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
211 // убираем связанные записи
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
212 if (se.associated != null)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
213 foreach (var item in se.associated)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
214 m_services.Remove(item);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
215 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
216 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
217
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
218 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
219 /// Освобождает зарегистрированные сервисы (которые требуется освобоить).
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
220 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
221 /// <param name="disposing">Призанак того, что нужно освободить ресурсы.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
222 protected override void Dispose(bool disposing) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
223 if (disposing) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
224
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
225 foreach (var entry in m_services.Values)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
226 if (!entry.shared && entry.service is IDisposable)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
227 ((IDisposable)entry.service).Dispose();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
228
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
229 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
230 base.Dispose(disposing);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
231 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
232 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
233 }