Beispiel #1
0
        /// <inheritdoc/>
        public async Task AddLocalSoundAsync(Sound s)
        {
            Guard.IsNotNull(s, nameof(s));

            bool isAlreadyInstalled = await IsSoundInstalledAsync(s.Id);

            if (isAlreadyInstalled)
            {
                return;
            }

            _localSoundCache.Add(s);
            await WriteCacheAsync();

            LocalSoundAdded?.Invoke(this, s);
        }
Beispiel #2
0
        /// <inheritdoc/>
        public async Task AddLocalSoundAsync(Sound s)
        {
            Guard.IsNotNull(s, nameof(s));

            bool isAlreadyInstalled = await IsSoundInstalledAsync(s.Id);

            if (isAlreadyInstalled)
            {
                return;
            }

            StorageFile localDataFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
                LocalDataFileName,
                CreationCollisionOption.OpenIfExists);

            _localSoundCache.Add(s);
            string json = JsonSerializer.Serialize(_localSoundCache);
            await FileIO.WriteTextAsync(localDataFile, json);

            LocalSoundAdded?.Invoke(this, s);
        }