/// <summary> /// Helper method to check if the uri has an extension that is in the list /// of this handler's supported extensions. /// </summary> /// <param name="uri">The uri to check</param> /// <returns><c>true</c> if the extension is supported, <c>false</c>otherwise.</returns> protected bool CheckExtension(Uri uri) { return Extensions.Contains(uri.GetExtension().ToLower()); }
public void LoadOrImport(Uri uri) { if (uri == null) throw new ArgumentNullException("uri"); uri = DataManager.Songs.TryRewriteUri(uri); string ext = uri.GetExtension(); Song song = null; try { if (ext == ".ppl") { song = new Song(uri, new PowerpraiseSongReader()); } else if (ext == ".sng") { song = new Song(uri, new SongBeamerSongReader()); } else if (ext == ".chopro" || ext == ".cho" || ext == ".pro") { song = new Song(uri, new ChordProSongReader()); } else if (ext == ".usr") { song = new Song(uri, new CcliUsrSongReader()); } else if (ext == ".txt") { song = new Song(uri, new CcliTxtSongReader()); } else if (ext == ".xml") { song = new Song(uri, new OpenLyricsSongReader()); } else if (ext == "") // OpenSong songs have no file extension { song = new Song(uri, new OpenSongSongReader()); } else { throw new NotSupportedException("Song format is not supported."); } } catch(Exception e) { Controller.ShowEditorWindow(); MessageBox.Show(String.Format(Resource.eMsgCouldNotOpenSong, uri.FormatLocal(), e.Message), Resource.dialogError, MessageBoxButton.OK, MessageBoxImage.Error); } if (song != null) { Load(song); } }
protected virtual ICollection<ContentType> GetContentTypeByUrl(Uri url, ContentKind requiredKind) { var ext = url.GetExtension(); if (null == ext) return null; return FilterByKind(ExtensionLookup[ext], requiredKind).ToArray(); }
public static bool IsValidImageUri(Uri uri) { var ext = uri.GetExtension().ToLower(); return ImageExtensions.Contains(ext); }