private void ExecuteWrite(XmlElement element, MagickImage image)
{
string fileName = element.GetAttribute("fileName");
if (!string.IsNullOrEmpty(fileName))
{
image.Write(fileName);
}
else
{
if (Write == null)
throw new InvalidOperationException("The Write event should be bound when the fileName attribute is not set.");
string id = element.GetAttribute("id");
ScriptWriteEventArgs eventArgs = new ScriptWriteEventArgs(id, image);
Write(this, eventArgs);
}
}