TvDatabase.TvBusinessLayer.GetMpGenres C# (CSharp) Method

GetMpGenres() public method

Returns a list of MediaPortal genres.
public GetMpGenres ( ) : List
return List
    public List<MpGenre> GetMpGenres()
    {
      string genre;
      bool enabled;
      List<MpGenre> mpGenres = new List<MpGenre>();
      List<string> mappedProgramGenres;
      List<string> defaultGenreNames = (List<string>)GetDefaultMpGenreNames();

      // Get the id of the mp genre identified as the movie genre.
      int genreMapMovieGenreId;
      if (!int.TryParse(GetSetting("genreMapMovieGenreId", "-1").Value, out genreMapMovieGenreId))
      {
        genreMapMovieGenreId = -1;
      }

      // Each genre map value is a '{' delimited list of "program" genre names (those that may be compared with the genre from the program listings).
      // It is an error if a single "program" genre is mapped to more than one guide genre; behavior is undefined for this condition.
      for (int i = 0; i < defaultGenreNames.Count; i++)
      {
        // The genremap key is an integer value that is added to a base value in order to locate the correct localized genre name string.
        genre = GetSetting("genreMapName" + i, defaultGenreNames[i]).Value;

        // Get the status of the mp genre.
        if (!bool.TryParse(GetSetting("genreMapNameEnabled" + i, "True").Value, out enabled))
        {
          enabled = true;
        }

        // Create a mp genre object.
        MpGenre mpg = new MpGenre(genre, i);
        mpg.IsMovie = (i == genreMapMovieGenreId);
        mpg.Enabled = enabled;

        string genreMapEntry = GetSetting("genreMapEntry" + i, "").Value;
        mappedProgramGenres = new List<string>(genreMapEntry.Split(new char[] { '{' }, StringSplitOptions.RemoveEmptyEntries));

        foreach (string programGenre in mappedProgramGenres)
        {
          mpg.MapToProgramGenre(programGenre);
        }

        mpGenres.Add((MpGenre)mpg);
      }

      return mpGenres;
    }

Usage Example

示例#1
0
    public override void LoadSettings()
    {
      base.LoadSettings();
      TvBusinessLayer layer = new TvBusinessLayer();

      // Load the list of all EPG provided program genres.
      _allProgramGenres = (List<string>)layer.GetProgramGenres();

      // Load the list of MP genres.
      _mpGenres = layer.GetMpGenres();

      // Populate the guide genre and program genre lists.
      PopulateGuideGenreList();
      PopulateProgramGenreList();
    }
TvBusinessLayer