Example #1
0
        public CachedProfileData(IAppSettings appSettings, IDisposable disposableLock)
        {
            Ensure.NotNull(appSettings, nameof(appSettings));

            _appSettings    = appSettings;
            _disposableLock = disposableLock;

            _cached = appSettings.Profiles;
        }
Example #2
0
        public void Dispose()
        {
            if (HasChanges)
            {
                if (_disposableLock == null)
                {
                    throw new InvalidOperationException("CachedProfileData mut be locked to support data changes");
                }
                Save();
            }

            _appSettings = null;
            _disposableLock?.Dispose();
            _disposableLock = null;
            _cached         = null;
        }