예제 #1
0
 public Catalog_Item(Attributes.Artist[] artist, Attributes.Title title, Attributes.Album album, Attributes.Genre[] genre, Attributes.Duration duration, Attributes.HoldingFile file)
 {
     this.Title = title;
     this.Album = album;
     if (artist != null && artist.Length > 0)
     {
         this.MainArtist = artist[0];
         if (artist.Length > 1)
         {
             Attributes.Artist[] tmp = new Attributes.Artist[artist.Length - 1];
             for (int i = 1; i < artist.Length; i++)
             {
                 tmp[i - 1] = artist[i];
             }
             this.featArtists = tmp;
         }
         else
         {
             this.featArtists = new Attributes.Artist[] { }
         };
     }
     if (genre != null)
     {
         if (genre.Length > 0)
         {
             Attributes.Genre[] tmp = new Attributes.Genre[genre.Length];
             for (int i = 0; i < genre.Length; i++)
             {
                 tmp[i] = genre[i];
             }
             this.genres = tmp;
         }
     }
     else
     {
         this.genres = new Attributes.Genre[] { }
     };
     this.File     = file;
     this.Duration = duration;
 }
예제 #2
0
        private Catalog_Item Create_Item(Wrapper arg)
        {
            #region Ini
            Attributes.HoldingFile arg_file;
            Attributes.Duration    arg_duration;
            Attributes.Album       arg_album;
            Attributes.Title       arg_title;
            Attributes.Artist[]    arg_artist;
            Attributes.Genre[]     arg_genre;
            #endregion
            #region Unique
            if (arg.File != null)
            {
                arg_file = new Attributes.HoldingFile(arg.File);
            }
            else
            {
                arg_file = null;
            }
            if (arg.Duration != null)
            {
                arg_duration = new Attributes.Duration(arg.Duration);
            }
            else
            {
                arg_duration = null;
            }
            if (arg.Title != null)
            {
                arg_title = new Attributes.Title(arg.Title);
            }
            else
            {
                arg_title = null;
            }
            #endregion
            #region Lists elements
            if (arg.Album != null)
            {
                arg.Album = arg.Album.Trim();
                if (albumsList == null)
                {
                    albumsList = new List <Attributes.Album>();
                }
                int indx = albumsList.FindIndex(x => x.GetValue().ToLower() == arg.Album.ToLower());
                if (indx >= 0)
                {
                    arg_album = albumsList[indx];
                }
                else
                {
                    Attributes.Album temp = new Attributes.Album(arg.Album);
                    albumsList.Add(temp);
                    arg_album = temp;
                }
            }
            else
            {
                arg_album = null;
            }

            if (arg.Artist != null)
            {
                if (artistsList == null)
                {
                    artistsList = new List <Attributes.Artist>();
                }
                arg_artist = new Attributes.Artist[arg.Artist.Length];
                for (int i = 0; i < arg.Artist.Length; i++)
                {
                    int indx = artistsList.FindIndex(x => x.GetValue().ToLower() == arg.Artist[i].ToLower().Trim());
                    if (indx >= 0)
                    {
                        arg_artist[i] = artistsList[indx];
                    }
                    else
                    {
                        Attributes.Artist temp = new Attributes.Artist(arg.Artist[i].Trim());
                        artistsList.Add(temp);
                        arg_artist[i] = temp;
                    }
                }
            }
            else
            {
                arg_artist = null;
            }

            if (arg.Genre != null)
            {
                if (genresList == null)
                {
                    genresList = new List <Attributes.Genre>();
                }
                arg_genre = new Attributes.Genre[arg.Genre.Length];
                for (int i = 0; i < arg.Genre.Length; i++)
                {
                    int indx = genresList.FindIndex(x => x.GetValue().ToLower() == arg.Genre[i].ToLower().Trim());
                    if (indx >= 0)
                    {
                        arg_genre[i] = genresList[indx];
                    }
                    else
                    {
                        Attributes.Genre temp = new Attributes.Genre(arg.Genre[i].Trim());
                        genresList.Add(temp);
                        arg_genre[i] = temp;
                    }
                }
            }
            else
            {
                arg_genre = null;
            }
            #endregion
            return(new Catalog_Item(arg_artist, arg_title, arg_album, arg_genre, arg_duration, arg_file));
        }
예제 #3
0
        public void ReadXml(XmlReader reader)
        {
            int i = 0, k = 0;

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "Title")
                    {
                        this.Title = new Attributes.Title(reader.ReadElementContentAsString());
                    }
                    if (reader.Name == "Duration")
                    {
                        this.Duration = new Attributes.Duration(reader.ReadElementContentAsString());
                    }
                    if (reader.Name == "Album")
                    {
                        this.Album = new Attributes.Album(reader.ReadElementContentAsString());
                    }
                    if (reader.Name == "File")
                    {
                        this.File = new Attributes.HoldingFile(reader.ReadElementContentAsString());
                    }
                    if (reader.Name == "Artist")
                    {
                        if (i < 1)
                        {
                            this.MainArtist = new Attributes.Artist(reader.ReadElementContentAsString());
                            i++;
                        }
                        else
                        {
                            Attributes.Artist[] tmp = new Attributes.Artist[i];
                            for (int j = 0; j < i - 1; j++)
                            {
                                tmp[j] = FeatArtist[j];
                            }
                            tmp[i - 1] = new Attributes.Artist(reader.ReadElementContentAsString());
                            FeatArtist = tmp;
                            i++;
                        }
                    }
                    if (reader.Name == "Genre")
                    {
                        Attributes.Genre[] tmp = new Attributes.Genre[k + 1];
                        for (int j = 0; j < k; j++)
                        {
                            tmp[j] = Genres[j];
                        }
                        tmp[k] = new Attributes.Genre(reader.ReadElementContentAsString());
                        Genres = tmp;
                        k++;
                    }
                }
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "Item")
                {
                    break;
                }
            }
        }