public override string ToString()
{
try
{
// Does a toString method/property exist?
if (HasProperty("toString") == true)
{
// Call the toString() method.
var result = CallMemberFunction("toString");
// Make sure we don't recursively loop forever.
if (result == this)
return "<error>";
// Convert to a string.
return TypeConverter.ToString(result);
}
else
{
// Otherwise, return the type name.
var constructor = this["constructor"];
if (constructor is FunctionInstance)
return string.Format("[{0}]", ((FunctionInstance) constructor).Name);
return "<unknown>";
}
}
catch (JavaScriptException)
{
return "<error>";
}
}
void Xhr(ObjectInstance href, ObjectInstance type, FunctionInstance callback, FunctionInstance errorCallback) { var filename = href.ToString(); var referencingFile = currentFiles.Peek(); try { var file = referencingFile.Directory.GetFile(filename); var content = file.OpenRead().ReadToEnd(); callback.Call(Null.Value, content, DateTime.MinValue); } catch (FileNotFoundException ex) { throw FileNotFoundExceptionWithSourceFilename(referencingFile, ex); } catch (DirectoryNotFoundException ex) { throw DirectoryNotFoundExceptionWithSourceFilename(referencingFile, ex); } }