public static Service uninstall(Service self)
{
try
{
List types = FanObj.@typeof(self).inheritance();
lock (m_lock)
{
// ensure service is stopped
stop(self);
// remove from byService map, it not installed short circuit
if (byService[self] == null) return self;
byService.Remove(self);
// remove from map for each type implemented by service
for (int i=0; i<types.sz(); ++i)
{
// get next type in inheritance and check if service type
Type t = (Type)types.get(i);
if (!isServiceType(t)) continue;
// lookup linked list for that type
Node node = (Node)byType[t.qname()];
if (node == null) continue;
// find this thread in the linked list
Node last = null;
bool cont = false;
while (node.service != self)
{
last = node;
node = node.next;
if (node == null) { cont=true; break; }
}
if (cont) continue;
// update the map or linked list
if (last == null)
byType[t.qname()] = node.next;
else
last.next = node.next;
}
}
}
catch (System.Exception e)
{
Err.dumpStack(e);
}
return self;
}