Beispiel #1
0
        private void RegisterService(IService inService)
        {
            m_RegisteredServices.Add(inService);

            Type      serviceType = inService.GetType();
            TypeCache selfCache   = GetCache(serviceType, true);

            selfCache.Add(inService);

            var linked = selfCache.BaseCacheTypes();

            if (linked != null)
            {
                foreach (var type in linked)
                {
                    GetCache(type, true).Add(inService);
                }
            }

            InjectStaticReferences(inService, serviceType);
            InjectReferences(inService);
            inService.InitializeService();
        }
Beispiel #2
0
        private void DeregisterService(IService inService)
        {
            m_RegisteredServices.Remove(inService);

            Type      serviceType = inService.GetType();
            TypeCache selfCache   = GetCache(serviceType, false);

            if (selfCache != null)
            {
                selfCache.Remove(inService);

                var linked = selfCache.BaseCacheTypes();
                if (linked != null)
                {
                    foreach (var type in linked)
                    {
                        GetCache(type, false)?.Remove(inService);
                    }
                }

                ClearStaticReferences(inService, serviceType);
                inService.ShutdownService();
            }
        }