private XmlWriter CreateResultDocument([NotNull] XdmWriterSettings settings, [NotNull] FileInfo fileInfo) { Assert.ArgumentNotNull(settings, "settings"); Assert.ArgumentNotNull(fileInfo, "fileInfo"); _task.Log.LogMessage(MessageImportance.Low, Resources.CreateResultDocument, fileInfo.FullName); var taskItem = new TaskItem(fileInfo.FullName); var directory = fileInfo.Directory; if (directory != null && directory.Exists == false) { directory.Create(); } var localPath = fileInfo.FullName; var stream = GetTemporaryFile(localPath); var name = stream.Name; taskItem.SetMetadata("MimeType", settings.MediaType ?? string.Empty); taskItem.SetMetadata("Encoding", settings.Encoding); // Record that, on failure, we must delete the newly created file. _log.Add(UndoCreateAction(name, stream)); // Record that, on completion, we need to move the temporary file to the actual file. _onComplete.Add(ReplaceAction(name, localPath, taskItem)); return(XdmWriter.Create(stream, settings)); }
private void Explain([NotNull] XQuery query) { Assert.ArgumentNotNull(query, "query"); Assert.IsNotNull(Plan, "Plan"); var settings = new XdmWriterSettings { Indent = true }; var stream = File.OpenWrite(Plan.GetMetadata("FullPath")); using (var xdmWriter = XdmWriter.Create(stream, settings)) query.Explain(xdmWriter); }
private void Explain([NotNull] Xslt transform) { Assert.ArgumentNotNull(transform, "transform"); Assert.IsNotNull(Plan, "Plan"); var settings = new XdmWriterSettings { Indent = true }; var stream = File.OpenWrite(Plan.GetMetadata("FullPath")); using (var xdmWriter = XdmWriter.Create(stream, settings)) transform.Explain(xdmWriter); }