private static void ExpandPlaylists <T>(IElementContainer <T> playlist, IList <T> elements, Action <String> errorHandler) where T : IContainerElement { int count = 0; foreach (T element in elements) { IElement inner = element.InnerElement; if (inner is IFileElement) { IFileElement fileElement = (IFileElement)inner; if (fileElement.FilePath.EndsWith(".m3u", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".pls", StringComparison.InvariantCultureIgnoreCase)) { count += AddPlaylistElements(playlist, fileElement, element, errorHandler); } else { playlist.InsertGeneralElement(count, element); ++count; } } else { playlist.InsertGeneralElement(count, element); ++count; } } }