|
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Tags.ID3
{
/// <summary>
/// Provide ID3 Information for a file
/// </summary>
public class ID3Info : ITagInfo
{
private ID3v1 _ID3v1;
private ID3v2 _ID3v2;
/// <summary>
/// Create new ID3 Info class
/// </summary>
/// <param name="FilePath">Path to read file</param>
/// <param name="LoadData">Indicate load data in constructor or not</param>
public ID3Info(string FilePath, bool LoadData)
{
_ID3v1 = new ID3v1(FilePath, LoadData);
_ID3v2 = new ID3v2(FilePath, LoadData);
}
/// <summary>
/// Get ID3 version 2 Tags
/// </summary>
public ID3v2 ID3v2Info
{
get
{ return _ID3v2; }
}
/// <summary>
/// Gets ID3 version Tag
/// </summary>
public ID3v1 ID3v1Info
{
get
{ return _ID3v1; }
}
/// <summary>
/// Load both ID3v1 and ID3v2 information from file
/// </summary>
public bool Load()
{
ID3v2Info.Load();
ID3v1Info.Load();
return true;
}
/// <summary>
/// Save both ID3v2 and ID3v1
/// </summary>
public bool Save()
{
ID3v2Info.Save();
ID3v1Info.Save();
return true;
}
/// <summary>
/// Return true if file had error while reading
/// </summary>
public bool HaveException
{
get { return ID3v2Info.HaveError; }
}
/// <summary>
/// Save both ID3v2 and ID3v1
/// </summary>
/// <param name="Formula">Formula to rename file while saving</param>
public bool Save(string Formula)
{
ID3v1Info.Save();
ID3v2Info.Save(Formula);
ID3v1Info.FilePath = ID3v2Info.FilePath;
return true;
}
/// <summary>
/// Save current ID3Info in specific location
/// </summary>
/// <param name="path">Path to save</param>
/// <returns>True if save successfull</returns>
public bool SaveAs(string path)
{
ID3v2Info.SaveAs(path);
ID3v1Info.FilePath = ID3v2Info.FilePath;
ID3v1Info.Save();
return true;
}
/// <summary>
/// Get filename according to specific formula
/// </summary>
/// <param name="Formula">Formula to make filename</param>
/// <returns>System.String Contains filename</returns>
public string MakeFileName(string Formula)
{
return ID3v2Info.MakeFileName(Formula);
}
/// <summary>
/// Get FilePath current ID3Info
/// </summary>
public string FilePath
{
get
{ return ID3v2Info.FilePath; }
}
/// <summary>
/// Get FileName of current ID3Info file
/// </summary>
public string FileName
{
get
{ return ID3v1Info.FileName; }
}
/// <summary>
/// Indicate if current ID3Info is ezual to specific one
/// </summary>
/// <param name="obj">Object to check equality</param>
/// <returns>True if equal otherwise false</returns>
public override bool Equals(object obj)
{
if (obj.GetType() != this.GetType())
return false;
if (this.FilePath == ((ID3Info)obj).FilePath)
return true;
else
return false;
}
/// <summary>
/// Get hash code for current ID3Info
/// </summary>
/// <returns>int contains hashcode</returns>
public override int GetHashCode()
{
return base.GetHashCode();
}
/// <summary>
/// Indicate if current ID3Info is template
/// </summary>
public bool IsTemplate
{
get
{ return _ID3v1.IsTemplate; }
set
{
_ID3v1.IsTemplate = value;
_ID3v2.IsTemplate = value;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.