Here are the examples of the csharp api System.Console.Write(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5037 Examples
19
Source : Log.cs
with MIT License
from 0ffffffffh
with MIT License
from 0ffffffffh
private static void Write(LogType type, string format, params object[] args)
{
ConsoleColor typeColor,origColor;
ulong mask = (ulong)type;
string log = string.Format(format, args);
logFile.Write(type.ToString() + ": " + log);
if ((logMask & mask) == mask)
{
typeColor = GetColorByLogType(type);
lock (consLock)
{
origColor = Console.ForegroundColor;
Console.ForegroundColor = typeColor;
Console.Write(string.Format("{0}: ", type.ToString()));
Console.ForegroundColor = origColor;
Console.WriteLine(log);
}
}
}
19
Source : PacketDeviceSelector.cs
with MIT License
from 0blu
with MIT License
from 0blu
public static ICaptureDevice AskForPacketDevice()
{
// Retrieve the device list from the local machine
CaptureDeviceList devices = CaptureDeviceList.Instance;
if (devices.Count == 0)
{
throw new Exception("No interfaces found! Make sure WinPcap is installed.");
}
// Print the list
for (int i = 0; i != devices.Count; ++i)
{
ICaptureDevice device = devices[i];
Console.Write((i + 1) + ". ");
if (device.Description != null)
Console.WriteLine(" (" + device.Description + ")");
else
Console.WriteLine(" (No description available)");
}
int deviceIndex;
do
{
Console.WriteLine("Enter the interface number (1-" + devices.Count + "):");
string deviceIndexString = Console.ReadLine();
if (!int.TryParse(deviceIndexString, out deviceIndex) ||
deviceIndex < 1 || deviceIndex > devices.Count)
{
deviceIndex = 0;
}
} while (deviceIndex == 0);
return devices[deviceIndex - 1];
}
19
Source : GetAssemblyVersion.cs
with zlib License
from 0x0ade
with zlib License
from 0x0ade
static void Main(string[] args)
{
Console.Write(replacedembly.LoadFile(args[0]).GetName().Version.ToString());
}
19
Source : XnaToFnaHelper.cs
with zlib License
from 0x0ade
with zlib License
from 0x0ade
public static void Log(string s) {
Console.Write("[XnaToFnaHelper] ");
Console.WriteLine(s);
}
19
Source : XnaToFnaUtil.cs
with zlib License
from 0x0ade
with zlib License
from 0x0ade
public void Log(string txt) {
Console.Write("[XnaToFna] ");
Console.WriteLine(txt);
}
19
Source : Program.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
private static async Task Step4UpdatingData(ISqDatabase database)
{
var tUser = new TableUser();
await Update(tUser)
.Set(tUser.LastName, "Malloy")
.Set(tUser.Version, tUser.Version + 1)
.Set(tUser.ModifiedAt, GetUtcDate())
.Where(tUser.LastName == "Maloy")
.Exec(database);
//Writing to console without storing in memory
await Select(tUser.Columns)
.From(tUser)
.Query(database,
record =>
{
Console.Write(tUser.UserId.Read(record) + ",");
Console.Write(tUser.FirstName.Read(record) + " ");
Console.Write(tUser.LastName.Read(record) + ",");
Console.Write(tUser.Version.Read(record) + ",");
Console.WriteLine(tUser.ModifiedAt.Read(record).ToString("s"));
});
}
19
Source : ScenarioContext.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void Write(string? line)
{
Console.Write(line);
}
19
Source : Program.cs
with GNU General Public License v3.0
from 0x2b00b1e5
with GNU General Public License v3.0
from 0x2b00b1e5
static void GetInfo()
{
Console.WriteLine("Would you like to replace your current shortcuts on your desktop? (Y/N)");
switch (Console.ReadKey().Key)
{
case ConsoleKey.Y:
ReplaceDesktop = true;
break;
case ConsoleKey.N:
ReplaceDesktop = false;
break;
default:
ReplaceDesktop = false;
break;
}
Console.WriteLine("\n Leave blank if you don't want to add shortcuts");
Console.Write("\n Where would you like to write (additonal) shortcuts? Write the full path to the folder, seperate folder paths with a comma (,): ");
string feed = Console.ReadLine();
if (feed != null)
{
WriteShortcuts = feed.Split(',');
}
Console.Write("\n Enter the version number of FL Studio (e.g 20): ");
VersionNumber = Console.ReadLine();
Console.WriteLine("Thank you! \n \n");
}
19
Source : Program.cs
with GNU General Public License v3.0
from 0x2b00b1e5
with GNU General Public License v3.0
from 0x2b00b1e5
static void GetFLPaths()
{
string path = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Image-Line\\Shared\\Paths", "FL Studio", null);
if(path == null)
{
Console.WriteLine("No FL Studio path detected!\n\n");
Console.Write("Please enter full path to the FL Studio executable: ");
string output = Console.ReadLine();
System.Diagnostics.FileVersionInfo FLInf = System.Diagnostics.FileVersionInfo.GetVersionInfo(output);
if (FLInf.ProductName != "FL Studio")
{
Console.WriteLine("\n This file doesn't appear to be a FL Studio executable...try again!");
GetFLPaths();
}
FLStudioPaths = output;
}
else
{
FLStudioPaths = path;
Console.WriteLine(string.Format("Found FL Studio at path: {0}", path));
Console.WriteLine("Correct? (Y/N)");
switch (Console.ReadKey().Key)
{
case ConsoleKey.Y:
break;
case ConsoleKey.N:
Console.Write("Please enter full path to the FL Studio executable: ");
string output = Console.ReadLine();
output.Replace("\"", string.Empty);
System.Diagnostics.FileVersionInfo FLInf = System.Diagnostics.FileVersionInfo.GetVersionInfo(output);
if (FLInf.ProductName != "FL Studio")
{
Console.WriteLine("\n This file doesn't appear to be a FL Studio executable...try again!");
System.Threading.Thread.Sleep(1000);
GetFLPaths();
}
FLStudioPaths = output;
break;
}
}
}
19
Source : CommandLineParser.cs
with MIT License
from 0xd4d
with MIT License
from 0xd4d
public static void ShowHelp() {
var exe = Path.GetFileNameWithoutExtension(replacedembly.GetEntryreplacedembly()!.Location);
var msg = $@"Disreplacedembles jitted methods in .NET processes
-p, --pid <pid> Process id
-pn, --process <name> Process name
-m, --module <name> Name of module to disreplacedemble
-l, --load <module> Load module (for execution) into this process and jit every method
--no-run-cctor Don't run all .cctors before jitting methods (used with -l)
--filename-format <fmt> Filename format. <fmt>:
name => (default) member name
tokname => token + member name
token => token
-f, --file <kind> Output file. <kind>:
stdout => (default) stdout
file => One file, use -o to set filename
type => One file per type, use -o to set directory
method => One file per method, use -o to set directory
-d, --disasm <kind> Disreplacedembler. <kind>:
masm => (default) MASM syntax
nasm => NASM syntax
gas => GNU replacedembler (AT&T) syntax
att => same as gas
intel => Intel (XED) syntax
-o, --output <path> Output filename or directory
--type <tok-or-name> Disreplacedemble this type (wildcards supported) or type token
--type-exclude <tok-or-name> Don't disreplacedemble this type (wildcards supported) or type token
--method <tok-or-name> Disreplacedemble this method (wildcards supported) or method token
--method-exclude <tok-or-name> Don't disreplacedemble this method (wildcards supported) or method token
--diffable Create diffable disreplacedembly
--no-addr Don't show instruction addresses
--no-bytes Don't show instruction bytes
--no-source Don't show source code
--heap-search Check the GC heap for instantiated generic types
-s, --search <path> Add replacedembly search paths (used with -l), {Path.PathSeparator}-delimited
-h, --help Show this help message
<tok-or-name> can be semicolon separated or multiple options can be used. Names support wildcards.
Token ranges are also supported eg. 0x06000001-0x06001234.
Generic methods and methods in generic types aren't 100% supported. Try --heap-search.
Examples:
{exe} -m MyModule -pn myexe -f type -o c:\out\dir --method Decode
{exe} -p 1234 -m System.Private.CoreLib -o C:\out\dir --diffable -f type
{exe} -l c:\path\to\mymodule.dll
";
Console.Write(msg);
}
19
Source : Program.cs
with MIT License
from 0xDivyanshu
with MIT License
from 0xDivyanshu
static void powershell_clm(String file_tmp)
{
Console.WriteLine("[+] Powershell CLM bypreplaced!\n");
Runspace rs = RunspaceFactory.CreateRunspace();
String op_file = file_tmp;
PowerShell ps = PowerShell.Create();
while (true)
{
Console.Write("PS:>");
string input = Console.ReadLine();
if (input == "exit")
{
break;
}
ps.AddScript(input + " | Out-File -FilePath " + op_file);
ps.Invoke();
string output = File.ReadAllText(op_file);
Console.WriteLine(output);
File.Delete(op_file);
}
rs.Close();
}
19
Source : PkgChecker.cs
with MIT License
from 13xforever
with MIT License
from 13xforever
private static void Write(string str, ConsoleColor? color = null)
{
Sync.Wait();
try
{
if (color is ConsoleColor c)
Console.ForegroundColor = c;
Console.Write(str);
if (color.HasValue)
Console.ResetColor();
}
finally
{
Sync.Release();
}
}
19
Source : Program.cs
with MIT License
from 13xforever
with MIT License
from 13xforever
internal static async Task Main(string[] args)
{
try
{
if (args.Length == 0)
{
Console.WriteLine("Drag .pkg files and/or folders onto this .exe to verify the packages.");
var isFirstChar = true;
var completedPath = false;
var path = new StringBuilder();
do
{
var keyInfo = Console.ReadKey(true);
if (isFirstChar)
{
isFirstChar = false;
if (keyInfo.KeyChar != '"')
return;
}
else
{
if (keyInfo.KeyChar == '"')
{
completedPath = true;
args = new[] {path.ToString()};
}
else
path.Append(keyInfo.KeyChar);
}
} while (!completedPath);
Console.Clear();
}
Console.OutputEncoding = new UTF8Encoding(false);
Console.replacedle = replacedle;
Console.CursorVisible = false;
Console.WriteLine("Scanning for PKGs...");
var pkgList = new List<FileInfo>();
Console.ForegroundColor = ConsoleColor.Yellow;
foreach (var item in args)
{
var path = item.Trim('"');
if (File.Exists(path))
pkgList.Add(new FileInfo(path));
else if (Directory.Exists(path))
pkgList.AddRange(GetFilePaths(path, "*.pkg", SearchOption.AllDirectories).Select(p => new FileInfo(p)));
else
Console.WriteLine("Unknown path: " + path);
}
Console.ResetColor();
if (pkgList.Count == 0)
{
Console.WriteLine("No packages were found. Check paths, and try again.");
return;
}
var longestFilename = Math.Max(pkgList.Max(i => i.Name.Length), HeaderPkgName.Length);
var sigWidth = Math.Max(HeaderSignature.Length, 8);
var csumWidth = Math.Max(HeaderChecksum.Length, 5);
var csumsWidth = 1 + sigWidth + 1 + csumWidth + 1;
var idealWidth = longestFilename + csumsWidth;
try
{
if (idealWidth > Console.LargestWindowWidth)
{
longestFilename = Console.LargestWindowWidth - csumsWidth;
idealWidth = Console.LargestWindowWidth;
}
if (idealWidth > Console.WindowWidth)
{
Console.BufferWidth = Math.Max(Console.BufferWidth, idealWidth);
Console.WindowWidth = idealWidth;
}
Console.BufferHeight = Math.Max(Console.BufferHeight, Math.Min(9999, pkgList.Count + 10));
}
catch (PlatformNotSupportedException) { }
Console.WriteLine($"{HeaderPkgName.Trim(longestFilename).PadRight(longestFilename)} {HeaderSignature.PadLeft(sigWidth)} {HeaderChecksum.PadLeft(csumWidth)}");
using var cts = new CancellationTokenSource();
Console.CancelKeyPress += (sender, eventArgs) => { cts.Cancel(); };
var t = new Thread(() =>
{
try
{
var indicatorIdx = 0;
while (!cts.Token.IsCancellationRequested)
{
Task.Delay(1000, cts.Token).ConfigureAwait(false).GetAwaiter().GetResult();
if (cts.Token.IsCancellationRequested)
return;
PkgChecker.Sync.Wait(cts.Token);
try
{
var frame = Animation[(indicatorIdx++) % Animation.Length];
var currentProgress = PkgChecker.CurrentFileProcessedBytes;
Console.replacedle = $"{replacedle} [{(double)(PkgChecker.ProcessedBytes + currentProgress) / PkgChecker.TotalFileSize * 100:0.00}%] {frame}";
if (PkgChecker.CurrentPadding > 0)
{
Console.CursorVisible = false;
var (top, left) = (Console.CursorTop, Console.CursorLeft);
Console.Write($"{(double)currentProgress / PkgChecker.CurrentFileSize * 100:0}%".PadLeft(PkgChecker.CurrentPadding));
Console.CursorTop = top;
Console.CursorLeft = left;
Console.CursorVisible = false;
}
}
finally
{
PkgChecker.Sync.Release();
}
}
}
catch (TaskCanceledException)
{
}
});
t.Start();
await PkgChecker.CheckAsync(pkgList, longestFilename, sigWidth, csumWidth, csumsWidth-2, cts.Token).ConfigureAwait(false);
cts.Cancel(false);
t.Join();
}
finally
{
Console.replacedle = replacedle;
Console.WriteLine("Press any key to exit");
Console.ReadKey();
Console.WriteLine();
Console.CursorVisible = true;
}
}
19
Source : ApplicationBuilderExtensions.cs
with MIT License
from 17MKH
with MIT License
from 17MKH
private static void ConsoleBanner()
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine();
Console.WriteLine(@" ***************************************************************************************************************");
Console.WriteLine(@" * *");
Console.WriteLine(@" * $$\ $$$$$$$$\ $$\ $$\ $$\ $$\ $$\ $$\ *");
Console.WriteLine(@" * $$$$ | \____$$ |$$$\ $$$ |$$ | $$ |$$ | $$ | *");
Console.WriteLine(@" * \_$$ | $$ / $$$$\ $$$$ |$$ |$$ / $$ | $$ | *");
Console.WriteLine(@" * $$ | $$ / $$\$$\$$ $$ |$$$$$ / $$$$$$$$ | *");
Console.WriteLine(@" * $$ | $$ / $$ \$$$ $$ |$$ $$< $$ __$$ | *");
Console.WriteLine(@" * $$ | $$ / $$ |\$ /$$ |$$ |\$$\ $$ | $$ | *");
Console.WriteLine(@" * $$$$$$\ $$ / $$ | \_/ $$ |$$ | \$$\ $$ | $$ | *");
Console.WriteLine(@" * \______|\__/ \__| \__|\__| \__|\__| \__| *");
Console.WriteLine(@" * *");
Console.WriteLine(@" * *");
Console.Write(@" * ");
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(@"启动成功,欢迎使用 17MKH ~");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(@" *");
Console.WriteLine(@" * *");
Console.WriteLine(@" * *");
Console.WriteLine(@" ***************************************************************************************************************");
Console.WriteLine();
}
19
Source : GenerateCommand.cs
with MIT License
from 188867052
with MIT License
from 188867052
private int Initialize()
{
try
{
CommondConfig config = new CommondConfig();
// From console.
if (!string.IsNullOrEmpty(this.ProjectName))
{
string fileFullPath = Directory.GetFiles(".", $"{this.ProjectName}.csproj", SearchOption.AllDirectories).FirstOrDefault();
if (string.IsNullOrEmpty(fileFullPath))
{
System.Console.Write($"Project {this.ProjectName} is not exist.");
return 1;
}
config.ProjectPath = new FileInfo(fileFullPath).DirectoryName;
config.ProjectName = this.ProjectName;
config.GenerateMethod = this.GenerateMethod == "1" || this.GenerateMethod.Equals("true", StringComparison.InvariantCultureIgnoreCase);
}
else
{
// From appsettings.json.
this.ConfigJsonPath = Directory.GetFiles(".", "appsettings.json", SearchOption.AllDirectories).FirstOrDefault();
if (string.IsNullOrEmpty(this.ConfigJsonPath))
{
this.Console.WriteLine("No appsettings.json file found, will generate code with default setting.");
}
string appSettings = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(this.ConfigJsonPath)).RouteGenerator.ToString();
config = JsonConvert.DeserializeObject<CommondConfig>(appSettings);
if (string.IsNullOrEmpty(config.ProjectName))
{
System.Console.Write($"Please provide ProjectName.");
return 1;
}
string fileFullPath = Directory.GetFiles(".", $"{config.ProjectName}.csproj", SearchOption.AllDirectories).FirstOrDefault();
if (string.IsNullOrEmpty(fileFullPath))
{
System.Console.Write($"Project {config.ProjectName} is not exist.");
return 1;
}
config.ProjectPath = new FileInfo(fileFullPath).DirectoryName;
}
this.Config = config;
this.Console.WriteLine(JsonConvert.SerializeObject(config, Formatting.Indented));
if (string.IsNullOrEmpty(this.Config.OutPutFile))
{
this.Config.OutPutFile = "Routes.Generated.cs";
}
if (!this.Config.OutPutFile.EndsWith(".cs"))
{
this.Config.OutPutFile += ".cs";
}
if (string.IsNullOrEmpty(this.Config.ProjectName))
{
this.Console.WriteLine($"Please provide ProjectName.");
return 1;
}
}
catch (Exception ex)
{
this.Console.WriteLine("Read config file error.");
this.Console.WriteLine(ex.Message);
this.Console.WriteLine(ex.StackTrace);
return 1;
}
return 0;
}
19
Source : rotations.cs
with MIT License
from 1CM69
with MIT License
from 1CM69
private static void testrotations()
{
double[,] numArray1 = new double[0, 0];
double[,] numArray2 = new double[0, 0];
double[,] numArray3 = new double[0, 0];
double[,] numArray4 = new double[0, 0];
double[] numArray5 = new double[0];
double[] numArray6 = new double[0];
double[] numArray7 = new double[0];
double[] numArray8 = new double[0];
double[] numArray9 = new double[0];
int num1 = 1000;
double val2_1 = 0.0;
for (int index1 = 1; index1 <= num1; ++index1)
{
int num2 = 2 + AP.Math.RandomInteger(50);
int num3 = 2 + AP.Math.RandomInteger(50);
bool isforward = AP.Math.RandomReal() > 0.5;
int num4 = System.Math.Max(num2, num3);
double[,] a1 = new double[num2 + 1, num3 + 1];
double[,] a2 = new double[num2 + 1, num3 + 1];
double[,] a3 = new double[num2 + 1, num3 + 1];
double[,] a4 = new double[num2 + 1, num3 + 1];
double[] c1 = new double[num2 - 1 + 1];
double[] s1 = new double[num2 - 1 + 1];
double[] c2 = new double[num3 - 1 + 1];
double[] s2 = new double[num3 - 1 + 1];
double[] work = new double[num4 + 1];
for (int index2 = 1; index2 <= num2; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
{
a1[index2, index3] = 2.0 * AP.Math.RandomReal() - 1.0;
a2[index2, index3] = a1[index2, index3];
a3[index2, index3] = a1[index2, index3];
a4[index2, index3] = a1[index2, index3];
}
}
for (int index2 = 1; index2 <= num2 - 1; ++index2)
{
double num5 = 2.0 * System.Math.PI * AP.Math.RandomReal();
c1[index2] = System.Math.Cos(num5);
s1[index2] = System.Math.Sin(num5);
}
for (int index2 = 1; index2 <= num3 - 1; ++index2)
{
double num5 = 2.0 * System.Math.PI * AP.Math.RandomReal();
c2[index2] = System.Math.Cos(num5);
s2[index2] = System.Math.Sin(num5);
}
rotations.applyrotationsfromtheleft(isforward, 1, num2, 1, num3, ref c1, ref s1, ref a1, ref work);
for (int index2 = 1; index2 <= num3; ++index2)
rotations.applyrotationsfromtheleft(isforward, 1, num2, index2, index2, ref c1, ref s1, ref a2, ref work);
double val1_1 = 0.0;
for (int index2 = 1; index2 <= num2; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
val1_1 = System.Math.Max(val1_1, System.Math.Abs(a1[index2, index3] - a2[index2, index3]));
}
double val2_2 = System.Math.Max(val1_1, val2_1);
rotations.applyrotationsfromtheright(isforward, 1, num2, 1, num3, ref c2, ref s2, ref a3, ref work);
for (int index2 = 1; index2 <= num2; ++index2)
rotations.applyrotationsfromtheright(isforward, index2, index2, 1, num3, ref c2, ref s2, ref a4, ref work);
double val1_2 = 0.0;
for (int index2 = 1; index2 <= num2; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
val1_2 = System.Math.Max(val1_2, System.Math.Abs(a3[index2, index3] - a4[index2, index3]));
}
val2_1 = System.Math.Max(val1_2, val2_2);
}
Console.Write("TESTING ROTATIONS");
Console.WriteLine();
Console.Write("Preplaced count ");
Console.Write("{0,0:d}", (object) num1);
Console.WriteLine();
Console.Write("Error is ");
Console.Write("{0,5:E3}", (object) val2_1);
Console.WriteLine();
}
19
Source : reflections.cs
with MIT License
from 1CM69
with MIT License
from 1CM69
private static void testreflections()
{
double[] numArray1 = new double[0];
double[] numArray2 = new double[0];
double[] numArray3 = new double[0];
double[,] numArray4 = new double[0, 0];
double[,] numArray5 = new double[0, 0];
double[,] numArray6 = new double[0, 0];
double[,] numArray7 = new double[0, 0];
double num1 = 0.0;
double tau = 0.0;
int num2 = 1000;
double val1_1 = 0.0;
double val1_2 = 0.0;
double val1_3 = 0.0;
for (int index1 = 1; index1 <= num2; ++index1)
{
int num3 = 1 + AP.Math.RandomInteger(10);
int num4 = 1 + AP.Math.RandomInteger(10);
int num5 = System.Math.Max(num4, num3);
double[] numArray8 = new double[num5 + 1];
double[] numArray9 = new double[num5 + 1];
double[] work = new double[num5 + 1];
double[,] numArray10 = new double[num5 + 1, num5 + 1];
double[,] numArray11 = new double[num5 + 1, num5 + 1];
double[,] c = new double[num5 + 1, num5 + 1];
double[,] numArray12 = new double[num5 + 1, num5 + 1];
for (int index2 = 1; index2 <= num3; ++index2)
{
numArray8[index2] = 2.0 * AP.Math.RandomReal() - 1.0;
numArray9[index2] = numArray8[index2];
}
reflections.generatereflection(ref numArray9, num3, ref tau);
double num6 = numArray9[1];
numArray9[1] = 1.0;
for (int index2 = 1; index2 <= num3; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
numArray10[index2, index3] = index2 != index3 ? -(tau * numArray9[index2] * numArray9[index3]) : 1.0 - tau * numArray9[index2] * numArray9[index3];
}
double num7 = 0.0;
for (int index2 = 1; index2 <= num3; ++index2)
{
double num8 = 0.0;
for (int index3 = 1; index3 <= num3; ++index3)
num8 += numArray10[index2, index3] * numArray8[index3];
num7 = index2 != 1 ? System.Math.Max(num7, System.Math.Abs(num8)) : System.Math.Max(num7, System.Math.Abs(num8 - num6));
}
val1_3 = System.Math.Max(val1_3, num7);
for (int index2 = 1; index2 <= num4; ++index2)
{
numArray8[index2] = 2.0 * AP.Math.RandomReal() - 1.0;
numArray9[index2] = numArray8[index2];
}
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
{
numArray11[index2, index3] = 2.0 * AP.Math.RandomReal() - 1.0;
c[index2, index3] = numArray11[index2, index3];
}
}
reflections.generatereflection(ref numArray9, num4, ref tau);
num1 = numArray9[1];
numArray9[1] = 1.0;
reflections.applyreflectionfromtheleft(ref c, tau, ref numArray9, 1, num4, 1, num3, ref work);
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num4; ++index3)
numArray10[index2, index3] = index2 != index3 ? -(tau * numArray9[index2] * numArray9[index3]) : 1.0 - tau * numArray9[index2] * numArray9[index3];
}
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
{
double num8 = 0.0;
for (int index4 = 1; index4 <= num4; ++index4)
num8 += numArray10[index2, index4] * numArray11[index4, index3];
numArray12[index2, index3] = num8;
}
}
double num9 = 0.0;
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
num9 = System.Math.Max(num9, System.Math.Abs(c[index2, index3] - numArray12[index2, index3]));
}
val1_2 = System.Math.Max(val1_2, num9);
for (int index2 = 1; index2 <= num3; ++index2)
{
numArray8[index2] = 2.0 * AP.Math.RandomReal() - 1.0;
numArray9[index2] = numArray8[index2];
}
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
{
numArray11[index2, index3] = 2.0 * AP.Math.RandomReal() - 1.0;
c[index2, index3] = numArray11[index2, index3];
}
}
reflections.generatereflection(ref numArray9, num3, ref tau);
num1 = numArray9[1];
numArray9[1] = 1.0;
reflections.applyreflectionfromtheright(ref c, tau, ref numArray9, 1, num4, 1, num3, ref work);
for (int index2 = 1; index2 <= num3; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
numArray10[index2, index3] = index2 != index3 ? -(tau * numArray9[index2] * numArray9[index3]) : 1.0 - tau * numArray9[index2] * numArray9[index3];
}
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
{
double num8 = 0.0;
for (int index4 = 1; index4 <= num3; ++index4)
num8 += numArray11[index2, index4] * numArray10[index4, index3];
numArray12[index2, index3] = num8;
}
}
double num10 = 0.0;
for (int index2 = 1; index2 <= num4; ++index2)
{
for (int index3 = 1; index3 <= num3; ++index3)
num10 = System.Math.Max(num10, System.Math.Abs(c[index2, index3] - numArray12[index2, index3]));
}
val1_1 = System.Math.Max(val1_1, num10);
}
numArray1 = new double[11];
double[] x = new double[11];
for (int index = 1; index <= 10; ++index)
x[index] = 1E+298 * (2.0 * AP.Math.RandomReal() - 1.0);
reflections.generatereflection(ref x, 10, ref tau);
Console.Write("TESTING REFLECTIONS");
Console.WriteLine();
Console.Write("Preplaced count is ");
Console.Write("{0,0:d}", (object) num2);
Console.WriteLine();
Console.Write("Generate absolute error is ");
Console.Write("{0,5:E3}", (object) val1_3);
Console.WriteLine();
Console.Write("Apply(Left) absolute error is ");
Console.Write("{0,5:E3}", (object) val1_2);
Console.WriteLine();
Console.Write("Apply(Right) absolute error is ");
Console.Write("{0,5:E3}", (object) val1_1);
Console.WriteLine();
Console.Write("Overflow crash test preplaceded");
Console.WriteLine();
}
19
Source : ObjectPool.cs
with MIT License
from 2881099
with MIT License
from 2881099
private void RestoreToAvailable()
{
bool isRestored = false;
if (UnavailableException != null)
{
lock (UnavailableLock)
{
if (UnavailableException != null)
{
UnavailableException = null;
UnavailableTime = null;
isRestored = true;
}
}
}
if (isRestored)
{
lock (_allObjectsLock)
_allObjects.ForEach(a => a.LastGetTime = a.LastReturnTime = new DateTime(2000, 1, 1));
Policy.OnAvailable();
var bgcolor = Console.BackgroundColor;
var forecolor = Console.ForegroundColor;
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"【{Policy.Name}】已恢复工作");
Console.BackgroundColor = bgcolor;
Console.ForegroundColor = forecolor;
Console.WriteLine();
}
}
19
Source : ObjectPool.cs
with MIT License
from 2881099
with MIT License
from 2881099
private void CheckAvailable(int interval)
{
new Thread(() =>
{
if (UnavailableException != null)
{
var bgcolor = Console.BackgroundColor;
var forecolor = Console.ForegroundColor;
Console.BackgroundColor = ConsoleColor.DarkYellow;
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"【{Policy.Name}】恢复检查时间:{DateTime.Now.AddSeconds(interval)}");
Console.BackgroundColor = bgcolor;
Console.ForegroundColor = forecolor;
Console.WriteLine();
}
while (UnavailableException != null)
{
if (running == false) return;
Thread.CurrentThread.Join(TimeSpan.FromSeconds(interval));
if (running == false) return;
try
{
var conn = getFree(false);
if (conn == null) throw new Exception($"CheckAvailable 无法获得资源,{this.Statistics}");
try
{
if (Policy.OnCheckAvailable(conn) == false) throw new Exception("CheckAvailable 应抛出异常,代表仍然不可用。");
break;
}
finally
{
Return(conn);
}
}
catch (Exception ex)
{
var bgcolor = Console.BackgroundColor;
var forecolor = Console.ForegroundColor;
Console.BackgroundColor = ConsoleColor.DarkYellow;
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"【{Policy.Name}】仍然不可用,下一次恢复检查时间:{DateTime.Now.AddSeconds(interval)},错误:({ex.Message})");
Console.BackgroundColor = bgcolor;
Console.ForegroundColor = forecolor;
Console.WriteLine();
}
}
RestoreToAvailable();
}).Start();
}
19
Source : Form1.cs
with Apache License 2.0
from 214175590
with Apache License 2.0
from 214175590
private void button1_Click(object sender, EventArgs e)
{
try
{
string host = tb_host.Text;
string acc = tb_acc.Text;
string pwd = tb_pwd.Text;
shell = new SshShell(host, acc, pwd);
//shell.RedirectToConsole();
shell.Connect(22);
m_Channel = shell.getChannel();
string line = null;
ThreadPool.QueueUserWorkItem((a) =>
{
while (shell.ShellOpened)
{
System.Threading.Thread.Sleep(100);
while ((line = m_Channel.GetMessage()) != null)
{
ShowLogger(line);
}
}
Console.Write("Disconnecting...");
shell.Close();
Console.WriteLine("OK");
});
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
19
Source : ObjectPool.cs
with MIT License
from 2881099
with MIT License
from 2881099
internal static void WriteLine(string text, ConsoleColor backgroundColor)
{
try
{
var bgcolor = Console.BackgroundColor;
var forecolor = Console.ForegroundColor;
Console.BackgroundColor = backgroundColor;
switch (backgroundColor)
{
case ConsoleColor.DarkYellow:
Console.ForegroundColor = ConsoleColor.White;
break;
case ConsoleColor.DarkGreen:
Console.ForegroundColor = ConsoleColor.White;
break;
}
Console.Write(text);
Console.BackgroundColor = bgcolor;
Console.ForegroundColor = forecolor;
Console.WriteLine();
}
catch
{
try
{
System.Diagnostics.Debug.WriteLine(text);
}
catch { }
}
}
19
Source : Program.cs
with MIT License
from 2881099
with MIT License
from 2881099
static void Main(string[] args) {
fsql.CodeFirst.SyncStructure(typeof(Song), typeof(Song_tag), typeof(Tag));
//sugar.CodeFirst.InitTables(typeof(Song), typeof(Song_tag), typeof(Tag));
//sugar创建表失败:SqlSugar.SqlSugarException: Sequence contains no elements
//测试前清空数据
fsql.Delete<Song>().Where(a => a.Id > 0).ExecuteAffrows();
sugar.Deleteable<Song>().Where(a => a.Id > 0).ExecuteCommand();
fsql.Ado.ExecuteNonQuery("delete from efcore_song");
var sql = fsql.Select<Song>().Where(a => a.Id == int.Parse("55")).ToSql();
var sb = new StringBuilder();
Console.WriteLine("插入性能:");
//Insert(sb, 1000, 1);
//Console.Write(sb.ToString());
//sb.Clear();
//Insert(sb, 1000, 10);
//Console.Write(sb.ToString());
//sb.Clear();
Insert(sb, 1, 1000);
Console.Write(sb.ToString());
sb.Clear();
Insert(sb, 1, 10000);
Console.Write(sb.ToString());
sb.Clear();
Insert(sb, 1, 50000);
Console.Write(sb.ToString());
sb.Clear();
Insert(sb, 1, 100000);
Console.Write(sb.ToString());
sb.Clear();
Console.WriteLine("查询性能:");
Select(sb, 1000, 1);
Console.Write(sb.ToString());
sb.Clear();
Select(sb, 1000, 10);
Console.Write(sb.ToString());
sb.Clear();
Select(sb, 1, 1000);
Console.Write(sb.ToString());
sb.Clear();
Select(sb, 1, 10000);
Console.Write(sb.ToString());
sb.Clear();
Select(sb, 1, 50000);
Console.Write(sb.ToString());
sb.Clear();
Select(sb, 1, 100000);
Console.Write(sb.ToString());
sb.Clear();
Console.WriteLine("更新:");
Update(sb, 1000, 1);
Console.Write(sb.ToString());
sb.Clear();
Update(sb, 1000, 10);
Console.Write(sb.ToString());
sb.Clear();
Update(sb, 1, 1000);
Console.Write(sb.ToString());
sb.Clear();
Update(sb, 1, 10000);
Console.Write(sb.ToString());
sb.Clear();
Update(sb, 1, 50000);
Console.Write(sb.ToString());
sb.Clear();
Update(sb, 1, 100000);
Console.Write(sb.ToString());
sb.Clear();
Console.WriteLine("测试结束,按任意键退出...");
Console.ReadKey();
}
19
Source : Program.cs
with MIT License
from 3583Bytes
with MIT License
from 3583Bytes
private static void MakeEngineMove(Engine engine)
{
DateTime start = DateTime.Now;
engine.AiPonderMove();
MoveContent lastMove = engine.GetMoveHistory().ToArray()[0];
string tmp = "";
var sourceColumn = (byte)(lastMove.MovingPiecePrimary.SrcPosition % 8);
var srcRow = (byte)(8 - (lastMove.MovingPiecePrimary.SrcPosition / 8));
var destinationColumn = (byte)(lastMove.MovingPiecePrimary.DstPosition % 8);
var destinationRow = (byte)(8 - (lastMove.MovingPiecePrimary.DstPosition / 8));
tmp += GetPgnMove(lastMove.MovingPiecePrimary.PieceType);
if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Knight)
{
tmp += GetColumnFromInt(sourceColumn + 1);
tmp += srcRow;
}
else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Rook)
{
tmp += GetColumnFromInt(sourceColumn + 1);
tmp += srcRow;
}
else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Pawn)
{
if (sourceColumn != destinationColumn)
{
tmp += GetColumnFromInt(sourceColumn + 1);
}
}
if (lastMove.TakenPiece.PieceType != ChessPieceType.None)
{
tmp += "x";
}
tmp += GetColumnFromInt(destinationColumn + 1);
tmp += destinationRow;
if (lastMove.PawnPromotedTo == ChessPieceType.Queen)
{
tmp += "=Q";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Rook)
{
tmp += "=R";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Knight)
{
tmp += "=K";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Bishop)
{
tmp += "=B";
}
DateTime end = DateTime.Now;
TimeSpan ts = end - start;
Console.Write(engine.PlyDepthReached + " ");
int score = engine.GetScore();
if (score > 0)
{
score = score / 10;
}
Console.Write(score + " ");
Console.Write(ts.Seconds * 100 + " ");
Console.Write(engine.NodesSearched + engine.NodesQuiessence + " ");
Console.Write(engine.PvLine);
Console.WriteLine();
Console.Write("move ");
Console.WriteLine(tmp);
}
19
Source : Program.cs
with MIT License
from 3583Bytes
with MIT License
from 3583Bytes
private static void DrawBoard(Engine engine)
{
//Console.Clear();
for (byte i = 0; i < 64; i++)
{
if (i % 8 == 0)
{
Console.WriteLine();
Console.WriteLine(" ---------------------------------");
Console.Write((8 - (i / 8)));
}
ChessPieceType PieceType = engine.GetPieceTypeAt(i);
ChessPieceColor PieceColor = engine.GetPieceColorAt(i);
string str;
switch (PieceType)
{
case ChessPieceType.Pawn:
{
str = "| " + "P ";
break;
}
case ChessPieceType.Knight:
{
str = "| " + "N ";
break;
}
case ChessPieceType.Bishop:
{
str = "| " + "B ";
break;
}
case ChessPieceType.Rook:
{
str = "| " + "R ";
break;
}
case ChessPieceType.Queen:
{
str = "| " + "Q ";
break;
}
case ChessPieceType.King:
{
str = "| " + "K ";
break;
}
default:
{
str = "| " + " ";
break;
}
}
if (PieceColor == ChessPieceColor.Black)
{
str = str.ToLower();
}
Console.Write(str);
if (i % 8 == 7)
{
Console.Write("|");
}
}
Console.WriteLine();
Console.WriteLine(" ---------------------------------");
Console.WriteLine(" A B C D E F G H");
}
19
Source : Program.cs
with MIT License
from 3583Bytes
with MIT License
from 3583Bytes
private static void MakeEngineMove(Engine engine)
{
DateTime start = DateTime.Now;
engine.AiPonderMove();
MoveContent lastMove = engine.GetMoveHistory().ToArray()[0];
string tmp = "";
var sourceColumn = (byte)(lastMove.MovingPiecePrimary.SrcPosition % 8);
var srcRow = (byte)(8 - (lastMove.MovingPiecePrimary.SrcPosition / 8));
var destinationColumn = (byte)(lastMove.MovingPiecePrimary.DstPosition % 8);
var destinationRow = (byte)(8 - (lastMove.MovingPiecePrimary.DstPosition / 8));
tmp += GetPgnMove(lastMove.MovingPiecePrimary.PieceType);
if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Knight)
{
tmp += GetColumnFromInt(sourceColumn + 1);
tmp += srcRow;
}
else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Rook)
{
tmp += GetColumnFromInt(sourceColumn + 1);
tmp += srcRow;
}
else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Pawn)
{
if (sourceColumn != destinationColumn)
{
tmp += GetColumnFromInt(sourceColumn + 1);
}
}
if (lastMove.TakenPiece.PieceType != ChessPieceType.None)
{
tmp += "x";
}
tmp += GetColumnFromInt(destinationColumn + 1);
tmp += destinationRow;
if (lastMove.PawnPromotedTo == ChessPieceType.Queen)
{
tmp += "=Q";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Rook)
{
tmp += "=R";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Knight)
{
tmp += "=K";
}
else if (lastMove.PawnPromotedTo == ChessPieceType.Bishop)
{
tmp += "=B";
}
DateTime end = DateTime.Now;
TimeSpan ts = end - start;
Console.Write(engine.PlyDepthReached + " ");
int score = engine.GetScore();
if (score > 0)
{
score = score / 10;
}
Console.Write(score + " ");
Console.Write(ts.Seconds * 100 + " ");
Console.Write(engine.NodesSearched + engine.NodesQuiessence + " ");
Console.Write(engine.PvLine);
Console.WriteLine();
Console.Write("move ");
Console.WriteLine(tmp);
}
19
Source : Program.cs
with GNU General Public License v3.0
from 3xpl01tc0d3r
with GNU General Public License v3.0
from 3xpl01tc0d3r
private static async Task RunAsync()
{
AuthenticationResult result = null;
result = await Auth();
DateTime exp = result.ExpiresOn.DateTime;
if (result != null)
{
var pageid = await GetPageID(result.AccessToken);
while (true)
{
Console.Write("#> ");
string input = null;
input = Console.ReadLine().Trim();
while (input != null && input != "")
{
int exptime = DateTime.Compare(exp, DateTime.Now.ToUniversalTime().AddMinutes(10));
if (exptime < 0)
{
result = await Auth();
exp = result.ExpiresOn.DateTime;
}
await CreateTask(result.AccessToken, pageid,input);
input = null;
Thread.Sleep(2000);
}
}
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from 3xpl01tc0d3r
with GNU General Public License v3.0
from 3xpl01tc0d3r
private static async Task RunAsync()
{
try
{
AuthenticationResult result = null;
result = await Auth();
DateTime exp = result.ExpiresOn.DateTime;
if (result != null)
{
string userid = await GetUserID(result.AccessToken, ConfigurationManager.AppSettings["User"].ToString());
string mailfolderid = await GetFolderID(result.AccessToken, userid, ConfigurationManager.AppSettings["FolderName"].ToString());
while (true)
{
Console.Write("#> ");
string input = null;
input = Console.ReadLine().Trim();
while (input != null && input != "")
{
int exptime = DateTime.Compare(exp, DateTime.Now.ToUniversalTime().AddMinutes(10));
if (exptime < 0)
{
result = await Auth();
exp = result.ExpiresOn.DateTime;
}
await SendMessage(result.AccessToken, userid, mailfolderid, input);
Thread.Sleep(2000);
string output = null;
while (output == null)
{
output = await ReadMessage(result.AccessToken, userid, mailfolderid);
if (output != null & output != "")
{
Console.WriteLine(output);
}
}
input = null;
}
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
19
Source : SocketServiceImpl.cs
with MIT License
from 499116344
with MIT License
from 499116344
public void ReceiveVerifyCode(byte[] data)
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "yanzhengma");
var img = ImageHelper.CreateImageFromBytes(path, data);
Console.Write($"请输入验证码({img}):");
var code = Console.ReadLine();
if (!string.IsNullOrEmpty(code))
{
Send(new Send_0X00Ba(_user, code));
}
}
19
Source : Send_0x0002.cs
with MIT License
from 499116344
with MIT License
from 499116344
public void HttpUpLoadGroupImg(long groupNum, string ukey, string fileName)
{
using (var webclient = new WebClient())
{
var file = new FileStream(fileName, FileMode.Open);
var apiUrl =
$"http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver=5515&term=pc&ukey={ukey}&filesize={file.Length}&range=0&uin{User.QQ}&&groupcode={groupNum}";
webclient.Headers["User-Agent"] = "QQClient";
webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
var result = webclient.UploadData(apiUrl,
file.ToBytesArray());
Console.Write(Encoding.UTF8.GetString(result));
}
}
19
Source : Program.cs
with MIT License
from 6tail
with MIT License
from 6tail
static void Main(string[] args)
{
// ����
Solar solar = new Solar(2020, 5, 26, 23, 42, 0);
Console.WriteLine(solar);
Console.WriteLine(solar.toFullString());
// ����
Lunar lunar = solar.getLunar();
Console.WriteLine(lunar);
Console.WriteLine(lunar.toFullString());
// ����
EightChar baZi = lunar.getEightChar();
Console.WriteLine(baZi.getYear() + " " + baZi.getMonth() + " " + baZi.getDay() + " " + baZi.getTime());
// ��������
Console.WriteLine(baZi.getYearNaYin() + " " + baZi.getMonthNaYin() + " " + baZi.getDayNaYin() + " " + baZi.getTimeNaYin());
// ��������
Console.WriteLine(baZi.getYearWuXing() + " " + baZi.getMonthWuXing() + " " + baZi.getDayWuXing() + " " + baZi.getTimeWuXing());
// �������ʮ��
Console.WriteLine(baZi.getYearShiShenGan() + " " + baZi.getMonthShiShenGan() + " " + baZi.getDayShiShenGan() + " " + baZi.getTimeShiShenGan());
// ���ֵ�֧ʮ��
Console.WriteLine(baZi.getYearShiShenZhi()[0] + " " + baZi.getMonthShiShenZhi()[0] + " " + baZi.getDayShiShenZhi()[0] + " " + baZi.getTimeShiShenZhi()[0]);
// ������֧ʮ��
foreach (string s in baZi.getYearShiShenZhi())
{
Console.Write(s + " ");
}
Console.WriteLine();
// ������֧ʮ��
foreach (string s in baZi.getMonthShiShenZhi())
{
Console.Write(s + " ");
}
Console.WriteLine();
// ������֧ʮ��
foreach (string s in baZi.getDayShiShenZhi())
{
Console.Write(s + " ");
}
Console.WriteLine();
// ����ʱ֧ʮ��
foreach (string s in baZi.getTimeShiShenZhi())
{
Console.Write(s + " ");
}
Console.WriteLine();
// ����̥Ԫ
Console.WriteLine(baZi.getTaiYuan());
// ��������
Console.WriteLine(baZi.getMingGong());
// �������
Console.WriteLine(baZi.getShenGong());
Console.WriteLine();
solar = new Solar(1988, 3, 20, 18, 0, 0);
lunar = solar.getLunar();
EightChar bazi = lunar.getEightChar();
// ����
Yun yun = bazi.getYun(1);
Console.WriteLine("����" + solar.toYmdHms() + "����");
Console.WriteLine("����" + yun.getStartYear() + "��" + yun.getStartMonth() + "����" + yun.getStartDay() + "�������");
Console.WriteLine("����" + yun.getStartSolar().toYmd() + "������");
Console.WriteLine();
// �ڼ���
List<Holiday> holidays = HolidayUtil.getHolidays(2012);
foreach (Holiday holiday in holidays)
{
Console.WriteLine(holiday);
}
Console.WriteLine();
// ����ת����
List<Solar> solars = Solar.fromBaZi("����", "����", "��î", "����");
foreach (Solar d in solars)
{
Console.WriteLine(d.toFullString());
}
Console.WriteLine();
Console.ReadLine();
}
19
Source : Task001.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public static void Execute()
{
var allTables = new ToolsService().GetAllTables();
var solutionName = "Meiam.System";
foreach (var table in allTables)
{
Console.Write($"生成[{ table }]表 模型: ");
Console.WriteLine(new ToolsService().CreateModels($"..\\..\\..\\..\\{ solutionName }.Model\\Enreplacedy", solutionName , table, ""));
Console.Write($"生成[{ table }]表 服务: ");
Console.WriteLine(new ToolsService().CreateServices($"..\\..\\..\\..\\{ solutionName }.Interfaces\\Service", solutionName , table));
Console.Write($"生成[{ table }]表 接口: ");
Console.WriteLine(new ToolsService().CreateIServices($"..\\..\\..\\..\\{ solutionName }.Interfaces\\IService", solutionName, table));
}
//Console.Write($"生成DbContext: ");
//Console.WriteLine(new ToolsService().CreateDbContext($"..\\..\\..\\..\\{ solutionName }.Core\\DbContext.cs", solutionName));
}
19
Source : Program.cs
with MIT License
from 8x8
with MIT License
from 8x8
static void Main(string[] args)
{
try
{
/// Read private key from file.
var rsaPrivateKey = ReadPrivateKeyFromFile("./rsa-private.pk", PKType.PKCS8);
/// Create new JaaSJwtBuilder and setup the claims and sign using the private key.
var token = JaaSJwtBuilder.Builder()
.WithDefaults()
.WithApiKey("my api key")
.WithUserName("my user name")
.WithUserEmail("my user email")
.WithUserAvatar("https://avatarurl.com/avatar/url")
.WithAppID("my AppID")
.SignWith(rsaPrivateKey);
/// Write JaaS JWT to standard output.
Console.Write(token);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
19
Source : ToolsMain.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
static void Main(string[] args)
{
do
{
try
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("=============================================================================");
Console.WriteLine("* 1 - 生成模型");
Console.WriteLine("=============================================================================");
Console.Write("请选择要执行的程序 : ");
Console.ResetColor();
switch (Int32.Parse(Console.ReadLine()))
{
case 1:
#region 生成模型
Task001.Execute();
#endregion
Console.ReadKey();
break;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadKey();
}
} while (true);
}
19
Source : DesktopAPI.cs
with MIT License
from 944095635
with MIT License
from 944095635
public static IntPtr FindWorkerWPtr()
{
IntPtr workerw = IntPtr.Zero;
IntPtr def = IntPtr.Zero;
IntPtr intPtr = NativeMethods.FindWindow("Progman", null);
//http://blog.csdn.net/whatday/article/details/8714573
IntPtr zeroResult = IntPtr.Zero;
//遍历窗体
NativeMethods.EnumWindows(delegate (IntPtr handle, IntPtr param)
{
//TODO 双屏问题
//参考:http://blog.csdn.net/zhoufoxcn/article/details/2515753,获取墙纸的窗体下面的一个窗体句柄
if ((def = NativeMethods.FindWindowEx(handle, IntPtr.Zero, "SHELLDLL_DefView", IntPtr.Zero)) != IntPtr.Zero)
{
workerw = NativeMethods.FindWindowEx(IntPtr.Zero, handle, "WorkerW", IntPtr.Zero);
//得到
Console.Write("workerw:" + workerw + "\n");
NativeMethods.ShowWindow(workerw, 0);
}
return true;
}, IntPtr.Zero);
return intPtr;
}
19
Source : Program.cs
with MIT License
from a-luna
with MIT License
from a-luna
private static async Task TestProgressBar(ConsoleProgressBar progress, int num)
{
Console.Write($"{num}. Performing some task... ");
using (progress)
{
for (var i = 0; i <= 150; i++)
{
progress.Report((double) i / 150);
await Task.Delay(20);
}
progress.Report(1);
await Task.Delay(200);
}
Console.WriteLine();
}
19
Source : Program.cs
with MIT License
from a-luna
with MIT License
from a-luna
private static async Task TestFileTransferProgressBar(FileTransferProgressBar progress, long fileSize, int num)
{
Console.Write($"{num}. File transfer in progress... ");
using (progress)
{
for (var i = 0; i <= 150; i++)
{
progress.BytesReceived = i * (fileSize / 150);
progress.Report((double) i / 150);
await Task.Delay(20);
}
progress.BytesReceived = fileSize;
progress.Report(1);
await Task.Delay(200);
}
Console.WriteLine();
}
19
Source : Program.cs
with MIT License
from a-luna
with MIT License
from a-luna
private static async Task TestFileTransferStalled(FileTransferProgressBar progress, long fileSize, int num)
{
Console.Write($"{num}. File transfer in progress... ");
using (progress)
{
for (var i = 0; i <= 110; i++)
{
progress.BytesReceived = i * (fileSize / 1000);
progress.Report((double) i / 1000);
await Task.Delay(2);
}
await Task.Delay(6000);
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
public static void Debug(string source, string message, Event type = Event.Default)
{
DumpText += $"[ {DateTime.Now}]\t{source}: {message}\r\n";
if (DumpText.Length > 500000 && AllowFileDebugging == -1)
{
if (MessageBox.Show("The internal debugger has detected that log contents are greater than 500kB," +
" would you like debugging to continue anyway?", "Large File Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
== DialogResult.No)
AllowFileDebugging = 0;
else
AllowFileDebugging = 1;
}
Console.Write($"[ {DateTime.Now}]\t");
AdjustColor(type);
Console.Write($"{source}: {message}\r\n");
Console.ForegroundColor = Default;
}
19
Source : Program.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
public static void Debug(string message, Event type = Event.Default)
{
DumpText += $"[ {DateTime.Now}]\t{message}\r\n";
if (DumpText.Length > 500000 && AllowFileDebugging == -1)
{
if (MessageBox.Show("The internal debugger has detected that log contents are greater than 500kB," +
" would you like debugging to continue anyway?", "Large File Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
== DialogResult.No)
AllowFileDebugging = 0;
else
AllowFileDebugging = 1;
}
Console.Write($"[ {DateTime.Now}]\t");
AdjustColor(type);
Console.Write($"{message}\r\n");
Console.ForegroundColor = Default;
}
19
Source : Program.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
[STAThread]
static void Main(string[] argv)
{
if (argv.Any(o => o.Contains("--debug") || o.Contains("-d")))
{
NativeMethods.AllocConsole();
Default = Console.ForegroundColor;
DebugMode = true;
Console.replacedle = "Espressif Flash Manager - Debugging Console";
}
AllowFileDebugging = -1;
Debug("Application init.");
if (argv.Any(o => o.Contains("--fixdriver") || o.Contains("-fd")))
{
Debug("Program executed with --fixdriver flag. Device picker will be disabled and esptool will autodetect" +
" in order to mitigate access denied error messages.");
Settings.PortFix = true;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
if (argv.Any(o => o.Contains("--portable") || o.Contains("-p")))
{
Portable = true;
Debug("Program executed with the --portable flag which removes the need for Python and the esptool module" +
" and instead uses a precompiled (outdated) copy of the esptool.", Event.Warning);
Debug("You are warned that using untrusted executables not provided by N2D22 exposes your computer system" +
" to security risks. It's recommended that you do not use this mode and instead use the Python utility.", Event.Warning);
if (!File.Exists("esptool.exe"))
{
Debug("Could not find a matching file for esptool.exe in the current working directory.", Event.Critical);
OpenFileDialog fileDialog = new OpenFileDialog()
{
Multiselect = false,
SupportMultiDottedExtensions = true,
Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*",
replacedle = "Browse for esptool binary",
};
if (fileDialog.ShowDialog() == DialogResult.OK)
Settings.EsptoolExe = fileDialog.FileName;
else
Terminate();
}
else
Settings.EsptoolExe = "esptool.exe";
}
Application.ThreadException += (s, e) =>
{
Debug("threadexception", e.Exception.ToString(), Event.Critical);
MainWindow.Instance.Invoke(new Action(() =>
{
MessageBox.Show($"{e.Exception.Message}\nThe application will terminate immediately.", "Unexpected Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Terminate();
}));
};
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
Debug("appdomain", e.ExceptionObject.ToString(), Event.Critical);
MainWindow.Instance.Invoke(new Action(() =>
{
MessageBox.Show($"{(e.ExceptionObject as Exception).Message}\nThe application will terminate immediately.", "Unexpected Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Terminate();
}));
};
if (!argv.Any(o => o.Contains("--debugyes") || o.Contains("-dyes")) && DebugMode)
{
Debug("[WARN] Do not close this debugging window, doing so will prevent logging " +
"to the disk and may cause unintended behaviour.", Event.Critical);
Debug("If you wish to hide this window, please run N2D22 without the --debug flag.", Event.Warning);
string conf = string.Empty;
do
{
Console.Write("Please type \"understood\" without the quotes to continue: ");
conf = Console.ReadLine();
}
while (conf != "understood");
Debug("To debug faster, simply append 'yes' to the --debug flag i.e. \"--debugyes\" to skip the confirmation.", Event.Success);
Console.Write("Press any key to continue . . .");
Console.ReadKey();
}
Debug("Creating MainWindow");
Application.Run(new MainWindow());
Debug("Window destroyed. Exiting", Event.Critical);
if (argv.Any(o => o.Contains("--debug") || o.Contains("-d")))
NativeMethods.FreeConsole();
Terminate();
}
19
Source : PerformanceTest.cs
with Apache License 2.0
from aadreja
with Apache License 2.0
from aadreja
void Write(string text)
{
Console.ForegroundColor = defaultColor;
Console.Write(text);
}
19
Source : PerformanceTest.cs
with Apache License 2.0
from aadreja
with Apache License 2.0
from aadreja
void Write(string text, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.Write(text);
}
19
Source : DellFanCmd.cs
with GNU General Public License v3.0
from AaronKelley
with GNU General Public License v3.0
from AaronKelley
public static void Usage()
{
Console.Write(
"Usage: DellFanManagement [command]\n" +
"Available commands:\n" +
" ec-disable Turn EC fan control off (fan goes to manual control)\n" +
" ec-disable-nofanchg Turn EC fan control off and don't change the fan speed\n" +
" ec-enable Turn EC fan control on (fan goes to automatic control)\n" +
" test Try turning EC fan control off,\n" +
" and record the fan RPM at different levels.\n" +
" rpm-fanX Report RPM for fan 1\n" +
" Replace \"X\" with fan number (1-7)\n" +
" (RPMs are reported via status/error code)\n" +
" thermalmode MODE Change the system thermal mode;\n" +
" Replace \"MODE\" with Optimized, Cool, Quiet, or Performance\n" +
"\n" +
"After EC fan control is off, you may use:\n" +
" fanX-level0 Set fan X to level 0 (0%)\n" +
" fanX-level1 Set fan X to level 1 (50%)\n" +
" fanX-level2 Set fan X to level 2 (100%)\n" +
" Replace \"X\" with fan number (1-7)\n" +
"\n" +
"Append \"-alt\" to EC disable or enable commands to attempt alternate method.\n" +
"(Example: ec-disable-alt)\n");
}
19
Source : CheesePizza.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
internal override void Prepare()
{
Console.WriteLine("Preparing " + Name + " Using");
Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: ");
Console.WriteLine();
foreach (var val in _ingredients.CreateVeggies())
{
Console.Write(val.Name + " ");
}
Console.WriteLine();
}
19
Source : ClamPizza.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
internal override void Prepare()
{
Console.WriteLine("Preparing " + Name + " Using");
Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Clam: " + _ingredients.CreateClam().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Cheese: " + _ingredients.CreateCheese().Name);
Console.WriteLine();
}
19
Source : WeatherMonitor.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
public void OnNext(Weather value)
{
Console.WriteLine(_name);
if (_name.Contains("T"))
{
string op = $"| Temperature : {value.Temperature} Celsius |";
Console.Write(op);
}
if (_name.Contains("P"))
{
string op = $"| Pressure : {value.Pressure} atm |";
Console.Write(op);
}
if (_name.Contains("H"))
{
string op = $"| Humidity : {value.Humidity * 100} % |";
Console.Write(op);
}
if (!(_name.Contains("T") || _name.Contains("P") || _name.Contains("H")))
{
OnError(new Exception());
}
Console.WriteLine();
}
19
Source : Program.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
static void Main()
{
try
{
var chocoEggs = ChocolateBoiler.GetInstance();
chocoEggs.Fill();
chocoEggs.Boil();
chocoEggs.Drain();
}
catch (Exception)
{
Console.Write("Oops");
}
}
19
Source : NoQuarterState.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
public void EjectQuarter()
{
Console.Write("Can't eject anything");
}
19
Source : Program.cs
with GNU General Public License v3.0
from abishekaditya
with GNU General Public License v3.0
from abishekaditya
static void Main()
{
var tea = new Tea();
var coffee = new Coffee();
tea.WantsCondiments = true;
tea.AddSugar = 5;
tea.Prepare();
Console.WriteLine();
coffee.WantsCondiments = true;
coffee.Prepare();
var people = new List<Person> { new Person("Ram", 25), new Person("Abishek", 12), new Person("Ram", 18), new Person("Abishek", 18) };
foreach (var person in people)
{
Console.Write(person);
}
people.Sort();
Console.WriteLine();
foreach (var person in people)
{
Console.Write(person);
}
}
19
Source : ConsoleExtensions.cs
with Apache License 2.0
from acblog
with Apache License 2.0
from acblog
public static string Input(string prompt = "")
{
Console.Write(prompt);
return Console.ReadLine() ?? string.Empty;
}
See More Examples