Geowigo.Models.CartridgeTag.ImportOrMakeSoundsCache C# (CSharp) Method

ImportOrMakeSoundsCache() private method

private ImportOrMakeSoundsCache ( IsolatedStorageFile isf ) : void
isf System.IO.IsolatedStorage.IsolatedStorageFile
return void
		private void ImportOrMakeSoundsCache(IsolatedStorageFile isf)
		{
			_soundFiles = new Dictionary<int, string>();

			foreach (var sound in Cartridge.Resources.Where(m => ViewModels.SoundManager.IsPlayableSound(m)))
			{
				// Copies the sound file to the cache if it doesn't exist already.
				string cacheFilename = GetCachePathCore(sound);
				if (!isf.FileExists(cacheFilename))
				{
					using (IsolatedStorageFileStream fs = isf.CreateFile(cacheFilename))
					{
						if (sound.Type == MediaType.FDL)
						{
							// Converts the FDL to WAV and writes it.
							ConvertAndWriteFDL(fs, sound);
						}
						else
						{
							// Dumps the bytes out!
							fs.Write(sound.Data, 0, sound.Data.Length);
						}
					}
				}

				// Adds the sound filename to the dictionary.
				_soundFiles.Add(sound.MediaId, cacheFilename);
			}

			RaisePropertyChanged("Sounds");
		}