Here are the examples of the csharp api System.IO.TextWriter.Flush() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
516 Examples
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public override void Write(string? value) {
STDOUT?.Write(value);
File?.Write(value);
File?.Flush();
}
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public override void WriteLine(string? value) {
STDOUT?.WriteLine(value);
File?.WriteLine(value);
File?.Flush();
}
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public override void Write(char value) {
STDOUT?.Write(value);
File?.Write(value);
File?.Flush();
}
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public override void Write(char[] buffer, int index, int count) {
STDOUT?.Write(buffer, index, count);
File?.Write(buffer, index, count);
File?.Flush();
}
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public override void Flush() {
STDOUT?.Flush();
File?.Flush();
}
19
View Source File : HtmlRichTextWriter.cs
License : MIT License
Project Creator : Abdesol
License : MIT License
Project Creator : Abdesol
public override void Flush()
{
FlushSpace(true); // next char potentially might be whitespace
htmlWriter.Flush();
}
19
View Source File : ConvertEditLinksFilter.cs
License : Apache License 2.0
Project Creator : advanced-cms
License : Apache License 2.0
Project Creator : advanced-cms
public void Flush(bool rewriteText)
{
var bufferedText = stringBuilder.ToString();
if (rewriteText && textRewriteFunction != null)
{
bufferedText = textRewriteFunction.Invoke(bufferedText);
}
InnerTextWriter.Write(bufferedText);
InnerTextWriter.Flush();
}
19
View Source File : Modules.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
public static string Invoke(string FileId, string[] args)
{
string output = "";
try
{
string FullName = GetFullName(FileId);
replacedembly[] replacedems = AppDomain.CurrentDomain.Getreplacedemblies();
foreach (replacedembly replacedem in replacedems)
{
if (replacedem.FullName == Encoding.UTF8.GetString(Convert.FromBase64String(FullName)))
{
MethodInfo entrypoint = replacedem.EntryPoint;
object[] arg = new object[] { args };
TextWriter realStdOut = Console.Out;
TextWriter realStdErr = Console.Error;
TextWriter stdOutWriter = new StringWriter();
TextWriter stdErrWriter = new StringWriter();
Console.SetOut(stdOutWriter);
Console.SetError(stdErrWriter);
entrypoint.Invoke(null, arg);
Console.Out.Flush();
Console.Error.Flush();
Console.SetOut(realStdOut);
Console.SetError(realStdErr);
output = stdOutWriter.ToString();
output += stdErrWriter.ToString();
break;
}
}
return output;
}
catch
{
return output;
}
}
19
View Source File : JsonTextWriter.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public override void Flush()
{
_writer.Flush();
}
19
View Source File : AboutDialog.xaml.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
public static string ConvertToPlainText(string html)
{
HtmlDoreplacedent doc = new HtmlDoreplacedent();
doc.LoadHtml(html);
StringWriter sw = new StringWriter();
ConvertTo(doc.DoreplacedentNode, sw);
sw.Flush();
return sw.ToString();
}
19
View Source File : LocationLogWriter.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
protected virtual void Dispose(bool disposeManagedResources)
{
if (!_disposed)
{
if (disposeManagedResources)
{
Debug.LogFormat("{0} locations logged", _lineCount);
if (null != _textWriter)
{
_textWriter.Flush();
_fileStream.Flush();
#if !NETFX_CORE
_textWriter.Close();
#endif
_textWriter.Dispose();
_fileStream.Dispose();
_textWriter = null;
_fileStream = null;
}
}
_disposed = true;
}
}
19
View Source File : LocationLogWriter.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public void Write(Location location)
{
string[] lineTokens = new string[]
{
location.IsLocationServiceEnabled.ToString(),
location.IsLocationServiceInitializing.ToString(),
location.IsLocationUpdated.ToString(),
location.IsUserHeadingUpdated.ToString(),
location.Provider,
LocationProviderFactory.Instance.DefaultLocationProvider.GetType().Name,
DateTime.UtcNow.ToString("yyyyMMdd-HHmmss.fff"),
UnixTimestampUtils.From(location.Timestamp).ToString("yyyyMMdd-HHmmss.fff"),
string.Format(_invariantCulture, "{0:0.00000000}", location.LareplacedudeLongitude.x),
string.Format(_invariantCulture, "{0:0.00000000}", location.LareplacedudeLongitude.y),
string.Format(_invariantCulture, "{0:0.0}", location.Accuracy),
string.Format(_invariantCulture, "{0:0.0}", location.UserHeading),
string.Format(_invariantCulture, "{0:0.0}", location.DeviceOrientation),
nullablereplacedtr<float>(location.SpeedKmPerHour, "{0:0.0}"),
nullablereplacedtr<bool>(location.HasGpsFix, "{0}"),
nullablereplacedtr<int>(location.SatellitesUsed, "{0}"),
nullablereplacedtr<int>(location.SatellitesInView, "{0}")
};
_lineCount++;
string logMsg = string.Join(Delimiter, lineTokens);
Debug.Log(logMsg);
_textWriter.WriteLine(logMsg);
_textWriter.Flush();
}
19
View Source File : Block.cs
License : MIT License
Project Creator : alexanderdna
License : MIT License
Project Creator : alexanderdna
public void PrepareForPowHash(TextWriter writer)
{
HexUtils.AppendHexFromInt(writer, Index);
HexUtils.AppendHexFromLong(writer, Timestamp);
writer.Write(MerkleHash);
writer.Write(PreviousBlockHash);
writer.Flush();
}
19
View Source File : Program.cs
License : MIT License
Project Creator : alexanderdna
License : MIT License
Project Creator : alexanderdna
private static void runMainLoop(CLOptions options)
{
switch (options.LogMode)
{
case "console":
_logger = App.ConsoleLogger;
break;
case "both":
_logger = App.FileAndConsoleLogger;
break;
case "file":
default:
_logger = App.FileLogger;
options.LogMode = LogMode.File;
break;
}
_app = new App(App.DefaultPathsProvider, _logger);
_options = options;
if (options.ListeningPort > 0)
{
_app.Listen(options.ListeningPort);
}
_app.ConnectToPeers();
if (_app.IsInIbd)
{
ensureLogToConsole(App.LogLevel.Info, "Initial block download is running...");
Console.Out.Flush();
while (_app.IsInIbd)
{
Thread.Sleep(100);
}
if (_app.Daemon.CurrentIbdPhase == InitialBlockDownload.Phase.Succeeded)
{
ensureLogToConsole(App.LogLevel.Info, "Initial block download is finished.");
ensureLogToConsole(App.LogLevel.Info, $"Current height: {_app.ChainManager.Height}");
}
else
{
ensureLogToConsole(App.LogLevel.Info, "Initial block download failed. Exitting...");
return;
}
}
Console.CancelKeyPress += onSigInt;
var token = _app.CancellationTokenSource.Token;
if (options.IsNode)
{
while (!token.IsCancellationRequested)
{
Thread.Sleep(500);
}
}
else
{
Console.WriteLine("Welcome to ameow-cli. Enter `help` to show help message.");
Console.WriteLine();
var inputSeparator = new string[] { " " };
while (!token.IsCancellationRequested)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(">>> ");
string input = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Gray;
if (input == null)
{
Thread.Sleep(100);
if (token.IsCancellationRequested)
break;
}
string[] args = input.Split(inputSeparator, StringSplitOptions.RemoveEmptyEntries);
if (args.Length == 0) continue;
string cmdName = args[0];
Command cmd = commands.Find(c => c.Name == cmdName);
if (cmd != null)
cmd.Handler(args);
else
cmd_help(args);
}
}
try
{
_app.Shutdown();
}
catch (Exception ex)
{
_app.Logger.Log(App.LogLevel.Error, string.Format("Cannot shutdown properly: {0}", ex.Message));
}
}
19
View Source File : Class1.cs
License : MIT License
Project Creator : AlexChesser
License : MIT License
Project Creator : AlexChesser
public static void Main(string[] args)
{
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
int candlesCount = Convert.ToInt32(Console.ReadLine().Trim());
List<int> candles = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(candlesTemp => Convert.ToInt32(candlesTemp)).ToList();
int result = Result.birthdayCakeCandles(candles);
textWriter.WriteLine(result);
textWriter.Flush();
textWriter.Close();
}
19
View Source File : NetworkPressureTests.cs
License : MIT License
Project Creator : aliyun
License : MIT License
Project Creator : aliyun
private void Log(String text)
{
text = $"[Thread-{Thread.CurrentThread.ManagedThreadId}] {DateTime.Now:O} {text}";
// Debug.WriteLine(text);
Trace.WriteLine(text);
this.logWriter.WriteLine(text);
this.logWriter.Flush();
}
19
View Source File : Program.cs
License : MIT License
Project Creator : allantargino
License : MIT License
Project Creator : allantargino
static async Task ProcessMessagesAsync(Message message, CancellationToken token)
{
await _semapreplaced.WaitAsync();
try
{
_lastExecution = DateTime.Now;
Console.WriteLine($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}");
Console.Out.Flush();
await _client.CompleteAsync(message.SystemProperties.LockToken);
}
finally
{
_semapreplaced.Release();
}
}
19
View Source File : OutputStringWriter.cs
License : GNU Lesser General Public License v3.0
Project Creator : Alois-xx
License : GNU Lesser General Public License v3.0
Project Creator : Alois-xx
public static void Flush()
{
Output.Flush();
}
19
View Source File : TextWriterAdapter.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public override void Flush()
{
m_writer.Flush();
}
19
View Source File : ProgramArguments.cs
License : GNU General Public License v3.0
Project Creator : asimmon
License : GNU General Public License v3.0
Project Creator : asimmon
public void WriteHelp(TextWriter output)
{
var execName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "bomberjam.exe" : "bomberjam";
output.WriteLine($"Usage: {execName} [OPTION]... [BOTPATH]...");
output.WriteLine($"Example: {execName} -q -r 2 -o replay#n.json \"MyBot.exe\" \"node MyBot.js\" \"python MyBot.py\" \"MyBot.bat\"");
output.WriteLine();
output.WriteLine("Options:");
this._options.WriteOptionDescriptions(output);
output.Flush();
}
19
View Source File : Worker.cs
License : GNU General Public License v3.0
Project Creator : asimmon
License : GNU General Public License v3.0
Project Creator : asimmon
private void Debug(int? tick, string? playerId, string text)
{
if (!this._opts.Quiet)
{
var tickStr = tick.HasValue ? tick.Value.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0') : " ";
var playerIdStr = playerId ?? " ";
Console.Out.WriteLine($"[{DateTime.Now:yyyy-mm-dd HH:mm:ss:ffff}][tick:{tickStr}][player:{playerIdStr}] {text}");
Console.Out.Flush();
}
}
19
View Source File : Game.cs
License : GNU General Public License v3.0
Project Creator : asimmon
License : GNU General Public License v3.0
Project Creator : asimmon
public void Ready(string playerName)
{
if (this._isReady)
return;
if (string.IsNullOrWhiteSpace(playerName))
throw new ArgumentException("Your name cannot be null or empty");
Console.Out.WriteLine("0:{0}", playerName);
Console.Out.Flush();
this._myPlayerId = Console.In.ReadLine();
int parsedId;
if (string.IsNullOrWhiteSpace(this._myPlayerId) || !int.TryParse(this._myPlayerId, NumberStyles.Integer, CultureInfo.InvariantCulture, out parsedId))
throw new InvalidOperationException("Could not retrieve your ID from standard input");
this._isReady = true;
}
19
View Source File : Game.cs
License : GNU General Public License v3.0
Project Creator : asimmon
License : GNU General Public License v3.0
Project Creator : asimmon
public void SendAction(ActionKind action)
{
this.EnsureIsReady();
this.EnsureInitialState();
var actionStr = Constants.ActionKindToActionStringMappings[action];
Console.Out.WriteLine("{0}:{1}", this._state.Tick.ToString(CultureInfo.InvariantCulture), actionStr);
Console.Out.Flush();
}
19
View Source File : TestChildProgram.cs
License : MIT License
Project Creator : asmichi
License : MIT License
Project Creator : asmichi
private static int CommandEchoAndSleepAndEcho(string[] args)
{
Console.Out.Write(args[1]);
Console.Out.Flush();
int duration = int.Parse(args[2], CultureInfo.InvariantCulture);
Thread.Sleep(duration);
Console.Out.Write(args[3]);
Console.Out.Flush();
return 0;
}
19
View Source File : DualWriter.cs
License : Apache License 2.0
Project Creator : aspnet
License : Apache License 2.0
Project Creator : aspnet
public override void Flush()
{
// InternalFlush
Writer2.Flush();
}
19
View Source File : HostingEngine.cs
License : Apache License 2.0
Project Creator : aspnet
License : Apache License 2.0
Project Creator : aspnet
public IDisposable Start(StartContext context)
{
ResolveOutput(context);
InitializeBuilder(context);
EnableTracing(context);
IDisposable disposablePipeline = EnableDisposing(context);
ResolveServerFactory(context);
InitializeServerFactory(context);
ResolveApp(context);
IDisposable disposableServer = StartServer(context);
return new Disposable(
() =>
{
try
{
// first stop processing requests
disposableServer.Dispose();
}
finally
{
// then inform the pipeline of app shutdown
disposablePipeline.Dispose();
// Flush logs
context.TraceOutput.Flush();
}
});
}
19
View Source File : Logging.cs
License : GNU General Public License v3.0
Project Creator : audiamus
License : GNU General Public License v3.0
Project Creator : audiamus
private void write (LogMessage msg) {
string s = format (msg);
lock (_lockable) {
Writer.WriteLine (s);
if (InstantFlush)
Writer.Flush ();
else
_linecount++;
}
}
19
View Source File : Logging.cs
License : GNU General Public License v3.0
Project Creator : audiamus
License : GNU General Public License v3.0
Project Creator : audiamus
private void flushTimerCallback (object state) {
lock (_lockable) {
if (_linecount > 0)
Writer.Flush ();
_linecount = 0;
}
}
19
View Source File : Write_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_OneArgumentIsSpecified()
{
// Arrange
var originalConsoleOut = System.Console.Out;
string formattedStringToBePrinted;
var fixture = new Fixture();
var expectedText = fixture.Create<string>();
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.Write(expectedText);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(expectedText));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : Write_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_FormatAndOneArgumentAreSpecified()
{
// Arrange
var fixture = new Fixture();
var expectedText = fixture.Create<string>();
var originalConsoleOut = System.Console.Out;
string formattedStringToBePrinted;
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.Write("{0}", expectedText);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(expectedText));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : Write_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_FormatAndTwoArgumentAreSpecified()
{
// Arrange
var fixture = new Fixture();
var expectedText1 = fixture.Create<string>();
var expectedText2 = fixture.Create<string>();
var originalConsoleOut = System.Console.Out;
string formattedStringToBePrinted;
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.Write("{0}{1}", expectedText1, expectedText2);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText1, expectedText2)));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : WriteLine_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_FormatAndTwoArgumentAreSpecified()
{
// Arrange
var fixture = new Fixture();
var expectedText1 = fixture.Create<string>();
var expectedText2 = fixture.Create<string>();
var originalConsoleOut = System.Console.Out;
string formattedStringToBePrinted;
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.WriteLine("{0}{1}", expectedText1, expectedText2);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText1, expectedText2, "\r\n")));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : WriteLine_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_OneArgumentIsSpecified()
{
// Arrange
var fixture = new Fixture();
var expectedText = fixture.Create<string>();
var originalConsoleOut = System.Console.Out; // preserve the original stream
string formattedStringToBePrinted;
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.WriteLine(expectedText);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText, "\r\n")));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : WriteLine_Should.cs
License : Apache License 2.0
Project Creator : AutomateThePlanet
License : Apache License 2.0
Project Creator : AutomateThePlanet
[Test]
public void PrintFormattedString_When_FormatAndOneArgumentAreSpecified()
{
// Arrange
var fixture = new Fixture();
var expectedText = fixture.Create<string>();
var originalConsoleOut = System.Console.Out;
string formattedStringToBePrinted;
using (var writer = new StringWriter())
{
System.Console.SetOut(writer);
// Act
var consoleProvider = new ConsoleProvider();
consoleProvider.WriteLine("{0}", expectedText);
writer.Flush();
formattedStringToBePrinted = writer.GetStringBuilder().ToString();
}
// replacedert
replacedert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText, "\r\n")));
// Clean-up
System.Console.SetOut(originalConsoleOut);
}
19
View Source File : AvaTaxOfflineHelper.cs
License : Apache License 2.0
Project Creator : avadev
License : Apache License 2.0
Project Creator : avadev
private static void WriteZipRateFile(TaxRateModel zipRate, string zip, string path)
{
TextWriter writer = null;
try {
Directory.GetAccessControl(path);
var content = JsonConvert.SerializeObject(zipRate);
writer = new StreamWriter(Path.Combine(path, zip + ".json"));
writer.Write(content);
}
finally {
if (writer != null) {
writer.Flush();
writer.Close();
}
}
}
19
View Source File : BaseCommand.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
protected string PromptForValue(CommandOption option)
{
if (_cachedRequestedValues.ContainsKey(option))
{
var cachedValue = _cachedRequestedValues[option];
return cachedValue;
}
string input = null;
Console.Out.WriteLine($"Enter {option.Name}: ({option.Description})");
Console.Out.Flush();
input = Console.ReadLine();
if (string.IsNullOrWhiteSpace(input))
return null;
input = input.Trim();
_cachedRequestedValues[option] = input;
return input;
}
19
View Source File : BaseCommand.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
protected int PromptForValue(string message, IList<string> items)
{
Console.Out.WriteLine(message);
for (int i = 0; i < items.Count; i++)
{
Console.Out.WriteLine($" {(i + 1).ToString().PadLeft(2)}) {items[i]}");
}
Console.Out.Flush();
int chosenIndex = WaitForIndexResponse(1, items.Count);
return chosenIndex - 1;
}
19
View Source File : RoleHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
public static string CreateRole(IAmazonIdenreplacedyManagementService iamClient, string roleName, string replacedumeRolePolicy, params string[] managedPolicies)
{
if (managedPolicies != null && managedPolicies.Length > 0)
{
for(int i = 0; i < managedPolicies.Length; i++)
{
managedPolicies[i] = ExpandManagedPolicyName(iamClient, managedPolicies[i]);
}
}
string roleArn;
try
{
CreateRoleRequest request = new CreateRoleRequest
{
RoleName = roleName,
replacedumeRolePolicyDoreplacedent = replacedumeRolePolicy
};
var response = iamClient.CreateRoleAsync(request).Result;
roleArn = response.Role.Arn;
}
catch (Exception e)
{
throw new ToolsException($"Error creating IAM Role: {e.Message}", ToolsException.CommonErrorCode.IAMCreateRole, e);
}
if (managedPolicies != null && managedPolicies.Length > 0)
{
try
{
foreach(var managedPolicy in managedPolicies)
{
var request = new AttachRolePolicyRequest
{
RoleName = roleName,
PolicyArn = managedPolicy
};
iamClient.AttachRolePolicyAsync(request).Wait();
}
}
catch (Exception e)
{
throw new ToolsException($"Error replacedigning managed IAM Policy: {e.Message}", ToolsException.CommonErrorCode.IAMAttachRole, e);
}
}
bool found = false;
do
{
// There is no way check if the role has propagated yet so to
// avoid error during deployment creation do a generous sleep.
Console.WriteLine("Waiting for new IAM Role to propagate to AWS regions");
long start = DateTime.Now.Ticks;
while (TimeSpan.FromTicks(DateTime.Now.Ticks - start).TotalSeconds < SLEEP_TIME_FOR_ROLE_PROPOGATION.TotalSeconds)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.Write(".");
Console.Out.Flush();
}
Console.WriteLine("\t Done");
try
{
var getResponse = iamClient.GetRoleAsync(new GetRoleRequest { RoleName = roleName }).Result;
if (getResponse.Role != null)
found = true;
}
catch (NoSuchEnreplacedyException)
{
}
catch (Exception e)
{
throw new ToolsException("Error confirming new role was created: " + e.Message, ToolsException.CommonErrorCode.IAMGetRole, e);
}
} while (!found);
return roleArn;
}
19
View Source File : RoleHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
private static string SelectFromExisting(IAmazonIdenreplacedyManagementService iamClient, PromptRoleInfo promptInfo, IList<Role> existingRoles)
{
Console.Out.WriteLine("Select IAM Role that to provide AWS credentials to your code:");
for (int i = 0; i < existingRoles.Count; i++)
{
Console.Out.WriteLine($" {(i + 1).ToString().PadLeft(2)}) {existingRoles[i].RoleName}");
}
Console.Out.WriteLine($" {(existingRoles.Count + 1).ToString().PadLeft(2)}) *** Create new IAM Role ***");
Console.Out.Flush();
int chosenIndex = Utilities.WaitForPromptResponseByIndex(1, existingRoles.Count + 1);
if (chosenIndex - 1 < existingRoles.Count)
{
return existingRoles[chosenIndex - 1].Arn;
}
else
{
return PromptToCreateRole(iamClient, promptInfo);
}
}
19
View Source File : RoleHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
private static string PromptToCreateRole(IAmazonIdenreplacedyManagementService iamClient, PromptRoleInfo promptInfo)
{
Console.Out.WriteLine($"Enter name of the new IAM Role:");
var roleName = Console.ReadLine();
if (string.IsNullOrWhiteSpace(roleName))
return null;
roleName = roleName.Trim();
Console.Out.WriteLine("Select IAM Policy to attach to the new role and grant permissions");
var managedPolices = FindManagedPoliciesAsync(iamClient, promptInfo, DEFAULT_ITEM_MAX).Result;
for (int i = 0; i < managedPolices.Count; i++)
{
var line = $" {(i + 1).ToString().PadLeft(2)}) {managedPolices[i].PolicyName}";
var description = AttemptToGetPolicyDescription(managedPolices[i].Arn, promptInfo.KnownManagedPolicyDescription);
if (!string.IsNullOrEmpty(description))
{
if ((line.Length + description.Length) > MAX_LINE_LENGTH_FOR_MANAGED_ROLE)
description = description.Substring(0, MAX_LINE_LENGTH_FOR_MANAGED_ROLE - line.Length) + " ...";
line += $" ({description})";
}
Console.Out.WriteLine(line);
}
Console.Out.WriteLine($" {(managedPolices.Count + 1).ToString().PadLeft(2)}) *** No policy, add permissions later ***");
Console.Out.Flush();
int chosenIndex = Utilities.WaitForPromptResponseByIndex(1, managedPolices.Count + 1);
string managedPolicyArn = null;
if (chosenIndex < managedPolices.Count)
{
var selectedPolicy = managedPolices[chosenIndex - 1];
managedPolicyArn = selectedPolicy.Arn;
}
var roleArn = CreateRole(iamClient, roleName, Utilities.GetreplacedumeRolePolicy(promptInfo.replacedumeRolePrincipal), managedPolicyArn);
return roleArn;
}
19
View Source File : ECSBaseCommand.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
public async Task AttemptToCreateServiceLinkRoleAsync()
{
try
{
await this.IAMClient.CreateServiceLinkedRoleAsync(new CreateServiceLinkedRoleRequest
{
AWSServiceName = "ecs.amazonaws.com"
});
this.Logger.WriteLine("Created IAM Role service role for ecs.amazonaws.com");
this.Logger.WriteLine("Waiting for new IAM Role to propagate to AWS regions");
long start = DateTime.Now.Ticks;
while (TimeSpan.FromTicks(DateTime.Now.Ticks - start).TotalSeconds < RoleHelper.SLEEP_TIME_FOR_ROLE_PROPOGATION.TotalSeconds)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.Write(".");
Console.Out.Flush();
}
Console.WriteLine("\t Done");
}
catch(Exception)
{
}
}
19
View Source File : WorkspaceBuilderHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
public async IAsyncEnumerable<ProjectreplacedysisResult> BuildProjectIncremental()
{
if (IsSolutionFile())
{
using (SemapreplacedSlim concurrencySemapreplaced = new SemapreplacedSlim(1))
{
string solutionFilePath = NormalizePath(WorkspacePath);
SolutionFile solutionFile = SolutionFile.Parse(solutionFilePath);
foreach (var project in solutionFile.ProjectsInOrder)
{
string projectPath = project.AbsolutePath;
if (IsProjectFile(projectPath))
{
// if it is part of replacedyzer manager
concurrencySemapreplaced.Wait();
var result = await Task.Run(() =>
{
try
{
return RunTask(projectPath);
}
finally
{
concurrencySemapreplaced.Release();
}
});
yield return result;
}
}
}
}
else
{
yield return BuildIncremental(WorkspacePath);
}
Logger.LogDebug(_sb.ToString());
_writer.Flush();
_writer.Close();
ProcessLog(_writer.ToString());
}
19
View Source File : WorkspaceBuilderHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
public void Build()
{
/* Uncomment the below code to debug issues with msbuild */
/*var writer = new StreamWriter(Console.OpenStandardOutput());
writer.AutoFlush = true;
Console.SetOut(writer);
Console.SetError(writer);*/
if (IsSolutionFile())
{
Logger.LogInformation("Loading the Workspace (Solution): " + WorkspacePath);
replacedyzerManager replacedyzerManager = new replacedyzerManager(WorkspacePath,
new replacedyzerManagerOptions
{
LogWriter = _writer
});
Logger.LogInformation("Loading the Solution Done: " + WorkspacePath);
// replacedyzerManager builds the projects based on their dependencies
// After this, code does not depend on Buildalyzer
BuildSolution(replacedyzerManager);
}
else
{
replacedyzerManager replacedyzerManager = new replacedyzerManager(new replacedyzerManagerOptions
{
LogWriter = _writer
});
var dict = new Dictionary<Guid, IreplacedyzerResult>();
using (AdhocWorkspace workspace = new AdhocWorkspace())
{
Queue<string> queue = new Queue<string>();
ISet<string> existing = new HashSet<string>();
queue.Enqueue(WorkspacePath);
existing.Add(WorkspacePath);
/*
* We need to resolve all the project dependencies to avoid compilation errors.
* If we have compilation errors, we might miss some of the semantic values.
*/
while (queue.Count > 0)
{
var path = queue.Dequeue();
Logger.LogInformation("Building: " + path);
IProjectreplacedyzer projectreplacedyzer = replacedyzerManager.GetProject(path);
IreplacedyzerResults replacedyzerResults = projectreplacedyzer.Build(GetEnvironmentOptions(projectreplacedyzer.ProjectFile));
IreplacedyzerResult replacedyzerResult = replacedyzerResults.First();
if (replacedyzerResult == null)
{
FailedProjects.Add(new ProjectreplacedysisResult()
{
Projectreplacedyzer = projectreplacedyzer
});
}
dict[replacedyzerResult.ProjectGuid] = replacedyzerResult;
replacedyzerResult.AddToWorkspace(workspace);
foreach (var pref in replacedyzerResult.ProjectReferences)
{
if (!existing.Contains(pref))
{
existing.Add(pref);
queue.Enqueue(pref);
}
}
}
foreach (var project in workspace.CurrentSolution.Projects)
{
try
{
var result = dict[project.Id.Id];
var projectreplacedyzer = replacedyzerManager.Projects.Values.FirstOrDefault(p =>
p.ProjectGuid.Equals(project.Id.Id));
Projects.Add(new ProjectreplacedysisResult()
{
Project = project,
replacedyzerResult = result,
Projectreplacedyzer = projectreplacedyzer
});
}
catch (Exception ex)
{
Logger.LogDebug(ex.StackTrace);
}
}
}
}
Logger.LogDebug(_sb.ToString());
_writer.Flush();
_writer.Close();
ProcessLog(_writer.ToString());
}
19
View Source File : WorkspaceBuilderHelper.cs
License : Apache License 2.0
Project Creator : aws
License : Apache License 2.0
Project Creator : aws
public void GenerateNoBuildreplacedysis()
{
if (IsSolutionFile())
{
Logger.LogInformation("Loading the Workspace (Solution): " + WorkspacePath);
replacedyzerManager replacedyzerManager = new replacedyzerManager(WorkspacePath,
new replacedyzerManagerOptions
{
LogWriter = _writer
});
replacedyzerManager.Projects.Values.ToList().ForEach(projectreplacedyzer =>
{
Projects.Add(new ProjectreplacedysisResult()
{
Projectreplacedyzer = projectreplacedyzer
});
});
Logger.LogInformation("Loading the Solution Done: " + WorkspacePath);
}
else
{
replacedyzerManager replacedyzerManager = new replacedyzerManager(new replacedyzerManagerOptions
{
LogWriter = _writer
});
IProjectreplacedyzer projectreplacedyzer = replacedyzerManager.GetProject(WorkspacePath);
Projects.Add(new ProjectreplacedysisResult()
{
Projectreplacedyzer = projectreplacedyzer
});
}
Logger.LogDebug(_sb.ToString());
_writer.Flush();
_writer.Close();
ProcessLog(_writer.ToString());
}
19
View Source File : Log.cs
License : MIT License
Project Creator : AyrA
License : MIT License
Project Creator : AyrA
public static void Close()
{
lock (Logger)
{
if (Logger != TextWriter.Null)
{
var DT = DateTime.UtcNow;
Write("{0} {1}: Logger ended", DT.ToLongDateString(), DT.ToLongTimeString());
Logger.Flush();
Logger.Close();
Logger.Dispose();
Logger = TextWriter.Null;
}
}
}
19
View Source File : Log.cs
License : MIT License
Project Creator : AyrA
License : MIT License
Project Creator : AyrA
public static void Write(Exception ex, bool IsRoot = true)
{
if (ex == null)
{
return;
}
if (IsRoot)
{
Write("=== START: {0} handler ===", ex.GetType().FullName);
}
Write("Error: {0}", ex.Message);
Write("Stack: {0}", ex.StackTrace);
if (ex.Data != null && ex.Data.Count > 0)
{
foreach (var Entry in ex.Data)
{
Write("Data: {0}", Entry);
}
}
if (ex is AggregateException)
{
foreach (var E in ((AggregateException)ex).InnerExceptions)
{
Write(E, false);
}
}
else
{
Write(ex.InnerException, false);
}
if (IsRoot)
{
Write("=== END: {0} handler ===", ex.GetType().FullName);
lock (Logger)
{
//Always flush on exceptions
Logger.Flush();
}
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
public static string EncodeDateTime(DateTime data)
{
using(var wri = new StringWriter())
{
var year = data.Year;
if (year>999) wri.Write(year);
else if (year>99) { wri.Write('0'); wri.Write(year); }
else if (year>9) { wri.Write("00"); wri.Write(year); }
else if (year>0) { wri.Write("000"); wri.Write(year); }
wri.Write('-');
var month = data.Month;
if (month>9) wri.Write(month);
else { wri.Write('0'); wri.Write(month); }
wri.Write('-');
var day = data.Day;
if (day>9) wri.Write(day);
else { wri.Write('0'); wri.Write(day); }
wri.Write('T');
var hour = data.Hour;
if (hour>9) wri.Write(hour);
else { wri.Write('0'); wri.Write(hour); }
wri.Write(':');
var minute = data.Minute;
if (minute>9) wri.Write(minute);
else { wri.Write('0'); wri.Write(minute); }
wri.Write(':');
var second = data.Second;
if (second>9) wri.Write(second);
else { wri.Write('0'); wri.Write(second); }
var ms = data.Millisecond;
if (ms>0)
{
wri.Write('.');
if (ms>99) wri.Write(ms);
else if (ms>9) { wri.Write('0'); wri.Write(ms); }
else { wri.Write("00"); wri.Write(ms); }
}
wri.Write('Z');//UTC
wri.Flush();
return wri.ToString();
}
}
19
View Source File : CommandExecuter.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
public void ExecuteModuleManaged()
{
string output = "";
try
{
StringBuilder myb = new StringBuilder();
StringWriter sw = new StringWriter(myb);
TextWriter oldOut = Console.Out;
Console.SetOut(sw);
Console.SetError(sw);
string clreplacedname;
string replacedembly;
string method;
string[] paramsv;
switch (task.TaskType)
{
case "standard":
clreplacedname = task.StandardTask.Moduleclreplaced;
replacedembly = task.StandardTask.replacedembly;
method = task.StandardTask.Method;
paramsv = task.StandardTask.Parameters;
RedPeanutAgent.Core.Utility.Runreplacedembly(replacedembly, clreplacedname, method, new object[] { paramsv });
break;
case "download":
clreplacedname = task.DownloadTask.Moduleclreplaced;
replacedembly = task.DownloadTask.replacedembly;
method = task.DownloadTask.Method;
paramsv = task.DownloadTask.Parameters;
RedPeanutAgent.Core.Utility.Runreplacedembly(replacedembly, clreplacedname, method, new object[] { paramsv });
break;
case "migrate":
clreplacedname = task.ModuleTask.Moduleclreplaced;
replacedembly = task.ModuleTask.replacedembly;
method = task.ModuleTask.Method;
paramsv = task.ModuleTask.Parameters;
RedPeanutAgent.Core.Utility.Runreplacedembly(replacedembly, clreplacedname, method, new object[] { paramsv });
break;
case "module":
clreplacedname = task.ModuleTask.Moduleclreplaced;
replacedembly = task.ModuleTask.replacedembly;
method = task.ModuleTask.Method;
paramsv = task.ModuleTask.Parameters;
RedPeanutAgent.Core.Utility.Runreplacedembly(replacedembly, clreplacedname, method, new object[] { paramsv });
break;
}
output = myb.ToString();
Console.SetOut(oldOut);
Console.SetError(oldOut);
sw.Flush();
sw.Close();
}
catch (Exception e)
{
if (e.InnerException != null)
{
try
{
Type newextype = Type.GetType(e.InnerException.GetType().FullName);
RedPeanutAgent.Core.Utility.EndOfLifeException newex = (RedPeanutAgent.Core.Utility.EndOfLifeException)Activator.CreateInstance(newextype);
throw newex;
}
catch (InvalidCastException ex)
{
}
catch (ArgumentNullException ex)
{
}
}
output = e.Message;
}
SendResponse(output);
}
19
View Source File : MultiTextWriter.cs
License : The Unlicense
Project Creator : BAndysc
License : The Unlicense
Project Creator : BAndysc
public override void Flush()
{
foreach (System.IO.TextWriter thisWriter in MWriters)
{
thisWriter.Flush();
}
}
19
View Source File : DiskLogListener.cs
License : GNU Lesser General Public License v2.1
Project Creator : BepInEx
License : GNU Lesser General Public License v2.1
Project Creator : BepInEx
public void LogEvent(object sender, LogEventArgs eventArgs)
{
if (LogWriter == null)
return;
if (BlacklistedSources.Contains(eventArgs.Source.SourceName))
return;
if ((eventArgs.Level & DisplayedLogLevel) == 0)
return;
LogWriter.WriteLine(eventArgs.ToString());
if (InstantFlushing)
LogWriter.Flush();
}
See More Examples