Example #1
0
        private void Init()
        {
            _ins = this;
            LoadData();

            const string noPurgeLifetime = "none";

            for (var i = 0; i < _config.Purges.Count; i++)
            {
                var purge = _config.Purges[i];
                if (!string.IsNullOrEmpty(purge.Permission))
                {
                    permission.RegisterPermission(purge.Permission, this);
                }

                var isNoPurge = purge.LifetimeRaw.Equals(noPurgeLifetime, StringComparison.CurrentCultureIgnoreCase);
                if (!isNoPurge && !ConvertToSeconds(purge.LifetimeRaw, out purge.Lifetime))
                {
                    PrintWarning(
                        $"Unable to parse {purge.LifetimeRaw} value as Lifetime. Disabling purge for this purge setup");
                    purge.NoPurge = true;
                }

                if (isNoPurge)
                {
                    purge.NoPurge = true;
                }
            }

            AddCovalenceCommand("autopurge.run", nameof(CommandRun));
        }
Example #2
0
        private void Unload()
        {
            _timerLastSeen?.Destroy();
            _timerPurge?.Destroy();

            SaveData();

            _config = null;
            _data   = null;
            _ins    = null;
        }