本文整理汇总了C#中ContentLanguagePreference类的典型用法代码示例。如果您正苦于以下问题:C# ContentLanguagePreference类的具体用法?C# ContentLanguagePreference怎么用?C# ContentLanguagePreference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentLanguagePreference类属于命名空间,在下文中一共展示了ContentLanguagePreference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ByPV
public ActionResult ByPV(PVService service, string pvId, ContentLanguagePreference? lang, string callback,
DataFormat format = DataFormat.Auto)
{
var song = Service.GetSongWithPV(s => new SongForApiContract(s, lang ?? ContentLanguagePreference.Default), service, pvId);
return Object(song, format, callback);
}
示例2: SongWithComponentsContract
public SongWithComponentsContract(Song song, ContentLanguagePreference languagePreference, bool includeArtists = false)
: base(song, languagePreference) {
if (includeArtists)
Artists = song.ArtistList.Select(a => new ArtistContract(a, languagePreference)).ToArray();
}
示例3: UnifiedCommentContract
public UnifiedCommentContract(Comment comment, ContentLanguagePreference languagePreference)
: base(comment)
{
Entry = new EntryRefWithNameContract(comment.Entry, languagePreference);
ArtistString = GetArtistString(comment.Entry, languagePreference);
SongThumbUrl = GetSongThumbUrl(comment.Entry);
}
示例4: GetName
public static EntryNameContract GetName(INameManager nameManager, ContentLanguagePreference languagePreference) {
var primary = nameManager.SortNames[languagePreference];
return new EntryNameContract(primary, GetAdditionalNames(nameManager.AllValues, primary));
}
示例5: AddOrder
public static IQueryable<Album> AddOrder(IQueryable<Album> criteria, AlbumSortRule sortRule, ContentLanguagePreference languagePreference) {
switch (sortRule) {
case AlbumSortRule.Name:
return FindHelpers.AddNameOrder(criteria, languagePreference);
case AlbumSortRule.ReleaseDate:
return AddReleaseRestriction(criteria)
.OrderByDescending(a => a.OriginalRelease.ReleaseDate.Year)
.ThenByDescending(a => a.OriginalRelease.ReleaseDate.Month)
.ThenByDescending(a => a.OriginalRelease.ReleaseDate.Day);
case AlbumSortRule.AdditionDate:
return criteria.OrderByDescending(a => a.CreateDate);
case AlbumSortRule.RatingAverage:
return criteria.OrderByDescending(a => a.RatingAverageInt)
.ThenByDescending(a => a.RatingCount);
case AlbumSortRule.NameThenReleaseDate:
return FindHelpers.AddNameOrder(criteria, languagePreference)
.ThenBy(a => a.OriginalRelease.ReleaseDate.Year)
.ThenBy(a => a.OriginalRelease.ReleaseDate.Month)
.ThenBy(a => a.OriginalRelease.ReleaseDate.Day);
}
return criteria;
}
示例6: AlbumWithArchivedVersionsContract
public AlbumWithArchivedVersionsContract(Album album, ContentLanguagePreference languagePreference)
: base(album, languagePreference)
{
ParamIs.NotNull(() => album);
ArchivedVersions = album.ArchivedVersionsManager.Versions.Select(a => new ArchivedAlbumVersionContract(a)).ToArray();
}
示例7: EntryForApiContract
public EntryForApiContract(Album album, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, bool ssl,
EntryOptionalFields includedFields)
: this(album, languagePreference) {
ArtistString = album.ArtistString[languagePreference];
CreateDate = album.CreateDate;
DiscType = album.DiscType;
Status = album.Status;
if (includedFields.HasFlag(EntryOptionalFields.MainPicture) && album.CoverPictureData != null) {
MainPicture = new EntryThumbForApiContract(new EntryThumb(album, album.CoverPictureMime), thumbPersister, ssl);
}
if (includedFields.HasFlag(EntryOptionalFields.Names)) {
Names = album.Names.Select(n => new LocalizedStringContract(n)).ToArray();
}
if (includedFields.HasFlag(EntryOptionalFields.Tags)) {
Tags = album.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray();
}
if (includedFields.HasFlag(EntryOptionalFields.WebLinks)) {
WebLinks = album.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray();
}
}
示例8: SongInListForApiContract
public SongInListForApiContract(SongInList songInList, ContentLanguagePreference languagePreference, SongOptionalFields fields) {
this.Notes = songInList.Notes;
this.Order = songInList.Order;
this.Song = new SongForApiContract(songInList.Song, null, languagePreference, fields);
}
示例9: OrderBy
public static IQueryable<AlbumForUser> OrderBy(this IQueryable<AlbumForUser> query, AlbumSortRule sortRule, ContentLanguagePreference languagePreference) {
switch (sortRule) {
case AlbumSortRule.Name:
return AddNameOrder(query, languagePreference);
case AlbumSortRule.CollectionCount:
return query.OrderByDescending(a => a.Album.UserCollections.Count);
case AlbumSortRule.ReleaseDate:
return query
.WhereHasReleaseDate()
.OrderByReleaseDate();
case AlbumSortRule.ReleaseDateWithNulls:
return query.OrderByReleaseDate();
case AlbumSortRule.AdditionDate:
return query.OrderByDescending(a => a.Album.CreateDate);
case AlbumSortRule.RatingAverage:
return query.OrderByDescending(a => a.Album.RatingAverageInt)
.ThenByDescending(a => a.Album.RatingCount);
case AlbumSortRule.RatingTotal:
return query.OrderByDescending(a => a.Album.RatingTotal)
.ThenByDescending(a => a.Album.RatingAverageInt);
case AlbumSortRule.NameThenReleaseDate:
return AddNameOrder(query, languagePreference)
.ThenBy(a => a.Album.OriginalRelease.ReleaseDate.Year)
.ThenBy(a => a.Album.OriginalRelease.ReleaseDate.Month)
.ThenBy(a => a.Album.OriginalRelease.ReleaseDate.Day);
}
return query;
}
示例10: ReleaseEventSeriesWithEventsContract
public ReleaseEventSeriesWithEventsContract(ReleaseEventSeries series, IEnumerable<ReleaseEvent> events, ContentLanguagePreference languagePreference)
: base(series)
{
ParamIs.NotNull(() => events);
Events = events.OrderBy(e => e.SeriesNumber).Select(e => new ReleaseEventContract(e)).ToArray();
}
示例11: EntryRefWithCommonPropertiesContract
public EntryRefWithCommonPropertiesContract(Song entry, ContentLanguagePreference languagePreference)
: base(entry, languagePreference) {
ArtistString = entry.ArtistString[languagePreference];
EntryTypeName = SongTypeNames.ResourceManager.GetString(entry.SongType.ToString());
}
示例12: SongDetailsContract
public SongDetailsContract(Song song, ContentLanguagePreference languagePreference) {
Song = new SongContract(song, languagePreference);
AdditionalNames = string.Join(", ", song.AllNames.Where(n => n != Song.Name).Distinct());
Albums = song.Albums.Select(a => new AlbumContract(a.Album, languagePreference)).Distinct().OrderBy(a => a.Name).ToArray();
AlternateVersions = song.AlternateVersions.Select(s => new SongContract(s, languagePreference)).ToArray();
Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).OrderBy(a => a.Name).ToArray();
ArtistString = song.ArtistString[languagePreference];
CreateDate = song.CreateDate;
Deleted = song.Deleted;
LikeCount = song.UserFavorites.Count(f => f.Rating == SongVoteRating.Like);
LyricsFromParents = song.LyricsFromParents.Select(l => new LyricsForSongContract(l)).ToArray();
Notes = song.Notes;
OriginalVersion = (song.OriginalVersion != null && !song.OriginalVersion.Deleted ? new SongContract(song.OriginalVersion, languagePreference) : null);
// TODO (PERF): this might be handled through a special query if the list is long
Pools =
song.ListLinks
.Where(l => l.List.FeaturedCategory == SongListFeaturedCategory.Pools)
.OrderBy(l => l.List.Name).Take(3)
.Select(l => new SongListBaseContract(l.List))
.ToArray();
ListCount = song.ListLinks.Count;
PVs = song.PVs.Select(p => new PVContract(p)).ToArray();
Tags = song.Tags.Usages.Select(u => new TagUsageContract(u)).OrderByDescending(t => t.Count).ToArray();
TranslatedName = new TranslatedStringContract(song.TranslatedName);
WebLinks = song.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();
}
示例13: ArtistWithArchivedVersionsContract
public ArtistWithArchivedVersionsContract(Artist artist, ContentLanguagePreference languagePreference)
: base(artist, languagePreference)
{
ParamIs.NotNull(() => artist);
ArchivedVersions = artist.ArchivedVersionsManager.Versions.Select(a => new ArchivedArtistVersionContract(a)).ToArray();
}
示例14: AlbumForArtistEditContract
public AlbumForArtistEditContract(ArtistForAlbum artistForAlbum, ContentLanguagePreference languagePreference)
{
AlbumId = artistForAlbum.Album.Id;
AlbumName = artistForAlbum.Album.TranslatedName[languagePreference];
AlbumAdditionalNames = string.Join(", ", artistForAlbum.Album.AllNames.Where(n => n != AlbumName));
ArtistForAlbumId = artistForAlbum.Id;
}
示例15: AlbumForApiContract
public AlbumForApiContract(
Album album, AlbumMergeRecord mergeRecord,
ContentLanguagePreference languagePreference,
IEntryThumbPersister thumbPersister,
bool ssl,
AlbumOptionalFields fields) : this(album, mergeRecord, languagePreference,
fields.HasFlag(AlbumOptionalFields.Artists),
fields.HasFlag(AlbumOptionalFields.Names),
fields.HasFlag(AlbumOptionalFields.PVs),
fields.HasFlag(AlbumOptionalFields.Tags),
fields.HasFlag(AlbumOptionalFields.WebLinks)) {
if (languagePreference != ContentLanguagePreference.Default || fields.HasFlag(AlbumOptionalFields.AdditionalNames)) {
AdditionalNames = album.Names.GetAdditionalNamesStringForLanguage(languagePreference);
}
if (fields.HasFlag(AlbumOptionalFields.Identifiers)) {
Identifiers = album.Identifiers.Select(i => new AlbumIdentifierContract(i)).ToArray();
}
if (thumbPersister != null && fields.HasFlag(AlbumOptionalFields.MainPicture) && !string.IsNullOrEmpty(album.CoverPictureMime)) {
MainPicture = new EntryThumbForApiContract(new EntryThumb(album, album.CoverPictureMime), thumbPersister, ssl);
}
}