static Given() { WriteOutput.Initialise(); }
public virtual void UseCommandRuntime(ICommandRuntime2 commandRuntime) { //Logger.UseCommandRuntime(commandRuntime); Output = commandRuntime.WriteObject; ShouldProcess = commandRuntime.ShouldProcess; }
/// <summary> /// Write output to file. /// </summary> /// <param name="path">The file path to write.</param> /// <param name="defaultFile">The default file name to use when a directory is specified.</param> /// <param name="encoding">The file encoding to use.</param> /// <param name="o">The text to write.</param> protected static void WriteToFile(string path, string defaultFile, ShouldProcess shouldProcess, WriteOutput output, Encoding encoding, object o) { var rootedPath = PSRuleOption.GetRootedPath(path: path); if (!Path.HasExtension(rootedPath) || Directory.Exists(rootedPath)) { rootedPath = Path.Combine(rootedPath, defaultFile); } var parentPath = Directory.GetParent(rootedPath); if (!parentPath.Exists && shouldProcess(target: parentPath.FullName, action: PSRuleResources.ShouldCreatePath)) { Directory.CreateDirectory(path: parentPath.FullName); } if (shouldProcess(target: rootedPath, action: PSRuleResources.ShouldWriteFile)) { File.WriteAllText(path: rootedPath, contents: o.ToString(), encoding: encoding); var info = new FileInfo(rootedPath); output(info, false); } }
public JsonOutputWriter(WriteOutput output) : base(output) { _Result = new List <object>(); }
internal CsvOutputWriter(WriteOutput output) : base(output) { _Builder = new StringBuilder(); _Result = new List <InvokeResult>(); }
protected PipelineWriter(WriteOutput output) { _Output = output; }
internal PassThruWriter(WriteOutput output, bool wide) : base(output) { _Wide = wide; }
internal PowerShellWriter(WriteOutput output) : base(output) { }
internal JsonPipelineWriter(WriteOutput output) : base(output) { _Result = new List <object>(); }
public RawDataReporter(Func <byte[], CancellationToken, Task> sender, RingBuffer buffer, WriteOutput outputWriter, int flushSize, int maxFlushSize, TimeSpan maxSpinningTime) { this.buffer = buffer; this.flushSize = flushSize; this.maxFlushSize = maxFlushSize; this.maxSpinningTime = maxSpinningTime; this.outputWriter = entries => outputWriter(entries, writer); this.sender = sender; memoryStream = new MemoryStream(); writer = new BinaryWriter(memoryStream); stopReporterTokenSource = new CancellationTokenSource(); cancelReportingTokenSource = new CancellationTokenSource(); }
public RawDataReporter(Func <byte[], CancellationToken, Task> sender, RingBuffer buffer, WriteOutput outputWriter, int flushSize, TimeSpan maxSpinningTime) : this(sender, buffer, outputWriter, flushSize, MaxDefaultFlushSize, maxSpinningTime) { }
public void ValidTypeText(string TableName, string ColumnType, string TypeLength, string SaveAddress) { var Write = new WriteOutput("MSSQL"); if (ColumnType == "CHAR") { //char可以转换成 //已经确定是char,然后直接拿着表名alter 列名 类型长度就可以 string commtext = String.Format("\r\n alter table {0} \r\n alter column {1} {2}", TableName, ColumnType, TypeLength); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "VARCHAR") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1} {2}", TableName, ColumnType, TypeLength); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "NCAHR") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1} {2}", TableName, ColumnType, TypeLength); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "NVARCHAR") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1} {2}", TableName, ColumnType, TypeLength); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "DATE") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "DATETIME") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "VARBINARY") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1} {2}", TableName, ColumnType, TypeLength); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "IMAGE") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "TEXT") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "INT") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } else if (ColumnType == "DECIMAL") { string commtext = String.Format("\r\n alter table {0} \r\n alter column {1}}", TableName, ColumnType); Write.Write(commtext, "MSSql", SaveAddress); } }
private static string WriteTargetFile(string content, RelativeFilePath relativePath, IDirectoryAccessor targetDirectoryAccessor, PublishOptions publishOptions, WriteOutput writeOutput) { var fullyQualifiedPath = targetDirectoryAccessor.GetFullyQualifiedPath(relativePath); targetDirectoryAccessor.EnsureDirectoryExists(relativePath); var targetPath = fullyQualifiedPath.FullName; if (publishOptions.Format == PublishFormat.HTML) { targetPath = Path.ChangeExtension(targetPath, ".html"); } writeOutput(targetPath, content); return(targetPath); }
internal BooleanWriter(WriteOutput output, RuleOutcome outcome) : base(output) { _Outcome = outcome; }