本文整理汇总了C#中Title.RemoveGenre方法的典型用法代码示例。如果您正苦于以下问题:C# Title.RemoveGenre方法的具体用法?C# Title.RemoveGenre怎么用?C# Title.RemoveGenre使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title.RemoveGenre方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyGenreMappings
private void ApplyGenreMappings(Title title, bool removeUnknownGenres)
{
List<String> genreList = new List<String>();
int genreCount = TitleCollectionManager.GetAllGenreMetaDatas().Count();
if (genreCount > 0)
{
genreList.AddRange(from gm in TitleCollectionManager.GetAllGenreMetaDatas()
select gm.Name);
Dictionary<string, string> genreIssuesList = new Dictionary<string, string>();
Dictionary<string, string> genreChanges = new Dictionary<string, string>();
foreach (string genre in title.Genres)
{
string newGenre = genre.Trim();
if (!genreList.Contains(newGenre))
{
// Genre doesn't exists
if (OMLEngine.Settings.SettingsManager.GenreMap_GetMapping(newGenre) != null)
{
// Mapping already exists for genre
genreChanges[genre] = OMLEngine.Settings.SettingsManager.GenreMap_GetMapping(newGenre);
}
else
{
// Mapping doesn't exists for genre, try trimming off 'film' from the end just incase
if (newGenre.EndsWith("Film", true, CultureInfo.InvariantCulture))
newGenre = newGenre.Replace(" Film", "");
if (genreList.Contains(newGenre))
genreIssuesList[genre] = newGenre;
else
{
string match = genreList.FirstOrDefault(s => s.Split(' ').Intersect(newGenre.Split(' ')).Count() != 0);
genreIssuesList[genre] = match;
}
}
}
}
foreach (string genre in genreChanges.Keys)
{
title.RemoveGenre(genre);
// Mapping contains empty string when user wants a specific genre ignored.
if (!String.IsNullOrEmpty(genreChanges[genre]) && !title.Genres.Contains(genreChanges[genre]))
title.AddGenre(genreChanges[genre]);
}
if (genreIssuesList.Keys.Count > 0)
{
if (!removeUnknownGenres)
{
foreach (string genre in genreIssuesList.Keys)
{
if (title.Genres.Contains(genre))
title.RemoveGenre(genre);
}
}
}
}
}