private void Init(TagType tagType, List<KeyValuePair<string, string>> list, List<SongTag> playlist = null)
{
if (list == null) list = new List<KeyValuePair<string, string>>();
this.TagType = tagType;
this.SourceList = list;
this._isEmpty = (list.Count == 0) ? true : false;
bool convsuc = false;
int convi = 0;
foreach (var keyValuePair in list)
{
switch (keyValuePair.Key)
{
case "file":
this.file = keyValuePair.Value;
if (tagType == TagType.FileOrDirectory) this.TagType = TagType.File;
break;
case "directory":
this.directory = keyValuePair.Value;
if (tagType == TagType.FileOrDirectory) this.TagType = TagType.Directory;
break;
case "playlist":
this.playlist = keyValuePair.Value;
this.TagType = TagType.Playlist;
break;
case "Last-Modified":
this.LastModified = keyValuePair.Value;
break;
case "Time":
convsuc = int.TryParse(keyValuePair.Value, out convi);
this.Time = (convsuc) ? convi : 0;
break;
case "Artist":
this.Artist = keyValuePair.Value;
break;
case "Title":
this.Title = keyValuePair.Value;
break;
case "Album":
this.Album = keyValuePair.Value;
break;
case "Date":
this.Date = keyValuePair.Value;
break;
case "Genre":
this.Genre = keyValuePair.Value;
break;
case "Track":
this.Track = keyValuePair.Value;
break;
case "AlbumArtist":
this.AlbumArtist = keyValuePair.Value;
break;
case "Disc":
this.Disc = keyValuePair.Value;
break;
case "Name":
this.Name = keyValuePair.Value;
break;
case "Pos":
convsuc = int.TryParse(keyValuePair.Value, out convi);
this.Pos = (convsuc) ? convi : 0;
break;
case "Id":
convsuc = int.TryParse(keyValuePair.Value, out convi);
this.Id = (convsuc) ? convi : 0;
break;
case "Prio":
convsuc = int.TryParse(keyValuePair.Value, out convi);
this.Prio = (convsuc) ? convi : 0;
break;
default:
break;
}
}
if (playlist != null)
{
foreach (SongTag st in playlist)
{
if (st.file.Equals(this.file))
{
this.Pos = st.Pos;
this.Id = st.Id;
}
}
}
if (this.TagType == TagType.File && string.IsNullOrEmpty(this.Title))
{
string[] s = this.file.Split("/".ToCharArray());
if (s.Length > 0) this.Title = s.Last<string>();
}
}