本文整理汇总了C#中Playlist.AddSongs方法的典型用法代码示例。如果您正苦于以下问题:C# Playlist.AddSongs方法的具体用法?C# Playlist.AddSongs怎么用?C# Playlist.AddSongs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist.AddSongs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Helpers
static Helpers()
{
Playlist1 = new Playlist("Playlist1");
Playlist1.AddSongs(new[] { LocalSong1, LocalSong2 });
Playlist2 = new Playlist("Playlist2");
Playlist2.AddSongs(new[] { (Song)LocalSong1, YoutubeSong1 });
}
示例2: SetsCorrectPlaylistIndexes
public void SetsCorrectPlaylistIndexes()
{
Song[] songs = Helpers.SetupSongMocks(2);
var playlist = new Playlist("Playlist");
playlist.AddSongs(songs);
Assert.Equal(0, playlist[0].Index);
Assert.Equal(1, playlist[1].Index);
}
示例3: VotesAfterCurrentSongIndexDontResetWhenCurrentSongIndexAdvances
public void VotesAfterCurrentSongIndexDontResetWhenCurrentSongIndexAdvances()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(3));
playlist.VoteFor(0);
playlist.VoteFor(1);
playlist.VoteFor(2);
playlist.CurrentSongIndex = 1;
Assert.Equal(1, playlist[1].Votes);
Assert.Equal(1, playlist[2].Votes);
}
示例4: VotesRespectCurrentSongIndex
public void VotesRespectCurrentSongIndex()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(5));
List<PlaylistEntry> entries = playlist.ToList();
var expectedOrder = new[] { entries[0], entries[1], entries[3], entries[4], entries[2] };
playlist.CurrentSongIndex = 1;
playlist.VoteFor(4);
playlist.VoteFor(4);
playlist.VoteFor(3);
Assert.Equal(playlist, expectedOrder);
}
示例5: WithIndexThatIsLessThanCurrentSongIndexThrowsInvalidOperationException
public void WithIndexThatIsLessThanCurrentSongIndexThrowsInvalidOperationException()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(3));
playlist.CurrentSongIndex = 1;
Assert.Throws<InvalidOperationException>(() => playlist.VoteFor(0));
}
示例6: SmokeTest
public void SmokeTest()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(4));
List<PlaylistEntry> snapShot = playlist.ToList();
var expectedOrder = new[] { snapShot[3], snapShot[2], snapShot[0], snapShot[1] };
playlist.VoteFor(3);
playlist.VoteFor(0);
playlist.VoteFor(3);
playlist.VoteFor(2);
Assert.Equal(expectedOrder, playlist);
}
示例7: ReadPlaylists
public static IEnumerable<Playlist> ReadPlaylists(Stream stream)
{
IEnumerable<Song> songs = ReadSongs(stream);
stream.Position = 0;
var playlists = XDocument.Load(stream)
.Descendants("Root")
.Descendants("Playlists")
.Elements("Playlist")
.Select
(
playlist =>
new
{
Name = playlist.Attribute("Name").Value,
Entries = playlist
.Descendants("Entries")
.Elements("Entry")
.Select
(
entry =>
{
var type = entry.Attribute("Type").Value == "Local" ? typeof(LocalSong) : typeof(YoutubeSong);
TimeSpan? duration = null;
string title = null;
if (type == typeof(YoutubeSong))
{
duration = TimeSpan.FromTicks(Int64.Parse(entry.Attribute("Duration").Value));
title = entry.Attribute("Title").Value;
}
return new
{
Path = entry.Attribute("Path").Value,
Type = type,
Duration = duration,
Title = title
};
}
)
}
);
return playlists.Select
(
p =>
{
var playlist = new Playlist(p.Name);
var s = p.Entries
.Select
(
entry =>
{
if (entry.Type == typeof(YoutubeSong))
{
return new YoutubeSong(entry.Path, AudioType.Mp3, entry.Duration.Value, CoreSettings.Default.StreamYoutube)
{
Title = entry.Title
};
}
return songs.First(song => song.OriginalPath == entry.Path);
}
);
playlist.AddSongs(s);
return playlist;
}
)
.ToList();
}
示例8: DeserializePlaylists
public static IReadOnlyList<Playlist> DeserializePlaylists(JObject json, IReadOnlyList<Song> songCache = null)
{
IEnumerable<Song> songs = songCache ?? DeserializeSongs(json);
var playlists = json["playlists"].Select(playlist => new
{
Name = playlist["name"].ToObject<string>(),
Entries = playlist["entries"].Select(entry =>
{
var typeString = entry["type"].ToObject<string>();
Type type;
if (typeString == "Local")
{
type = typeof(LocalSong);
}
else if (typeString == "YouTube")
{
type = typeof(YoutubeSong);
}
else if (typeString == "SoundCloud")
{
type = typeof(SoundCloudSong);
}
else
{
throw new NotImplementedException("Type not implemented.");
}
TimeSpan? duration = null;
string title = null;
if (type == typeof(YoutubeSong) || type == typeof(SoundCloudSong))
{
duration = TimeSpan.FromTicks(entry["duration"].ToObject<long>());
title = entry["title"].ToObject<string>();
}
string artist = null;
string playbackPath = null;
if (type == typeof(SoundCloudSong))
{
artist = entry["artist"].ToObject<string>();
playbackPath = entry["playbackPath"].ToObject<string>();
}
return new
{
OriginalPath = entry["path"].ToObject<string>(),
PlaybackPath = playbackPath,
Type = type,
Duration = duration,
Title = title,
Artist = artist
};
})
});
return playlists.Select(p =>
{
var playlist = new Playlist(p.Name);
var s = p.Entries.Select(entry =>
{
if (entry.Type == typeof(YoutubeSong))
{
return new YoutubeSong(entry.OriginalPath, entry.Duration.Value)
{
Title = entry.Title
};
}
if (entry.Type == typeof(SoundCloudSong))
{
return new SoundCloudSong(entry.OriginalPath, entry.PlaybackPath)
{
Artist = entry.Artist,
Title = entry.Title,
Duration = entry.Duration.Value
};
}
if (entry.Type == typeof(LocalSong))
{
// We search for the path locally, so we don't have to serialize data about
// local songs
return songs.First(song => song.OriginalPath == entry.OriginalPath);
}
throw new NotImplementedException();
});
playlist.AddSongs(s);
return playlist;
}).ToList();
//.........这里部分代码省略.........
示例9: FirstEntryLeavesItInFirstPlace
public void FirstEntryLeavesItInFirstPlace()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(2));
List<PlaylistEntry> snapshot = playlist.ToList();
playlist.VoteFor(0);
Assert.Equal(snapshot, playlist);
}
示例10: EntryBeforeCurrentSongWorks
public void EntryBeforeCurrentSongWorks()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(2));
playlist.CurrentSongIndex = 0;
playlist.VoteFor(1);
Assert.Equal(1, playlist[1].Votes);
}
示例11: ChecksIndexBounds
public void ChecksIndexBounds()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(1));
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.VoteFor(-1));
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.VoteFor(2));
}
示例12: ValidatesArguments
public void ValidatesArguments()
{
Song[] songs = Helpers.SetupSongMocks(2);
var playlist = new Playlist("Playlist");
playlist.AddSongs(songs);
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.MoveSong(-1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.MoveSong(2, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.MoveSong(0, 2));
Assert.Throws<ArgumentOutOfRangeException>(() => playlist.MoveSong(0, -1));
}
示例13: CanIncrementIndex
public void CanIncrementIndex()
{
Song[] songs = Helpers.SetupSongMocks(3);
var playlist = new Playlist("Playlist");
playlist.AddSongs(songs);
playlist.MoveSong(0, 1);
Assert.Equal(songs[0], playlist[1].Song);
Assert.Equal(songs[1], playlist[0].Song);
Assert.Equal(songs[2], playlist[2].Song);
}
示例14: ShouldThrowArgumentNullExceptionIfArgumentIsNull
public void ShouldThrowArgumentNullExceptionIfArgumentIsNull()
{
var playlist = new Playlist("Playlist");
Assert.Throws<ArgumentNullException>(() => playlist.AddSongs(null));
}
示例15: IncreasesVoteCount
public void IncreasesVoteCount()
{
var playlist = new Playlist("Playlist");
playlist.AddSongs(Helpers.SetupSongMocks(1));
playlist.VoteFor(0);
Assert.Equal(1, playlist[0].Votes);
}