Esempio n. 1
0
        public void LoadService(Type service)                                             // Load the service using the type
        {
            if (!service.IsClass || !typeof(PointBlankService).IsAssignableFrom(service)) // If it isn't a service then return
            {
                return;
            }
            if (service == typeof(PointBlankService)) // Prevents the actual service API from being loaded
            {
                return;
            }
            PointBlankService ser = (PointBlankService)Activator.CreateInstance(service);

            if (ServicesData.CheckKey(ser.Name))
            {
                ser.AutoStart = ((string)ServicesData.Document[ser.Name]["AutoStart"]).ToLower() == "true";
                ser.Replace   = ((string)ServicesData.Document[ser.Name]["Replace"]).ToLower() == "true";
            }
            else
            {
                JObject jObj = new JObject
                {
                    { "AutoStart", (ser.AutoStart ? "true" : "false") },
                    { "Replace", (ser.Replace ? "true" : "false") }
                };

                ServicesData.Document.Add(ser.Name, jObj);
                UniServicesData.Save();
            }

            _tempServices.Add(ser);
        }
Esempio n. 2
0
        public void Shutdown() // The service manager is getting shut down
        {
            if (!Initialized)  // Don't bother shutting down if the service manager isn't initialized
            {
                return;
            }

            UniServicesData.Save();                                                      // Save the services data
            foreach (ServiceWrapper wrapper in Enviroment.services.Select(a => a.Value)) // Stop the services
            {
                _tempWrappers.Add(wrapper);
            }
            foreach (ServiceWrapper wrapper in _tempWrappers.OrderByDescending(a => a.ServiceClass.LaunchIndex))
            {
                StopService(wrapper);
            }
            _tempWrappers.Clear();

            // Set the variables
            Initialized = false;
        }