public bool Verify()
{
//
// Make sure that the FileAttributes Tag is the first (if any)
//
uint fileAttributesCnt = 0;
// TODO : Check if TagHandlers not null
for (int i = 0; i < TagHandlers.Count; i++)
{
if (TagHandlers[i].Tag.TagType == TagTypes.FileAttributes)
{
if ((0 != i) && (this.Version < 8))
{
Log.Warn(this, "TAG FileAttributes not first in file, but at Tag #" + i.ToString());
}
fileAttributesCnt++;
}
}
if (fileAttributesCnt > 1)
{
string msg = "Multiple FileAttributes Tags: " + fileAttributesCnt.ToString();
if (!SwfFile.Configuration.AllowMultipleFileAttributes)
{
Log.Error(this, msg);
return false;
}
else
{
Log.Warn(this, msg);
}
}
//
// If the Swf version is 8 or higher, one FileAttributes Tag is required
//
if ((this.Version >= 8) && (fileAttributesCnt < 1))
{
if (SwfFile.Configuration.RequireFileAttributes)
{
String s = String.Format("Swf version {0:d} requires FileAttributes Tag, but none was found", this.Version);
Log.Error(this, s);
return false;
}
else
{
String s = String.Format("Swf version {0:d} requires FileAttributes Tag, but none was found - fixing it", this.Version);
Log.Warn(this, s);
this.FixFileAttributes();
}
}
//
// validate all Tags
//
bool result = true;
for (int i = 0; i < this.TagCount; i++)
{
result = result && this[i].Verify();
if (!result)
{
//
// Terminate verification when it failed one Tag
//
String s = String.Format("Tag #{0:d} {1} failed verification", i, this[i].Tag.TagTypeName);
Log.Info(this, s);
break;
}
}
// Fire VerficationCompleted event
if (null != VerificationCompleted)
{
VerificationCompleted();
}
return result;
}