本文整理汇总了C#中TagLib.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TagLib.Dispose方法的具体用法?C# TagLib.Dispose怎么用?C# TagLib.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagLib
的用法示例。
在下文中一共展示了TagLib.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateVideo
private Video CreateVideo(string filePath, int? folderId, TagLib.File file)
{
int? itemId = Injection.Kernel.Get<IItemRepository>().GenerateItemId(ItemType.Video);
if (itemId == null)
{
return new Video();
}
Video video = new Video();
video.ItemId = itemId;
video.FolderId = folderId;
video.FileType = video.FileType.FileTypeForTagLibMimeType(file.MimeType);
if (video.FileType == FileType.Unknown)
{
logger.IfInfo("\"" + filePath + "\" Unknown file type: " + file.Properties.Description);
}
video.Width = file.Properties.VideoWidth;
video.Height = file.Properties.VideoHeight;
video.Duration = Convert.ToInt32(file.Properties.Duration.TotalSeconds);
video.Bitrate = file.Properties.AudioBitrate;
// Get filesystem information about file
FileInfo fsFile = new FileInfo(filePath);
video.FileSize = fsFile.Length;
video.LastModified = fsFile.LastWriteTime.ToUnixTime();
video.FileName = fsFile.Name;
// Generate an art id from the embedded art, if it exists
int? artId = CreateArt(file).ArtId;
// Close file handles
fsFile = null;
file.Dispose();
// If there was no embedded art, use the folder's art
artId = (object)artId == null ? Injection.Kernel.Get<IArtRepository>().ArtIdForItemId(video.FolderId) : artId;
// Create the art/item relationship
Injection.Kernel.Get<IArtRepository>().UpdateArtItemRelationship(artId, video.ItemId, true);
return video;
}
示例2: CreateSong
//.........这里部分代码省略.........
}
try
{
song.TrackNumber = Convert.ToInt32(tag.Track);
}
catch
{
song.TrackNumber = null;
}
try
{
song.DiscNumber = Convert.ToInt32(tag.Disc);
}
catch
{
song.DiscNumber = null;
}
try
{
string firstGenre = tag.FirstGenre;
if (firstGenre != null)
{
song.GenreName = firstGenre.Trim();
}
}
catch
{
song.GenreName = null;
}
try
{
song.BeatsPerMinute = tag.BeatsPerMinute;
}
catch
{
song.BeatsPerMinute = null;
}
try
{
song.Lyrics = tag.Lyrics;
}
catch
{
song.Lyrics = null;
}
try
{
song.Comment = tag.Comment;
}
catch
{
song.Comment = null;
}
// Dispose tag
tag = null;
if ((object)song.GenreName != null)
{
// Retreive the genre id
song.GenreId = Injection.Kernel.Get<IGenreRepository>().GenreForName(song.GenreName).GenreId;
}
song.Duration = Convert.ToInt32(file.Properties.Duration.TotalSeconds);
song.Bitrate = file.Properties.AudioBitrate;
// Get necessary filesystem information about file
FileInfo fsFile = new FileInfo(filePath);
song.FileSize = fsFile.Length;
song.LastModified = fsFile.LastWriteTime.ToUnixTime();
song.FileName = fsFile.Name;
// If there is no song name, use the file name
if (song.SongName == null || song.SongName == "")
{
song.SongName = song.FileName;
}
// Generate an art id from the embedded art, if it exists
int? artId = CreateArt(file).ArtId;
// Dispose file handles
fsFile = null;
file.Dispose();
// If there was no embedded art, use the folder's art
artId = (object)artId == null ? Injection.Kernel.Get<IArtRepository>().ArtIdForItemId(song.FolderId) : artId;
// Create the art/item relationship
Injection.Kernel.Get<IArtRepository>().UpdateArtItemRelationship(artId, song.ItemId, true);
return song;
}
示例3: CreateArt
// used for getting art from a tag.
// We don't set the FilePath here, because that is only used for actual art files on disk
private Art CreateArt(TagLib.File file)
{
Art art = new Art();
if (file.Tag.Pictures.Length > 0)
{
byte[] data = file.Tag.Pictures[0].Data.Data;
art.Md5Hash = data.MD5();
art.FileSize = data.Length;
art.LastModified = System.IO.File.GetLastWriteTime(file.Name).ToUnixTime();
art.ArtId = Injection.Kernel.Get<IArtRepository>().ArtIdForMd5(art.Md5Hash);
if (art.ArtId == null)
{
// This art isn't in the database yet, so add it
art.ArtId = Injection.Kernel.Get<IItemRepository>().GenerateItemId(ItemType.Art);
Injection.Kernel.Get<IArtRepository>().InsertArt(art);
}
}
// Close file handle
file.Dispose();
return art;
}