public AlertSound Get(string filenameOrAlias) { AlertSound sound; if (aliasMap.TryGetValue(filenameOrAlias, out sound)) { return(sound); } // not alias => must be filename if (!File.Exists(filenameOrAlias)) { // try prepending resource path string filenameWithResourcePath = String.Format("{0}/{1}", Globals.SoundFilesRoot, filenameOrAlias); if (!File.Exists(filenameWithResourcePath)) { throw new ResourceNotFoundException(filenameOrAlias); } sound = Get(filenameWithResourcePath); // register filepath without the resource path as an alias RegisterAlias(sound, filenameOrAlias); return(sound); } sound = new AlertSound(filenameOrAlias); allAlertSounds.Add(sound); return(sound); }
public void RegisterAlias(AlertSound sound, string alias) { try { sound.AddAlias(alias); aliasMap.Add(alias, sound); } catch (ArgumentException) { throw new DuplicateAlertSoundAliasException(alias); } }