Beispiel #1
0
        /// <summary>
        /// Initialize from saved file (or create if doesn't exist)
        /// </summary>
        /// <param name="bot">The ServiceManager's bot.</param>
        /// <param name="path">File path for saving services.</param>
        public ServiceManager(Bot bot, string path)
        {
            MaxIDNum = 50000;
            FilePath = path;
            StartTimer();
            try
            {
                using (var ms = new FileStream(FilePath, FileMode.Open))
                {
                    var set = new BinaryFormatter();
                    RunningServices = set.Deserialize(ms) as List <Service>;
                }
            }
            catch (FileNotFoundException) { }
            catch (SerializationException) { }
            catch (ArgumentException) { }

            foreach (Service s in RunningServices)
            {
                s.bot = bot;
                if (s.ID == 0)
                {
                    s.ID = GetNewID();
                }
            }

            ServiceAllocator.AllocateStartupServices(bot, RunningServices, this);
        }
Beispiel #2
0
        public ServiceManager(Bot bot)
        {
            StartTimer();
            MaxIDNum = 50000;

            ServiceAllocator.AllocateStartupServices(bot, RunningServices, this);
        }