public bool ParseFrom( string line )
{
char[] delims = { ' ', '\t' };
string[] token = line.Split( delims, StringSplitOptions.RemoveEmptyEntries );
if ( 0 == token.Length )
return false;
try
{
AVM1Actions action = (AVM1Actions)Enum.Parse( typeof( AVM1Actions ), token[ 0 ] );
_actionCode = ( byte )action;
}
catch ( ArgumentException )
{
return false;
}
//
// Sanity check
//
// It is possible that the parser instantiated a wrong ActionXXX Class. Make sure
// our Type equals the action determined.
//
if ( !this.GetType().ToString().EndsWith( token[ 0 ] ) )
{
throw new ArgumentException( "'" + line + "' passed into " + this.GetType().ToString() );
}
bool res = true;
if ( 0 != ( _actionCode & 0x80 ) )
{
//
// fancy ActionCode, let it do the argument parsing
//
try
{
string[] arguments = ParseFromTokenize( line );
res = ParseFrom( arguments );
//
// we now set the length, as its former meaning is gone
// after repopulating all class members through parsing
//
// Note: the -3 is because ActionLength* will add them (ACTIONRECORDHEADER)
_length = (ushort)( this.ActionLengthRendered - 3 );
//
// FIXME: we set the SwfVersion to an arbitrary value here
//
_SwfVersion = 10;
}
catch ( ArgumentException )
{
res = false;
}
catch ( FormatException )
{
res = false;
}
}
else
{
_length = 0;
}
return res;
}