public IDictionary<object, object> AsDictionary()
{
var resultDictionary = new Dictionary<object, object>();
if (IsMultiAnnounce)
{
List<object> list = AnnounceList.Select(anList => anList.Cast<object>().ToList())
.Cast<object>()
.ToList();
resultDictionary.Add(MultiAnnounceKey, list);
}
else
{
resultDictionary.Add(AnnounceKey, Announce);
}
if (HasCreationDate)
{
TimeSpan t = CreationDate - EpochDateTime;
resultDictionary.Add(CreationDateKey, (long) t.TotalSeconds);
}
if (HasComment)
{
resultDictionary.Add(CommentKey, Comment);
}
if (HasCreatedBy)
{
resultDictionary.Add(CreatedByKey, CreatedBy);
}
var infoDictionary = new Dictionary<object, object>();
if (IsMultiFile)
{
List<object> fileList = Files.Select(file => file.ToDictionary())
.Cast<object>()
.ToList();
infoDictionary.Add(FilesKey, fileList);
infoDictionary.Add(DirNameKey, DirectoryName);
}
else
{
infoDictionary.Add(FileSizeKey, FileSize);
infoDictionary.Add(FileNameKey, FileName);
}
infoDictionary.Add(PieceLengthKey, PieceSize);
infoDictionary.Add(PiecesKey, Pieces);
infoDictionary.Add(PrivateKey, (IsPrivate ? 1L : 0L));
resultDictionary.Add(InfoDictionaryKey, infoDictionary);
return resultDictionary;
}