Here are the examples of the csharp api System.IO.TextWriter.WriteAsync(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
44 Examples
19
Source : Output.cs
with Apache License 2.0
from adamralph
with Apache License 2.0
from adamralph
public async Task Header(Func<string> getVersion)
{
if (!this.Verbose)
{
return;
}
var version = getVersion();
var builder = new StringBuilder()
.AppendLine(Format($"{this.palette.Verbose}{version}{this.palette.Reset}", "Bullseye version", this.prefix, this.palette))
.AppendLine(Format($"{this.palette.Verbose}{this.host} ({(this.hostForced ? "forced" : "detected")}){this.palette.Reset}", "Host", this.prefix, this.palette))
.AppendLine(Format($"{this.palette.Verbose}{this.operatingSystem}{this.palette.Reset}", "OS", this.prefix, this.palette))
.AppendLine(Format($"{this.palette.Verbose}{string.Join(" ", this.args)}{this.palette.Reset}", "Args", this.prefix, this.palette));
await this.writer.WriteAsync(builder.ToString()).Tax();
}
19
Source : Output.cs
with Apache License 2.0
from adamralph
with Apache License 2.0
from adamralph
public Task List(TargetCollection targets, IEnumerable<string> rootTargets, int maxDepth, int maxDepthToShowInputs, bool listInputs) =>
this.writer.WriteAsync(GetListLines(targets, rootTargets, maxDepth, maxDepthToShowInputs, listInputs, "", this.palette));
19
Source : DualWriter.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
public override Task WriteAsync(string value)
{
InternalWrite(value);
return Writer2.WriteAsync(value);
}
19
Source : DocumentWriter.cs
with MIT License
from ChilliCream
with MIT License
from ChilliCream
public Task WriteIndentationAsync()
{
if (Indentation > 0)
{
return WriteAsync(new string(_space, Indentation * _indent));
}
return Task.CompletedTask;
}
19
Source : XSharpPublishProvider.cs
with BSD 3-Clause "New" or "Revised" License
from CosmosOS
with BSD 3-Clause "New" or "Revised" License
from CosmosOS
public async Task PublishAsync(CancellationToken aCancellationToken, TextWriter aOutputPaneWriter)
{
var xProjectProperties = await ProjectProperties.GetConfigurationGeneralPropertiesAsync().ConfigureAwait(false);
var xOutputType = await xProjectProperties.OutputType.GetEvaluatedValueAtEndAsync().ConfigureAwait(false);
var xOutputISO = await xProjectProperties.OutputISO.GetEvaluatedValueAtEndAsync().ConfigureAwait(false);
xOutputISO = ConfiguredProject.UnconfiguredProject.MakeRooted(xOutputISO);
if (String.Equals(xOutputType, OutputTypeValues.Bootable, StringComparison.OrdinalIgnoreCase))
{
if (mPublishSettings == null)
{
await aOutputPaneWriter.WriteAsync("Publish settings are null!").ConfigureAwait(false);
return;
}
switch (mPublishSettings.PublishType)
{
case PublishType.ISO:
await aOutputPaneWriter.WriteLineAsync("Publishing ISO!").ConfigureAwait(false);
if (String.IsNullOrWhiteSpace(mPublishSettings.PublishPath))
{
throw new Exception($"Invalid publish path! Publish path: '{mPublishSettings.PublishPath}'");
}
File.Copy(xOutputISO, mPublishSettings.PublishPath, true);
break;
case PublishType.USB:
await aOutputPaneWriter.WriteLineAsync("Publishing USB!").ConfigureAwait(false);
DriveInfo xDriveInfo;
try
{
xDriveInfo = new DriveInfo(mPublishSettings.PublishPath);
}
catch (ArgumentException)
{
throw new Exception($"Invalid drive letter! Drive letter: '{mPublishSettings.PublishPath}'");
}
// todo: format USB drive if requested? how?
var xDrivePath = xDriveInfo.RootDirectory.FullName;
using (var xStream = File.OpenRead(xOutputISO))
{
using (var xReader = new CDReader(xStream, true))
{
foreach (var xFile in xReader.GetFiles(""))
{
using (var xFileStream = xReader.OpenFile(xFile, FileMode.Open))
{
using (var xNewFile = File.Create(Path.Combine(xDrivePath, Path.GetFileName(xFile))))
{
await xFileStream.CopyToAsync(xNewFile).ConfigureAwait(false);
}
}
}
}
}
break;
default:
await aOutputPaneWriter.WriteLineAsync(
$"Unknown publish type! Publish type: '{mPublishSettings.PublishType}'").ConfigureAwait(false);
break;
}
}
else
{
await ConfiguredProject.Services.Build.BuildAsync(
ImmutableArray.Create("Publish"), CancellationToken.None, true).ConfigureAwait(false);
}
await aOutputPaneWriter.WriteLineAsync("Publish successful!").ConfigureAwait(false);
}
19
Source : ByLineTextMessageWriter.cs
with Apache License 2.0
from CXuesong
with Apache License 2.0
from CXuesong
public override async Task WriteAsync(Message message, CancellationToken cancellationToken)
{
if (message == null) throw new ArgumentNullException(nameof(message));
if (DisposalToken.IsCancellationRequested)
throw new ObjectDisposedException(nameof(ByLineTextMessageWriter));
cancellationToken.ThrowIfCancellationRequested();
var linkedToken = DisposalToken;
CancellationTokenSource linkedTokenSource = null;
if (cancellationToken.CanBeCanceled)
{
linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, DisposalToken);
linkedToken = linkedTokenSource.Token;
}
var content = message.ToString();
await writerSemapreplaced.WaitAsync(linkedToken);
try
{
#if BCL_FEATURE_READER_WRITER_CANCEL
await Writer.WriteAsync(content.AsMemory(), linkedToken);
await Writer.WriteAsync(Delimiter.AsMemory(), linkedToken);
#else
await Writer.WriteAsync(content);
linkedToken.ThrowIfCancellationRequested();
await Writer.WriteAsync(Delimiter);
#endif
linkedToken.ThrowIfCancellationRequested();
await Writer.FlushAsync();
}
catch (ObjectDisposedException)
{
// Throws OperationCanceledException if the cancellation has already been requested.
linkedToken.ThrowIfCancellationRequested();
throw;
}
finally
{
linkedTokenSource?.Dispose();
// Note: when DisposalToken cancels, this part of code might execute concurrently with Dispose().
// We might receive ObjectDisposedException if we are taking longer time than expected (>1s) to reach here.
writerSemapreplaced.Release();
}
}
19
Source : Logic.cs
with MIT License
from ExRam
with MIT License
from ExRam
private async Task Create_the_graph()
{
// Create a graph very similar to the one
// found at http://tinkerpop.apache.org/docs/current/reference/#graph-computing.
await _writer.WriteAsync("Clearing the database...");
await _g
.V()
.Drop();
await _writer.WriteAsync("creating a new database...");
_marko = await _g
.AddV(new Person { Name = "Marko", Age = 29 })
.FirstAsync();
_vadas = await _g
.AddV(new Person { Name = "Vadas", Age = 27 })
.FirstAsync();
_josh = await _g
.AddV(new Person { Name = "Josh", Age = 32 })
.FirstAsync();
_peter = await _g
.AddV(new Person { Name = "Peter", Age = 35 })
.FirstAsync();
_daniel = await _g
.AddV(new Person
{
Name = "Daniel",
Age = 37,
PhoneNumbers = new[]
{
"+491234567",
"+492345678"
}
})
.FirstAsync();
var charlie = await _g
.AddV(new Dog { Name = "Charlie", Age = 2 })
.FirstAsync();
var catmanJohn = await _g
.AddV(new Cat { Name = "Catman John", Age = 5 })
.FirstAsync();
var luna = await _g
.AddV(new Cat { Name = "Luna", Age = 9 })
.FirstAsync();
var lop = await _g
.AddV(new Software { Name = "Lop", Language = ProgrammingLanguage.Java })
.FirstAsync();
var ripple = await _g
.AddV(new Software { Name = "Ripple", Language = ProgrammingLanguage.Java })
.FirstAsync();
await _g
.V(_marko.Id!)
.AddE<Knows>()
.To(__ => __
.V(_vadas.Id!))
.FirstAsync();
await _g
.V(_marko.Id!)
.AddE<Knows>()
.To(__ => __
.V(_josh.Id!))
.FirstAsync();
await _g
.V(_marko.Id!)
.AddE<Created>()
.To(__ => __
.V(lop.Id!))
.FirstAsync();
await _g
.V(_josh.Id!)
.AddE<Created>()
.To(__ => __
.V(ripple.Id!))
.FirstAsync();
// Creates multiple edges in a single query
// Note that query ends with ToArrayAsync
await _g
.V(_josh.Id!, _peter.Id!)
.AddE<Created>()
.To(__ => __
.V(lop.Id!))
.ToArrayAsync();
await _g
.V(_josh.Id!)
.AddE<Owns>()
.To(__ => __
.V(charlie.Id!))
.FirstAsync();
await _g
.V(_josh.Id!)
.AddE<Owns>()
.To(__ => __
.V(luna.Id!))
.FirstAsync();
await _g
.V(_daniel.Id!)
.AddE<Owns>()
.To(__ => __
.V(catmanJohn.Id!))
.FirstAsync();
await _writer.WriteLineAsync("done.");
await _writer.WriteLineAsync();
}
19
Source : ViewBuffer.cs
with GNU General Public License v3.0
from grandnode
with GNU General Public License v3.0
from grandnode
public async Task WriteToAsync(TextWriter writer, HtmlEncoder encoder)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
if (encoder == null)
{
throw new ArgumentNullException(nameof(encoder));
}
for (var i = 0; i < Count; i++)
{
var page = this[i];
for (var j = 0; j < page.Count; j++)
{
var value = page.Buffer[j];
if (value.Value is string valuereplacedtring)
{
await writer.WriteAsync(valuereplacedtring);
continue;
}
if (value.Value is ViewBuffer valueAsViewBuffer)
{
await valueAsViewBuffer.WriteToAsync(writer, encoder);
continue;
}
if (value.Value is IHtmlContent valueAsHtmlContent)
{
valueAsHtmlContent.WriteTo(writer, encoder);
await writer.FlushAsync();
continue;
}
}
}
}
19
Source : ViewBufferTextWriter.cs
with GNU General Public License v3.0
from grandnode
with GNU General Public License v3.0
from grandnode
public override Task WriteAsync(string value)
{
if (IsBuffering)
{
Buffer.AppendHtml(value);
return Task.CompletedTask;
}
else
{
return _inner.WriteAsync(value);
}
}
19
Source : 9.cs
with MIT License
from hanabi1224
with MIT License
from hanabi1224
public static unsafe void Main(string[] args)
{
var size = args.Length == 0 ? 200 : int.Parse(args[0]);
// Ensure image_Width_And_Height are multiples of 8.
size = (size + 7) / 8 * 8;
Console.Out.WriteAsync(String.Concat("P4\n", size, " ", size, "\n"));
var Crb = new double[size + 2];
var lineLength = size >> 3;
var data = new byte[size * lineLength];
fixed (double* pCrb = &Crb[0])
fixed (byte* pdata = &data[0])
{
var value = new Vector<double>(
new double[] { 0, 1, 0, 0, 0, 0, 0, 0 }
);
var invN = new Vector<double>(2.0 / size);
var onePtFive = new Vector<double>(1.5);
var step = new Vector<double>(2);
for (var i = 0; i < size; i += 2)
{
Unsafe.Write(pCrb + i, value * invN - onePtFive);
value += step;
}
var _Crb = pCrb;
var _pdata = pdata;
Parallel.For(0, size, y =>
{
var Ciby = _Crb[y] + 0.5;
for (var x = 0; x < lineLength; x++)
{
_pdata[y * lineLength + x] = GetByte(_Crb + x * 8, Ciby);
}
});
using var hasher = MD5.Create();
var hash = hasher.ComputeHash(data);
Console.WriteLine(ToHexString(hash));
}
}
19
Source : Literal.cs
with MIT License
from hishamco
with MIT License
from hishamco
public async override Task RenderAsync(TextWriter writer)
{
if (!Visible)
{
await Task.CompletedTask;
}
if (Text?.Length > 0)
{
if (Encoded)
{
Text = HtmlEncoder.Default.Encode(Text);
}
await writer.WriteAsync(Text);
}
}
19
Source : Given02.cs
with BSD 3-Clause "New" or "Revised" License
from kutoga
with BSD 3-Clause "New" or "Revised" License
from kutoga
private static async Task Init(string apiKey, uint timeout)
{
/* ... */
await Console.Out.WriteAsync($"Init: {nameof(apiKey)}={apiKey}, {nameof(timeout)}={timeout}").ConfigureAwait(false);
/* ... */
}
19
Source : Given02.cs
with BSD 3-Clause "New" or "Revised" License
from kutoga
with BSD 3-Clause "New" or "Revised" License
from kutoga
private static async Task Delete(string apiKey, string file, uint timeout)
{
/* ... */
await Console.Out.WriteAsync($"Delete: {nameof(apiKey)}={apiKey}, {nameof(file)}={file}, {nameof(timeout)}={timeout}").ConfigureAwait(false);
/* ... */
}
19
Source : Given02.cs
with BSD 3-Clause "New" or "Revised" License
from kutoga
with BSD 3-Clause "New" or "Revised" License
from kutoga
private static async Task Move(string apiKey, string source, string target, uint timeout)
{
/* ... */
await Console.Out.WriteAsync($"Move: {nameof(apiKey)}={apiKey}, {nameof(source)}={source}, {nameof(target)}={target}, {nameof(timeout)}={timeout}").ConfigureAwait(false);
/* ... */
}
19
Source : DefaultMediaFormatter.cs
with MIT License
from letsar
with MIT License
from letsar
public Task WriteAsync<T>(T content, TextWriter writer)
{
return writer.WriteAsync(content.ToString());
}
19
Source : MarkdownWriter.cs
with MIT License
from malware-dev
with MIT License
from malware-dev
public Task WriteAsync(string text) => _writer._writer.WriteAsync(text);
19
Source : ConsoleImpl.cs
with GNU General Public License v3.0
from marcinotorowski
with GNU General Public License v3.0
from marcinotorowski
public async Task WriteError(string error)
{
var originalBackground = Console.BackgroundColor;
var originalForeground = Console.ForegroundColor;
try
{
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.White;
await this.errorOut.WriteAsync(error).ConfigureAwait(false);
}
finally
{
Console.BackgroundColor = originalBackground;
Console.ForegroundColor = originalForeground;
await this.output.WriteLineAsync();
}
}
19
Source : ConsoleImpl.cs
with GNU General Public License v3.0
from marcinotorowski
with GNU General Public License v3.0
from marcinotorowski
public async Task WriteWarning(string warn)
{
var originalBackground = Console.BackgroundColor;
var originalForeground = Console.ForegroundColor;
try
{
Console.BackgroundColor = ConsoleColor.DarkYellow;
Console.ForegroundColor = ConsoleColor.White;
await this.output.WriteAsync(warn).ConfigureAwait(false);
}
finally
{
Console.BackgroundColor = originalBackground;
Console.ForegroundColor = originalForeground;
await this.output.WriteLineAsync();
}
}
19
Source : ConsoleImpl.cs
with GNU General Public License v3.0
from marcinotorowski
with GNU General Public License v3.0
from marcinotorowski
public async Task WriteSuccess(string success)
{
var originalBackground = Console.BackgroundColor;
var originalForeground = Console.ForegroundColor;
try
{
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.ForegroundColor = ConsoleColor.White;
await this.output.WriteAsync(success).ConfigureAwait(false);
}
finally
{
Console.BackgroundColor = originalBackground;
Console.ForegroundColor = originalForeground;
await this.output.WriteLineAsync();
}
}
19
Source : YamlWriter.cs
with GNU General Public License v3.0
from marcinotorowski
with GNU General Public License v3.0
from marcinotorowski
public async Task WriteAsync(YamlManifest manifest, TextWriter textWriter, CancellationToken cancellationToken = default)
{
var stringBuilder = new StringBuilder();
await using (var stringWriter = new StringWriter(stringBuilder))
{
this.serializer.Value.Serialize(stringWriter, manifest);
}
cancellationToken.ThrowIfCancellationRequested();
stringBuilder.AppendLine();
stringBuilder.AppendLine("# Edited with MSIX Hero");
cancellationToken.ThrowIfCancellationRequested();
var serialized = stringBuilder.ToString();
serialized = Regex.Replace(serialized, @"[\r\n]{2,}", Environment.NewLine);
await textWriter.WriteAsync(serialized).ConfigureAwait(false);
}
19
Source : CsvWriter.cs
with MIT License
from meziantou
with MIT License
from meziantou
public Task BeginRowAsync()
{
var isFirstRow = _isFirstRow;
_isFirstRow = false;
_isFirstRowValue = true;
if (!isFirstRow)
{
return BaseWriter.WriteAsync(EndOfLine);
}
return Task.CompletedTask;
}
19
Source : FileTranscriptLogger.cs
with MIT License
from microsoft
with MIT License
from microsoft
public async Task LogActivityAsync(IActivity activity)
{
if (activity == null)
{
throw new ArgumentNullException(nameof(activity));
}
var transcriptFile = GetTranscriptFile(activity.ChannelId, activity.Conversation.Id);
if (Debugger.IsAttached && activity.Type == ActivityTypes.Message)
{
System.Diagnostics.Trace.TraceInformation($"{activity.From.Name ?? activity.From.Id ?? activity.From.Role} [{activity.Type}] {activity.AsMessageActivity()?.Text}");
}
else
{
System.Diagnostics.Trace.TraceInformation($"{activity.From.Name ?? activity.From.Id ?? activity.From.Role} [{activity.Type}]");
}
// try 3 times
for (int i = 0; i < 3; i++)
{
try
{
if ((this._unitTestMode == true && !_started.Contains(transcriptFile)) || !File.Exists(transcriptFile))
{
Trace.TraceInformation($"file://{transcriptFile.Replace("\\", "/")}");
_started.Add(transcriptFile);
using (var stream = File.OpenWrite(transcriptFile))
{
using (var writer = new StreamWriter(stream) as TextWriter)
{
await writer.WriteAsync($"[{JsonConvert.SerializeObject(activity, _jsonSettings)}]").ConfigureAwait(false);
return;
}
}
}
switch (activity.Type)
{
case ActivityTypes.MessageDelete:
await MessageDeleteAsync(activity, transcriptFile).ConfigureAwait(false);
return;
case ActivityTypes.MessageUpdate:
await MessageUpdateAsync(activity, transcriptFile).ConfigureAwait(false);
return;
default:
// append
await LogActivityAsync(activity, transcriptFile).ConfigureAwait(false);
return;
}
}
#pragma warning disable CA1031 // Do not catch general exception types (we ignore the exception and we retry)
catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
{
// try again
Trace.TraceError($"Try {i + 1} - Failed to log activity because: {e.GetType()} : {e.Message}");
}
}
}
19
Source : FileTranscriptLogger.cs
with MIT License
from microsoft
with MIT License
from microsoft
private static async Task LogActivityAsync(IActivity activity, string transcriptFile)
{
var json = $",\n{JsonConvert.SerializeObject(activity, _jsonSettings)}]";
using (var stream = File.Open(transcriptFile, FileMode.OpenOrCreate))
{
if (stream.Length > 0)
{
stream.Seek(-1, SeekOrigin.End);
}
using (TextWriter writer = new StreamWriter(stream))
{
await writer.WriteAsync(json).ConfigureAwait(false);
}
}
}
19
Source : Extensions.cs
with MIT License
from neo-project
with MIT License
from neo-project
public static async Task WriteTxHashAsync(this TextWriter writer, UInt256 txHash, string txType = "", bool json = false)
{
if (json)
{
await writer.WriteLineAsync($"{txHash}").ConfigureAwait(false);
}
else
{
if (!string.IsNullOrEmpty(txType)) await writer.WriteAsync($"{txType} ").ConfigureAwait(false);
await writer.WriteLineAsync($"Transaction {txHash} submitted").ConfigureAwait(false);
}
}
19
Source : TransactionExecutor.cs
with MIT License
from neo-project
with MIT License
from neo-project
public async Task InvokeForResultsAsync(Script script, string accountName, WitnessScope witnessScope)
{
Signer? signer = chainManager.TryGetSigningAccount(accountName, string.Empty, out _, out var accountHash)
? signer = new Signer
{
Account = accountHash,
Scopes = witnessScope,
AllowedContracts = Array.Empty<UInt160>(),
AllowedGroups = Array.Empty<Neo.Cryptography.ECC.ECPoint>()
}
: null;
var result = await expressNode.InvokeAsync(script, signer).ConfigureAwait(false);
if (json)
{
await writer.WriteLineAsync(result.ToJson().ToString(true)).ConfigureAwait(false);
}
else
{
await writer.WriteLineAsync($"VM State: {result.State}").ConfigureAwait(false);
await writer.WriteLineAsync($"Gas Consumed: {result.GasConsumed}").ConfigureAwait(false);
if (!string.IsNullOrEmpty(result.Exception))
{
await writer.WriteLineAsync($"Exception: {result.Exception}").ConfigureAwait(false);
}
if (result.Stack.Length > 0)
{
var stack = result.Stack;
await writer.WriteLineAsync("Result Stack:").ConfigureAwait(false);
for (int i = 0; i < stack.Length; i++)
{
await WriteStackItemAsync(writer, stack[i]).ConfigureAwait(false);
}
}
}
static async Task WriteStackItemAsync(System.IO.TextWriter writer, Neo.VM.Types.StackItem item, int indent = 1, string prefix = "")
{
switch (item)
{
case Neo.VM.Types.Boolean _:
await WriteLineAsync(item.GetBoolean() ? "true" : "false").ConfigureAwait(false);
break;
case Neo.VM.Types.Integer @int:
await WriteLineAsync(@int.GetInteger().ToString()).ConfigureAwait(false);
break;
case Neo.VM.Types.Buffer buffer:
await WriteLineAsync(Neo.Helper.ToHexString(buffer.GetSpan())).ConfigureAwait(false);
break;
case Neo.VM.Types.ByteString byteString:
await WriteLineAsync(Neo.Helper.ToHexString(byteString.GetSpan())).ConfigureAwait(false);
break;
case Neo.VM.Types.Null _:
await WriteLineAsync("<null>").ConfigureAwait(false);
break;
case Neo.VM.Types.Array array:
await WriteLineAsync($"Array: ({array.Count})").ConfigureAwait(false);
for (int i = 0; i < array.Count; i++)
{
await WriteStackItemAsync(writer, array[i], indent + 1).ConfigureAwait(false);
}
break;
case Neo.VM.Types.Map map:
await WriteLineAsync($"Map: ({map.Count})").ConfigureAwait(false);
foreach (var m in map)
{
await WriteStackItemAsync(writer, m.Key, indent + 1, "key: ").ConfigureAwait(false);
await WriteStackItemAsync(writer, m.Value, indent + 1, "value: ").ConfigureAwait(false);
}
break;
}
async Task WriteLineAsync(string value)
{
for (var i = 0; i < indent; i++)
{
await writer.WriteAsync(" ").ConfigureAwait(false);
}
if (!string.IsNullOrEmpty(prefix))
{
await writer.WriteAsync(prefix).ConfigureAwait(false);
}
await writer.WriteLineAsync(value).ConfigureAwait(false);
}
}
}
19
Source : TextWriterWrapper.cs
with MIT License
from OrbitalShell
with MIT License
from OrbitalShell
public virtual Task WriteAsync(string s)
{
if (IsMute) return Task.CompletedTask;
IsModified = !string.IsNullOrWhiteSpace(s);
if (IsModified && IsRecordingEnabled)
_recording.Append(s);
if (IsReplicationEnabled)
_replicateStreamWriter.WriteAsync(s);
if (IsBufferEnabled)
{
return _bufferWriter.WriteAsync(s);
}
else
{
return _textWriter.WriteAsync(s);
}
}
19
Source : ObservablesForEventGenerator.cs
with MIT License
from reactiveui
with MIT License
from reactiveui
public static async Task ExtractEventsFromreplacedemblies(TextWriter writer, InputreplacedembliesGroup input, NuGetFramework framework)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
var compilation = new EventBuilderCompiler(input, framework);
var compilationOutputSyntax = CompilationUnit()
.WithMembers(List<MemberDeclarationSyntax>(_resolvers.SelectMany(x => x.Create(compilation))))
.WithUsings(List(new[]
{
UsingDirective(IdentifierName("global::System")),
UsingDirective(IdentifierName("global::System.Reactive")),
UsingDirective(IdentifierName("global::System.Reactive.Linq")),
UsingDirective(IdentifierName("global::System.Reactive.Subjects")),
UsingDirective(IdentifierName("global::Pharmacist.Common"))
}));
await writer.WriteAsync(Environment.NewLine).ConfigureAwait(false);
await writer.WriteAsync(compilationOutputSyntax.NormalizeWhitespace(elasticTrivia: true).ToString()).ConfigureAwait(false);
await writer.FlushAsync().ConfigureAwait(false);
compilation.Dispose();
}
19
Source : PagedBufferedTextWriter.cs
with MIT License
from Rizzen
with MIT License
from Rizzen
public override async Task WriteAsync(string value)
{
await FlushAsync();
await _inner.WriteAsync(value);
}
19
Source : InputOutput.cs
with MIT License
from rudzen
with MIT License
from rudzen
public async Task WriteAsync(string cad, InputOutputMutex action = InputOutputMutex.None)
{
if (action.IsWaitable())
_mutex.WaitOne();
await Output.WriteAsync(cad).ConfigureAwait(false);
if (action.IsReleasable())
_mutex.ReleaseMutex();
}
19
Source : CSharpWriter.cs
with MIT License
from rwredding
with MIT License
from rwredding
public async Task WriteIndentAsync() => await this.TextWriter.WriteAsync(new string('\t', this.indentation));
19
Source : CSharpWriter.cs
with MIT License
from rwredding
with MIT License
from rwredding
public async Task WriteAttributesAsync()
{
if (this.attributeBuffer.Any())
{
await this.WriteIndentAsync();
await this.TextWriter.WriteAsync("[");
await this.WriteAttributeContentAsync(this.attributeBuffer.First());
foreach (AttributeModel attribute in this.attributeBuffer.Skip(1))
{
await this.TextWriter.WriteAsync(", ");
await this.WriteAttributeContentAsync(attribute);
}
await this.TextWriter.WriteAsync("]");
await this.TextWriter.WriteLineAsync();
this.attributeBuffer.Clear();
}
}
19
Source : CSharpWriter.cs
with MIT License
from rwredding
with MIT License
from rwredding
private async Task WriteAttributeContentAsync(AttributeModel attribute)
{
await this.TextWriter.WriteAsync(attribute.TypeName);
if (attribute.Arguments.Any())
{
await this.TextWriter.WriteAsync("(");
await this.TextWriter.WriteAsync(string.Join(", ", attribute.Arguments.Select(this.FormatAttributeLiteral)));
await this.TextWriter.WriteAsync(")");
}
}
19
Source : CSharpWriter.cs
with MIT License
from rwredding
with MIT License
from rwredding
public async Task WritePropertyAsync(string type, string name, string[] modifiers = null)
{
await this.WriteIndentAsync();
if (modifiers?.Length > 0)
{
await this.TextWriter.WriteAsync(string.Join(" ", modifiers));
await this.TextWriter.WriteAsync(" ");
}
await this.TextWriter.WriteAsync(type);
await this.TextWriter.WriteAsync(" ");
await this.TextWriter.WriteAsync(name);
await this.TextWriter.WriteLineAsync(" { get; set; }");
}
19
Source : CSharpWriter.cs
with MIT License
from rwredding
with MIT License
from rwredding
public async Task WriteObjectStartAsync(string type, string name, string[] modifiers = null, string[] baseTypes = null)
{
await this.WriteIndentAsync();
if (modifiers?.Length > 0)
{
await this.TextWriter.WriteAsync(string.Join(" ", modifiers));
await this.TextWriter.WriteAsync(" ");
}
await this.TextWriter.WriteAsync(type);
await this.TextWriter.WriteAsync(" ");
await this.TextWriter.WriteAsync(CSharp.Identifier(name));
if (baseTypes?.Length > 0)
{
await this.TextWriter.WriteAsync(" : ");
await this.TextWriter.WriteAsync(string.Join(", ", baseTypes));
}
await this.WriteLineAsync();
await this.WriteIndentAsync();
await this.TextWriter.WriteLineAsync("{");
if (this.HasFlag(CSharpFlags.AutoIndent))
this.Indent();
}
19
Source : TextSpanStatement.cs
with MIT License
from sebastienros
with MIT License
from sebastienros
public override ValueTask<Completion> WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
{
if (!_isStripped)
{
// Prevent two threads from strsipping the same statement in case WriteToAsync is called concurrently
//
lock (_synLock)
{
if (!_isStripped)
{
var trimming = context.Options.Trimming;
StripLeft |=
(PreviousIsTag && (trimming & TrimmingFlags.TagRight) != 0) ||
(PreviousIsOutput && (trimming & TrimmingFlags.OutputRight) != 0)
;
StripRight |=
(NextIsTag && (trimming & TrimmingFlags.TagLeft) != 0) ||
(NextIsOutput && (trimming & TrimmingFlags.OutputLeft) != 0)
;
var span = _text.Buffer;
var start = 0;
var end = _text.Length - 1;
// Does this text need to have its left part trimmed?
if (StripLeft)
{
var firstNewLine = -1;
for (var i = start; i <= end; i++)
{
var c = span[_text.Offset + i];
if (Character.IsWhiteSpaceOrNewLine(c))
{
start++;
if (firstNewLine == -1 && (c == '\n'))
{
firstNewLine = start;
}
}
else
{
break;
}
}
if (!context.Options.Greedy)
{
if (firstNewLine != -1)
{
start = firstNewLine;
}
}
}
// Does this text need to have its right part trimmed?
if (StripRight)
{
var lastNewLine = -1;
for (var i = end; i >= start; i--)
{
var c = span[_text.Offset + i];
if (Character.IsWhiteSpaceOrNewLine(c))
{
if (lastNewLine == -1 && c == '\n')
{
lastNewLine = end;
}
end--;
}
else
{
break;
}
}
if (!context.Options.Greedy)
{
if (lastNewLine != -1)
{
end = lastNewLine;
}
}
}
if (end - start + 1 == 0)
{
_isEmpty = true;
}
else if (start != 0 || end != _text.Length - 1)
{
var offset = _text.Offset;
var buffer = _text.Buffer;
_text = new TextSpan(buffer, offset + start, end - start + 1);
}
_buffer = _text.ToString();
_isStripped = true;
}
}
}
if (_isEmpty)
{
return new ValueTask<Completion>(Completion.Normal);
}
context.IncrementSteps();
// The Text fragments are not encoded, but kept as-is
// Since WriteAsync needs an actual buffer, we created and reused _buffer
static async ValueTask<Completion> Awaited(Task task)
{
await task;
return Completion.Normal;
}
var task = writer.WriteAsync(_buffer);
if (!task.IsCompletedSuccessfully())
{
return Awaited(task);
}
return new ValueTask<Completion>(Completion.Normal);
}
19
Source : WriteUtils.cs
with GNU Affero General Public License v3.0
from siteserver
with GNU Affero General Public License v3.0
from siteserver
public static async Task PrintSuccessAsync(string successMessage)
{
var backgroundColor = Console.BackgroundColor;
Console.BackgroundColor = ConsoleColor.DarkGreen;
await Console.Out.WriteAsync(" SUCCESS ");
Console.BackgroundColor = backgroundColor;
await Console.Out.WriteAsync($" {successMessage}");
await Console.Out.WriteLineAsync();
}
19
Source : WriteUtils.cs
with GNU Affero General Public License v3.0
from siteserver
with GNU Affero General Public License v3.0
from siteserver
public static async Task PrintErrorAsync(string errorMessage)
{
var backgroundColor = Console.BackgroundColor;
Console.BackgroundColor = ConsoleColor.DarkRed;
await Console.Out.WriteAsync(" ERROR ");
Console.BackgroundColor = backgroundColor;
await Console.Out.WriteAsync($" {errorMessage}");
await Console.Out.WriteLineAsync();
}
19
Source : NodeImplementations.cs
with GNU General Public License v3.0
from TASVideos
with GNU General Public License v3.0
from TASVideos
public async Task WriteTextAsync(TextWriter writer, WriterContext ctx)
{
await writer.WriteAsync(Content);
}
19
Source : NodeImplementations.cs
with GNU General Public License v3.0
from TASVideos
with GNU General Public License v3.0
from TASVideos
public async Task WriteTextAsync(TextWriter writer, WriterContext ctx)
{
if (Name.ToLowerInvariant() == "settableattributes")
{
// Do nothing for this special module
}
else if (WikiModules.IsModule(Name))
{
// It's the caller's responsibility to provide a view component runner that will create text output.
await ctx.Helper.RunViewComponentAsync(writer, Name, Parameters);
}
else
{
await writer.WriteAsync($"ERROR: Unknown module {Name}");
}
}
19
Source : IndentedTextWriter.cs
with MIT License
from Team-RTCLI
with MIT License
from Team-RTCLI
protected virtual async Task OutputTabsAsync()
{
if (_tabsPending)
{
for (int i = 0; i < _indentLevel; i++)
{
await _writer.WriteAsync(_tabString).ConfigureAwait(false);
}
_tabsPending = false;
}
}
19
Source : NewtonsoftNdjsonWriterFactory.cs
with MIT License
from tpeczek
with MIT License
from tpeczek
public async Task WriteAsync(object value, CancellationToken cancellationToken)
{
_jsonSerializer.Serialize(_jsonResponseStreamWriter, value);
await _textResponseStreamWriter.WriteAsync("\n");
await _textResponseStreamWriter.FlushAsync();
}
19
Source : ResponseStreamTest.cs
with MIT License
from ultranijia
with MIT License
from ultranijia
public static Task StartTransferTypeAndErrorServer(
TransferType transferType,
TransferError transferError,
Func<Uri, Task> clientFunc)
{
return LoopbackServer.CreateClientAndServerAsync(
clientFunc,
server => server.AcceptConnectionAsync(async connection =>
{
// Read past request headers.
await connection.ReadRequestHeaderAsync();
// Determine response transfer headers.
string transferHeader = null;
string content = "This is some response content.";
if (transferType == TransferType.ContentLength)
{
transferHeader = transferError == TransferError.ContentLengthTooLarge ?
$"Content-Length: {content.Length + 42}\r\n" :
$"Content-Length: {content.Length}\r\n";
}
else if (transferType == TransferType.Chunked)
{
transferHeader = "Transfer-Encoding: chunked\r\n";
}
// Write response header
TextWriter writer = connection.Writer;
await writer.WriteAsync("HTTP/1.1 200 OK\r\n").ConfigureAwait(false);
await writer.WriteAsync($"Date: {DateTimeOffset.UtcNow:R}\r\n").ConfigureAwait(false);
await writer.WriteAsync("Content-Type: text/plain\r\n").ConfigureAwait(false);
if (!string.IsNullOrEmpty(transferHeader))
{
await writer.WriteAsync(transferHeader).ConfigureAwait(false);
}
await writer.WriteAsync("\r\n").ConfigureAwait(false);
// Write response body
if (transferType == TransferType.Chunked)
{
string chunkSizeInHex = string.Format(
"{0:x}\r\n",
content.Length + (transferError == TransferError.ChunkSizeTooLarge ? 42 : 0));
await writer.WriteAsync(chunkSizeInHex).ConfigureAwait(false);
await writer.WriteAsync($"{content}\r\n").ConfigureAwait(false);
if (transferError != TransferError.MissingChunkTerminator)
{
await writer.WriteAsync("0\r\n\r\n").ConfigureAwait(false);
}
}
else
{
await writer.WriteAsync($"{content}").ConfigureAwait(false);
}
}));
}
19
Source : TextWriterExtensions.cs
with MIT License
from WaifuShork
with MIT License
from WaifuShork
public static async Task WriteColorAsync<T>(this TextWriter writer, T message, ConsoleColor color = ConsoleColor.White, bool isNewLine = true)
{
if (message == null)
{
await writer.WriteLineAsync();
return;
}
Console.ForegroundColor = color;
if (isNewLine)
{
await writer.WriteLineAsync(message.ToString());
}
else
{
await writer.WriteAsync(message.ToString());
}
Console.ResetColor();
}
19
Source : Installer.cs
with MIT License
from WaifuShork
with MIT License
from WaifuShork
public static async Task<int> Install()
{
using (var idenreplacedy = WindowsIdenreplacedy.GetCurrent())
{
var principal = new WindowsPrincipal(idenreplacedy);
var isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);
if (!isElevated)
{
await Console.Error.WriteErrorAsync("Unable to execute installer/uninstall, please run as administrator.");
return 0;
}
}
// Force 64 bit
// Do not allow 32 bit until the language runtime itself supports it
if (!Environment.Is64BitOperatingSystem)
{
await Console.Error.WriteErrorAsync("Error: Unsupported OS Architecture detected, please ensure you're using Windows OS (x64 bit)");
Console.ReadKey();
return 0;
}
// Find the embedded resource
var stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("Vivian.vivian-x64.zip");
if (stream == null)
{
await Console.Error.WriteErrorAsync($"Internal Error: <{stream}> \n\nPlease see <bug-tracker>");
Console.ReadKey();
return 1;
}
var zip = new ZipArchive(stream);
// Fetch and print the logo
var logo = await FetchLogoAsync(zip, "logo.txt");
await Console.Out.WriteColorAsync(logo, ConsoleColor.Magenta);
await Console.Out.WriteAsync("Install or Uninstall? ([I]nstall / [U]ninstall");
var input = await Console.In.ReadLineAsync();
if (!string.IsNullOrWhiteSpace(input))
{
var path = @$"{Path.GetPathRoot(Environment.SystemDirectory)}Program Files\vivian";
if (input.ToLowerInvariant() == "install" | input.ToLowerInvariant() == "i")
{
await Console.Out.WriteAsync("Confirm installation of Vivian Tools? ([Y]es / [N]o): ");
input = await Console.In.ReadLineAsync();
// prompt user
if (!string.IsNullOrWhiteSpace(input))
{
if (!PromptUser(input))
{
return 0;
}
}
await Console.Out.WriteAsync("Would you like to add Vivian Tools to PATH? ([Y]es / [N]o): ");
input = await Console.In.ReadLineAsync();
var isAddingToPath = false;
if (!string.IsNullOrWhiteSpace(input))
{
isAddingToPath = PromptUser(input);
}
await InstallVivianTools(isAddingToPath, path, zip);
await Console.Out.WriteSuccessAsync("Successfully installed Vivian Tools. Press any key to exit...");
await Task.Run(() => Console.ReadKey(true).Key);
return 0;
}
// Leaving this temporarily unimplemented
// not tryna replaced up replaced
// if (input.ToLowerInvariant() == "uninstall" | input.ToLowerInvariant() == "u")
//{
// if for some reason the path isn't at the SystemDir\Program Files\vivian
// something is wrong and should be aborted
// await UninstallVivianTools(path);
// return 0;
//}
}
// if we somehow reached this point, then we've done something wrong
return 1;
}