Here are the examples of the csharp api System.Console.WriteLine() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4309 Examples
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async Task RunPostgreSql(string connectionString)
{
Console.WriteLine("Running on PostgreSQL database...");
int commandCounter = 0;
DbCommand NpgsqlCommandFactory(NpgsqlConnection connection, string sqlText)
{
Console.WriteLine($"Command #{++commandCounter}");
Console.WriteLine(sqlText);
Console.WriteLine();
return new NpgsqlCommand(sqlText, connection);
}
using (var connection = new NpgsqlConnection(connectionString))
{
if (!await CheckConnection(connection, "PostgreSQL"))
{
return;
}
using (var database = new SqDatabase<NpgsqlConnection>(
connection: connection,
commandFactory: NpgsqlCommandFactory,
sqlExporter: new PgSqlExporter(builderOptions: SqlBuilderOptions.Default
.WithSchemaMap(schemaMap: new[] { new SchemaMap(@from: "dbo", to: "public") }))))
{
await Script(database: database, isMsSql: false);
}
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async Task RunMsSql(string connectionString)
{
Console.WriteLine("Running on MsSQL database...");
int commandCounter = 0;
DbCommand SqlCommandFactory(SqlConnection connection, string sqlText)
{
Console.WriteLine($"Command #{++commandCounter}");
Console.WriteLine(sqlText);
Console.WriteLine();
return new SqlCommand(sqlText, connection);
}
using (var connection = new SqlConnection(connectionString))
{
if (!await CheckConnection(connection, "MsSQL"))
{
return;
}
await connection.OpenAsync();
using (var database = new SqDatabase<SqlConnection>(
connection: connection,
commandFactory: SqlCommandFactory,
sqlExporter: TSqlExporter.Default))
{
await Script(database, isMsSql: true);
}
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async Task ExecScenarioAll(IScenario scenario, string msSqlConnectionString, string pgSqlConnectionString, string mySqlConnectionString)
{
Stopwatch stopwatch = new Stopwatch();
Console.WriteLine();
Console.WriteLine("-MS SQL Test-------");
stopwatch.Restart();
await ExecMsSql(scenario, msSqlConnectionString);
stopwatch.Stop();
Console.WriteLine($"-MS SQL Test End: {stopwatch.ElapsedMilliseconds} ms");
Console.WriteLine("-Postgres Test-----");
stopwatch.Start();
await ExecNpgSql(scenario, pgSqlConnectionString);
stopwatch.Stop();
Console.WriteLine($"-Postgres Test End: {stopwatch.ElapsedMilliseconds} ms");
Console.WriteLine();
Console.WriteLine("-MY SQL Test-------");
stopwatch.Restart();
await ExecMySql(scenario, mySqlConnectionString);
stopwatch.Stop();
Console.WriteLine($"-MY SQL Test End: {stopwatch.ElapsedMilliseconds} ms");
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async Task RunMySql(string connectionString)
{
Console.WriteLine("Running on MySQL database...");
int commandCounter = 0;
DbCommand MySqlCommandFactory(MySqlConnection connection, string sqlText)
{
Console.WriteLine($"Command #{++commandCounter}");
Console.WriteLine(sqlText);
Console.WriteLine();
return new MySqlCommand(sqlText, connection);
}
using (var connection = new MySqlConnection(connectionString))
{
if (!await CheckConnection(connection, "MySQL"))
{
return;
}
using (var database = new SqDatabase<MySqlConnection>(
connection: connection,
commandFactory: MySqlCommandFactory,
sqlExporter: new MySqlExporter(builderOptions: SqlBuilderOptions.Default)))
{
await Script(database: database, isMsSql: false);
}
}
}
19
View Source File : ScSelectSets.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public async Task Exec(IScenarioContext context)
{
var tUser = AllTables.GereplacedUser();
var tCompany = AllTables.GereplacedCompany();
var unionResult = await SelectTop(2, (tUser.FirstName + "-" + tUser.LastName).As("Name")).From(tUser)
.Union(SelectTop(2, tCompany.CompanyName.As("Name")).From(tCompany))
.QueryList(context.Database, r => r.GetString("Name"));
Console.WriteLine("Union");
foreach (var name in unionResult)
{
Console.WriteLine(name);
}
var exceptSet = Values(unionResult
.Where((i, index) => index % 2 == 0)
.Select(i => new ExprValue[] {Literal(i)})
.ToList())
.As("EX", "Name");
var unionExceptResult = await SelectTop(2, (tUser.FirstName + "-" + tUser.LastName).As("Name")).From(tUser)
.Union(SelectTop(2, tCompany.CompanyName.As("Name")).From(tCompany))
.Except(Select(exceptSet.Alias.AllColumns()).From(exceptSet))
.QueryList(context.Database, r => r.GetString("Name"));
Console.WriteLine();
Console.WriteLine("Union Except");
foreach (var name in unionExceptResult)
{
Console.WriteLine(name);
}
for (int i = 0; i < unionResult.Count; i++)
{
if (i % 2 != 0)
{
if (unionResult[i] != unionExceptResult[i / 2])
{
throw new Exception(unionResult[i] + " != " + unionExceptResult[i / 2]);
}
}
}
}
19
View Source File : ScUpdateUsers.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public async Task Exec(IScenarioContext context)
{
var tUser = AllTables.GereplacedUser();
var tCustomer = AllTables.GereplacedCustomer();
var maxVersion = (int) await Select(Max(tUser.Version))
.From(tUser)
.QueryScalar(context.Database);
var countBefore = (long)await Select(Cast(CountOne(), SqlType.Int64))
.From(tUser)
.Where(tUser.Version == maxVersion & Exists(SelectOne().From(tCustomer).Where(tCustomer.UserId == tUser.UserId)))
.QueryScalar(context.Database);
await Update(tUser)
.Set(tUser.Version, tUser.Version + 1)
.From(tUser)
.InnerJoin(tCustomer, on: tCustomer.UserId == tUser.UserId)
.All()
.Exec(context.Database);
var countAfter = (long)await Select(Cast(CountOne(), SqlType.Int64))
.From(tUser)
.Where(tUser.Version == maxVersion + 1)
.QueryScalar(context.Database);
if (countBefore != countAfter)
{
throw new Exception($"Something went wrong: count before {countBefore}, count after {countAfter}");
}
Console.WriteLine();
Console.WriteLine($"{countAfter} items were updated.");
Console.WriteLine();
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
static bool Review()
{
Console.WriteLine("\n Please review these settings: \n");
Console.WriteLine("-------------------------------------------------------------------------------");
Console.WriteLine("Shortcuts:");
Console.WriteLine(string.Format(" Replace desktop shortcuts: {0} \n", ReplaceDesktop.ToString()));
if (WriteShortcuts[0] == "")
{
Console.WriteLine(string.Format(" Don't write additional shortcuts"));
}
else
{
Console.WriteLine(string.Format(" Write additional shortcuts to: \n"));
foreach(string p in WriteShortcuts)
{
Console.WriteLine(string.Format(" {0}", p));
}
Console.WriteLine();
}
Console.WriteLine("-------------------------------------------------------------------------------");
Console.WriteLine("FL Studio versions:\n");
Console.WriteLine(string.Format(" Path: {0}", FLStudioPaths));
if(VersionNumber == ""){ Console.WriteLine(" No version specified\n"); }
else
{ Console.WriteLine(string.Format(" Version: {0}\n", VersionNumber)); }
Console.WriteLine("-------------------------------------------------------------------------------\n");
Console.WriteLine("Are these settings OK? (Y/N)");
switch (Console.ReadKey().Key)
{
case ConsoleKey.Y:
return true;
case ConsoleKey.N:
return false;
}
return false;
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void WriteToFileWMI(string host, string eventName, string username, string preplacedword)
{
try
{
ConnectionOptions options = new ConnectionOptions();
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[*] User credentials : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
// first create a 5 second timer on the remote host
ManagementScope timerScope = new ManagementScope(string.Format(@"\\{0}\root\cimv2", host), options);
ManagementClreplaced timerClreplaced = new ManagementClreplaced(timerScope, new ManagementPath("__IntervalTimerInstruction"), null);
ManagementObject myTimer = timerClreplaced.CreateInstance();
myTimer["IntervalBetweenEvents"] = (UInt32)5000;
myTimer["SkipIfPreplaceded"] = false;
myTimer["TimerId"] = "Timer";
try
{
Console.WriteLine("[+] Creating Event Subscription {0} : {1}", eventName, host);
myTimer.Put();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in creating timer object: {0}", ex.Message);
return;
}
ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\subscription", host), options);
// then install the __EventFilter for the timer object
ManagementClreplaced wmiEventFilter = new ManagementClreplaced(scope, new ManagementPath("__EventFilter"), null);
WqlEventQuery myEventQuery = new WqlEventQuery(@"SELECT * FROM __TimerEvent WHERE TimerID = 'Timer'");
ManagementObject myEventFilter = wmiEventFilter.CreateInstance();
myEventFilter["Name"] = eventName;
myEventFilter["Query"] = myEventQuery.QueryString;
myEventFilter["QueryLanguage"] = myEventQuery.QueryLanguage;
myEventFilter["EventNameSpace"] = @"\root\cimv2";
try
{
myEventFilter.Put();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in setting event filter : {0}", ex.Message);
}
// now create the ActiveScriptEventConsumer payload (VBS)
ManagementObject myEventConsumer = new ManagementClreplaced(scope, new ManagementPath("ActiveScriptEventConsumer"), null).CreateInstance();
myEventConsumer["Name"] = eventName;
myEventConsumer["ScriptingEngine"] = "VBScript";
myEventConsumer["ScriptText"] = vbsp;
myEventConsumer["KillTimeout"] = (UInt32)45;
try
{
myEventConsumer.Put();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in setting event consumer: {0}", ex.Message);
}
// finally bind them together with a __FilterToConsumerBinding
ManagementObject myBinder = new ManagementClreplaced(scope, new ManagementPath("__FilterToConsumerBinding"), null).CreateInstance();
myBinder["Filter"] = myEventFilter.Path.RelativePath;
myBinder["Consumer"] = myEventConsumer.Path.RelativePath;
try
{
myBinder.Put();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in setting FilterToConsumerBinding: {0}", ex.Message);
}
// wait for everything to trigger
Console.WriteLine("\r\n[+] Waiting 10 seconds for event '{0}' to trigger\r\n", eventName);
System.Threading.Thread.Sleep(10 * 1000);
Console.WriteLine("[+] Done...cleaning up");
// cleanup
try
{
myTimer.Delete();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in removing 'Timer' interval timer: {0}", ex.Message);
}
try
{
myBinder.Delete();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in removing FilterToConsumerBinding: {0}", ex.Message);
}
try
{
myEventFilter.Delete();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in removing event filter: {0}", ex.Message);
}
try
{
myEventConsumer.Delete();
}
catch (Exception ex)
{
Console.WriteLine("[X] Exception in removing event consumer: {0}", ex.Message);
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[X] Exception : {0}", ex.Message));
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void RemoveRegValue(string host, string username, string preplacedword, string keypath, string keyname)
{
if (!keypath.Contains(":"))
{
Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
return;
}
if (!String.IsNullOrEmpty(host))
{
host = "127.0.0.1";
}
string[] reginfo = keypath.Split(':');
string reghive = reginfo[0];
string wmiNameSpace = "root\\CIMv2";
UInt32 hive = 0;
switch (reghive.ToUpper())
{
case "HKCR":
hive = 0x80000000;
break;
case "HKCU":
hive = 0x80000001;
break;
case "HKLM":
hive = 0x80000002;
break;
case "HKU":
hive = 0x80000003;
break;
case "HKCC":
hive = 0x80000005;
break;
default:
Console.WriteLine("[X] Error : Could not get the right reg hive");
return;
}
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connecto to WMI : {0}", ex.Message);
return;
}
try
{
//Probably stay with string value only
ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("DeleteValue");
inParams["hDefKey"] = hive;
inParams["sSubKeyName"] = keypath;
inParams["sValueName"] = keyname;
ManagementBaseObject outParams1 = registry.InvokeMethod("DeleteValue", inParams, null);
Console.WriteLine("[+] Deleted value at {0} {1}", keypath, keyname);
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[-] {0}", ex.Message));
return;
}
}
19
View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
static void QueryReg()
{
try
{
string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
Console.WriteLine("Current HKCU:{0} values", keypath);
RegistryKey regkey;
regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
if (regkey.ValueCount > 0)
{
foreach (string subKey in regkey.GetValueNames())
{
Console.WriteLine("[+] Key Name : {0}", subKey);
Console.WriteLine(" Value : {0}", regkey.GetValue(subKey).ToString());
Console.WriteLine();
}
}
regkey.Close();
}
catch (Exception ex)
{
Console.WriteLine("[-] Error: {0}", ex.Message);
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void RemoveWMIClreplaced(string host, string username, string preplacedword, string wnamespace, string clreplacedname)
{
if (!String.IsNullOrEmpty(wnamespace))
{
wnamespace = "root\\CIMv2";
}
if (!String.IsNullOrEmpty(host))
{
host = "127.0.0.1";
}
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wnamespace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connecto to WMI : {0}", ex.Message);
return;
}
try
{
var rmclreplaced = new ManagementClreplaced(scope, new ManagementPath(clreplacedname), new ObjectGetOptions());
rmclreplaced.Delete();
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[-] {0}", ex.Message));
return;
}
}
19
View Source File : FileWrite.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void WriteToWMIClreplaced(string host, string username, string preplacedword, string wnamespace, string clreplacedname)
{
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wnamespace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connecto to WMI : {0}", ex.Message);
return;
}
try
{
var nclreplaced = new ManagementClreplaced(scope, new ManagementPath(string.Empty), new ObjectGetOptions());
nclreplaced["__CLreplaced"] = clreplacedname;
nclreplaced.Qualifiers.Add("Static", true);
nclreplaced.Properties.Add("WinVal", CimType.String, false);
nclreplaced.Properties["WinVal"].Qualifiers.Add("read", true);
nclreplaced["WinVal"] = datavals;
//nclreplaced.Properties.Add("Sizeof", CimType.String, false);
//nclreplaced.Properties["Sizeof"].Qualifiers.Add("read", true);
//nclreplaced.Properties["Sizeof"].Qualifiers.Add("Description", "Value needed for Windows");
nclreplaced.Put();
Console.WriteLine("[+] Create WMI Clreplaced : {0} {1}", wnamespace, clreplacedname);
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[X] Error : {0}", ex.Message));
return;
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void WriteToRegKey(string host, string username, string preplacedword, string keypath, string valuename)
{
if (!keypath.Contains(":"))
{
Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
return;
}
string[] reginfo = keypath.Split(':');
string reghive = reginfo[0];
string wmiNameSpace = "root\\CIMv2";
UInt32 hive = 0;
switch (reghive.ToUpper())
{
case "HKCR":
hive = 0x80000000;
break;
case "HKCU":
hive = 0x80000001;
break;
case "HKLM":
hive = 0x80000002;
break;
case "HKU":
hive = 0x80000003;
break;
case "HKCC":
hive = 0x80000005;
break;
default:
Console.WriteLine("[X] Error : Could not get the right reg hive");
return;
}
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connect to to WMI : {0}", ex.Message);
return;
}
try
{
//Probably stay with string value only
ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("SetStringValue");
inParams["hDefKey"] = hive;
inParams["sSubKeyName"] = reginfo[1];
inParams["sValueName"] = valuename;
inParams["sValue"] = datavals;
ManagementBaseObject outParams = registry.InvokeMethod("SetStringValue", inParams, null);
if(Convert.ToInt32(outParams["ReturnValue"]) == 0)
{
Console.WriteLine("[+] Created {0} {1} and put content inside", keypath, valuename);
}
else
{
Console.WriteLine("[-] An error occured, please check values");
return;
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[X] Error : {0}", ex.Message));
return;
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 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
View Source File : ApplicationBuilderExtensions.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 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
View Source File : rotations.cs
License : MIT License
Project Creator : 1CM69
License : MIT License
Project Creator : 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
View Source File : reflections.cs
License : MIT License
Project Creator : 1CM69
License : MIT License
Project Creator : 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
View Source File : ObjectPool.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : ObjectPool.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : ObjectPool.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : Program.cs
License : MIT License
Project Creator : 3583Bytes
License : MIT License
Project Creator : 3583Bytes
private static void RunEngine()
{
bool ShowBoard = false;
var engine = new Engine();
Console.WriteLine("Chess Core");
Console.WriteLine("Created by Adam Berent");
Console.WriteLine("Version: 1.0.1");
Console.WriteLine("");
Console.WriteLine("Type quit to exit");
Console.WriteLine("Type show to show board");
Console.WriteLine("");
Console.WriteLine("feature setboard=1");
while (true)
{
try
{
if (ShowBoard)
{
DrawBoard(engine);
}
if (engine.WhoseMove != engine.HumanPlayer)
{
MakeEngineMove(engine);
}
else
{
Console.WriteLine();
string move = Console.ReadLine();
if (String.IsNullOrEmpty(move))
{
continue;
}
move = move.Trim();
if (move == "new")
{
engine.NewGame();
continue;
}
if (move == "quit")
{
return;
}
if (move == "xboard")
{
continue;
}
if (move == "show")
{
ShowBoard = !ShowBoard;
continue;
}
if (move.StartsWith("edit"))
{
continue;
}
if (move == "hint")
{
continue;
}
if (move == "bk")
{
continue;
}
if (move == "undo")
{
engine.Undo();
continue;
}
if (move == "remove")
{
continue;
}
if (move == "remove")
{
continue;
}
if (move == "hard")
{
engine.GameDifficulty = Engine.Difficulty.Hard;
continue;
}
if (move == "easy")
{
continue;
}
if (move.StartsWith("accepted"))
{
continue;
}
if (move.StartsWith("rejected"))
{
continue;
}
if (move.StartsWith("variant"))
{
continue;
}
if (move == "random")
{
continue;
}
if (move == "force")
{
continue;
}
if (move == "go")
{
continue;
}
if (move == "playother")
{
if (engine.WhoseMove == ChessPieceColor.White)
{
engine.HumanPlayer = ChessPieceColor.Black;
}
else if (engine.WhoseMove == ChessPieceColor.Black)
{
engine.HumanPlayer = ChessPieceColor.White;
}
continue;
}
if (move == "white")
{
engine.HumanPlayer = ChessPieceColor.Black;
if (engine.WhoseMove != engine.HumanPlayer)
{
MakeEngineMove(engine);
}
continue;
}
if (move == "black")
{
engine.HumanPlayer = ChessPieceColor.White;
if (engine.WhoseMove != engine.HumanPlayer)
{
MakeEngineMove(engine);
}
continue;
}
if (move.StartsWith("level"))
{
continue;
}
if (move.StartsWith("st"))
{
continue;
}
if (move.StartsWith("sd"))
{
continue;
}
if (move.StartsWith("time"))
{
continue;
}
if (move.StartsWith("otim"))
{
continue;
}
if (move.StartsWith("otim"))
{
continue;
}
if (move == "?")
{
continue;
}
if (move.StartsWith("ping"))
{
if (move.IndexOf(" ") > 0)
{
string pong = move.Substring(move.IndexOf(" "), move.Length - move.IndexOf(" "));
Console.WriteLine("pong " + pong);
}
continue;
}
if (move.StartsWith("result"))
{
continue;
}
if (move.StartsWith("setboard"))
{
if (move.IndexOf(" ") > 0)
{
string fen = move.Substring(move.IndexOf(" "), move.Length - move.IndexOf(" ")).Trim();
engine.InitiateBoard(fen);
}
continue;
}
if (move.StartsWith("setboard"))
{
continue;
}
if (move.StartsWith("edit"))
{
engine.NewGame();
continue;
}
if (move.StartsWith("1/2-1/2"))
{
engine.NewGame();
continue;
}
if (move.StartsWith("0-1"))
{
engine.NewGame();
continue;
}
if (move.StartsWith("1-0"))
{
engine.NewGame();
continue;
}
if (move.Length < 4)
{
continue;
}
if (move.Length > 5)
{
continue;
}
string src = move.Substring(0, 2);
string dst = move.Substring(2, 2);
byte srcCol;
byte srcRow;
byte dstRow;
byte dstCol;
try
{
srcCol = GetColumn(src);
srcRow = GetRow(src);
dstRow = GetRow(dst);
dstCol = GetColumn(dst);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
continue;
}
if (!engine.IsValidMove(srcCol, srcRow, dstCol, dstRow))
{
Console.WriteLine("Invalid Move");
continue;
}
engine.MovePiece(srcCol, srcRow, dstCol, dstRow);
MakeEngineMove(engine);
if (engine.StaleMate)
{
if (engine.InsufficientMaterial)
{
Console.WriteLine("1/2-1/2 {Draw by insufficient material}");
}
else if (engine.RepeatedMove)
{
Console.WriteLine("1/2-1/2 {Draw by repereplacedion}");
}
else if (engine.FiftyMove)
{
Console.WriteLine("1/2-1/2 {Draw by fifty move rule}");
}
else
{
Console.WriteLine("1/2-1/2 {Stalemate}");
}
engine.NewGame();
}
else if (engine.GetWhiteMate())
{
Console.WriteLine("0-1 {Black mates}");
engine.NewGame();
}
else if (engine.GetBlackMate())
{
Console.WriteLine("1-0 {White mates}");
engine.NewGame();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
}
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 3583Bytes
License : MIT License
Project Creator : 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
View Source File : Program.cs
License : MIT License
Project Creator : 3583Bytes
License : MIT License
Project Creator : 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
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
public static void logo()
{
Console.WriteLine();
Console.WriteLine("###################################################");
Console.WriteLine("# __ __ ___ _ _ ___ ____ _ _ __ __ ____ #");
Console.WriteLine("# | \\/ |_ _| \\ | |_ _| _ \\| | | | \\/ | _ \\ #");
Console.WriteLine("# | |\\/| || || \\| || || | | | | | | |\\/| | |_) | #");
Console.WriteLine("# | | | || || |\\ || || |_| | |_| | | | | __/ #");
Console.WriteLine("# |_| |_|___|_| \\_|___|____/ \\___/|_| |_|_| #");
Console.WriteLine("# #");
Console.WriteLine("###################################################");
Console.WriteLine();
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
public static void logo()
{
Console.WriteLine();
Console.WriteLine("##########################################################################");
Console.WriteLine("# ____ ____ ______ _ _ _____ _____ _______ ____ _____ #");
Console.WriteLine("# / __ \\| _ \\| ____| | | |/ ____|/ ____| /\\|__ __/ __ \\| __ \\ #");
Console.WriteLine("# | | | | |_) | |__ | | | | (___ | | / \\ | | | | | | |__) | #");
Console.WriteLine("# | | | | _ <| __| | | | |\\___ \\| | / /\\ \\ | | | | | | _ / #");
Console.WriteLine("# | |__| | |_) | | | |__| |____) | |____ / ____ \\| | | |__| | | \\ \\ #");
Console.WriteLine("# \\____/|____/|_| \\____/|_____/ \\_____/_/ \\_\\_| \\____/|_| \\_\\ #");
Console.WriteLine("##########################################################################");
Console.WriteLine();
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 6tail
License : MIT License
Project Creator : 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
View Source File : Program.cs
License : MIT License
Project Creator : a-luna
License : MIT License
Project Creator : a-luna
private static async Task Main()
{
Console.Clear();
await Task.Delay(2000);
await ConsoleProgressBars();
Console.WriteLine();
await FileTransferProgressBars();
Console.WriteLine();
}
19
View Source File : Program.cs
License : MIT License
Project Creator : a-luna
License : MIT License
Project Creator : 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
View Source File : Program.cs
License : MIT License
Project Creator : a-luna
License : MIT License
Project Creator : 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
View Source File : AccelCalculator.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection<SimulatedMouseInput> simulatedInputData)
{
double lastInputMagnitude = 0;
double lastOutputMagnitude = 0;
SimulatedMouseInput lastInput;
double lastSlope = 0;
double maxRatio = 0.0;
double minRatio = Double.MaxValue;
double maxSlope = 0.0;
double minSlope = Double.MaxValue;
double log = -2;
int index = 0;
int logIndex = 0;
foreach (var simulatedInputDatum in simulatedInputData)
{
if (simulatedInputDatum.velocity <= 0)
{
continue;
}
var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, 1, simulatedInputDatum.time);
var outMagnitude = DecimalCheck(Velocity(output.Item1, output.Item2, simulatedInputDatum.time));
var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5);
var outDiff = Math.Round(outMagnitude - lastOutputMagnitude, 5);
if (inDiff == 0)
{
continue;
}
if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
{
data.VelocityPoints.Add(simulatedInputDatum.velocity, outMagnitude);
}
else
{
continue;
}
while (Math.Pow(10,log) < outMagnitude && logIndex < data.LogToIndex.Length)
{
data.LogToIndex[logIndex] = index;
log += 0.01;
logIndex++;
}
var ratio = DecimalCheck(outMagnitude / simulatedInputDatum.velocity);
var slope = DecimalCheck(inDiff > 0 ? outDiff / inDiff : starter);
if (slope < lastSlope)
{
Console.WriteLine();
}
if (ratio > maxRatio)
{
maxRatio = ratio;
}
if (ratio < minRatio)
{
minRatio = ratio;
}
if (slope > maxSlope)
{
maxSlope = slope;
}
if (slope < minSlope)
{
minSlope = slope;
}
if (!data.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
{
data.AccelPoints.Add(simulatedInputDatum.velocity, ratio);
}
if (!data.GainPoints.ContainsKey(simulatedInputDatum.velocity))
{
data.GainPoints.Add(simulatedInputDatum.velocity, slope);
}
lastInputMagnitude = simulatedInputDatum.velocity;
lastOutputMagnitude = outMagnitude;
index += 1;
lastInput = simulatedInputDatum;
lastSlope = slope;
}
index--;
while (log <= 5.0)
{
data.LogToIndex[logIndex] = index;
log += 0.01;
logIndex++;
}
data.MaxAccel = maxRatio;
data.MinAccel = minRatio;
data.MaxGain = maxSlope;
data.MinGain = minSlope;
}
19
View Source File : Program.cs
License : Apache License 2.0
Project Creator : aaaddress1
License : Apache License 2.0
Project Creator : aaaddress1
static void Main(string[] args)
{
Console.WriteLine(@" ====================================== ");
Console.WriteLine(@" xlsGen v1.0, by [email protected]");
Console.WriteLine(@" github.com/aaaddress1/xlsGen");
Console.WriteLine(@" ====================================== ");
Console.WriteLine();
var decoyDocPath = @"decoy_doreplacedent.xls";
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
List<BiffRecord> defaultMacroSheetRecords = GetDefaultMacroSheetRecords();
WorkbookStream wbs = LoadDecoyDoreplacedent(decoyDocPath);
Console.WriteLine(wbs.ToDisplayString()); // that'll be cool if there's a hex-print :)
List<string> sheetNames = wbs.GetAllRecordsByType<BoundSheet8>().Select(bs => bs.stName.Value).ToList();
List<string> preambleCode = new List<string>();
WorkbookEditor wbe = new WorkbookEditor(wbs);
var macroSheetName = "Sheet2";
wbe.AddMacroSheet(defaultMacroSheetRecords, macroSheetName, BoundSheet8.HiddenState.Visible);
List<string> macros = null;
byte[] binaryPayload = null;
int rwStart = 0, colStart = 2, dstRwStart = 0, dstColStart = 0;
int curRw = rwStart, curCol = colStart;
binaryPayload = File.ReadAllBytes("popcalc.bin");
wbe.SetMacroBinaryContent(binaryPayload, 0, dstColStart + 1, 0, 0, SheetPackingMethod.ObfuscatedCharFunc, PayloadPackingMethod.Base64);
curRw = wbe.WbStream.GetFirstEmptyRowInColumn(colStart) + 1;
macros = MacroPatterns.GetBase64DecodePattern(preambleCode);
//Orginal: wbe.SetMacroSheetContent(macros, 0, 2, dstRwStart, dstColStart, SheetPackingMethod.ObfuscatedCharFuncAlt);
macros.Add("=GOTO(R1C1)");
wbe.SetMacroSheetContent_NoLoader(macros, rwStart, colStart);
wbe.InitializeGlobalStreamLabels();
wbe.AddLabel("Auto_Open", rwStart, colStart);
#region save Workbook Stream to file
WorkbookStream createdWorkbook = wbe.WbStream;
ExcelDocWriter writer = new ExcelDocWriter();
string outputPath = "a.xls";
Console.WriteLine("Writing generated doreplacedent to {0}", outputPath);
writer.WriteDoreplacedent(outputPath, createdWorkbook, null);
#endregion
}
19
View Source File : DellFanManagementApp.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley
License : GNU General Public License v3.0
Project Creator : AaronKelley
[STAThread]
static int Main(string[] args)
{
if (args.Length == 0)
{
// GUI mode.
try
{
if (UacHelper.IsProcessElevated())
{
// Looks like we're ready to start up the GUI app.
// Set process priority to high.
Process.GetCurrentProcess().PriorityClreplaced = ProcessPriorityClreplaced.High;
// Boilerplate code to start the app.
Application.SetHighDpiMode(HighDpiMode.DpiUnaware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DellFanManagementGuiForm());
}
else
{
MessageBox.Show("This program must be run with administrative privileges.", "Dell Fan Management privilege check", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception exception)
{
MessageBox.Show(string.Format("{0}: {1}\n{2}", exception.GetType().ToString(), exception.Message, exception.StackTrace),
"Error starting application", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 1;
}
return 0;
}
else
{
// CMD mode.
try
{
Console.WriteLine("Dell Fan Management, version {0}", Version);
Console.WriteLine("By Aaron Kelley");
Console.WriteLine("Licensed under GPLv3");
Console.WriteLine("Source code available at https://github.com/AaronKelley/DellFanManagement");
Console.WriteLine();
if (UacHelper.IsProcessElevated())
{
if (args[0].ToLower() == "packagetest")
{
return PackageTest.RunPackageTests() ? 0 : 1;
}
else if (args[0].ToLower() == "setthermalsetting")
{
return SetThermalSetting.ExecuteSetThermalSetting(args);
}
else if (args[0].ToLower() == "smi-token-dump")
{
return SmiTokenDump();
}
else if (args[0].ToLower() == "smi-get-token")
{
return SmiGetToken(args);
}
else if (args[0].ToLower() == "smi-set-token")
{
return SmiSetToken(args);
}
else
{
Console.WriteLine("Dell SMM I/O driver by 424778940z");
Console.WriteLine("https://github.com/424778940z/bzh-windrv-dell-smm-io");
Console.WriteLine();
Console.WriteLine("Derived from \"Dell fan utility\" by 424778940z");
Console.WriteLine("https://github.com/424778940z/dell-fan-utility");
Console.WriteLine();
return DellFanCmd.ProcessCommand(args);
}
}
else
{
Console.WriteLine();
Console.WriteLine("This program must be run with administrative privileges.");
return 1;
}
}
catch (Exception exception)
{
Console.Error.WriteLine("{0}: {1}\n{2}", exception.GetType().ToString(), exception.Message, exception.StackTrace);
return 1;
}
}
}
19
View Source File : DellFanCmd.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley
License : GNU General Public License v3.0
Project Creator : AaronKelley
public static int ProcessCommand(string[] args)
{
int returnCode = 0;
try
{
if (args.Length != 1)
{
Usage();
}
else
{
// Behavior variables.
bool disableEcFanControl = false;
bool enableEcFanControl = false;
bool setFansToMax = false;
bool useAlternateCommand = false;
bool setFanLevel = false;
bool getFanRpm = false;
bool runTest = false;
BzhFanIndex fanSelection = BzhFanIndex.Fan1;
BzhFanLevel fanLevel = BzhFanLevel.Level0;
// Figure out what was requested.
if (args[0] == "ec-disable")
{
disableEcFanControl = true;
setFansToMax = true;
}
else if (args[0] == "ec-disable-nofanchg")
{
disableEcFanControl = true;
}
else if (args[0] == "ec-enable")
{
enableEcFanControl = true;
}
else if (args[0] == "ec-disable-alt")
{
disableEcFanControl = true;
setFansToMax = true;
useAlternateCommand = true;
}
else if (args[0] == "ec-disable-alt-nofanchg")
{
disableEcFanControl = true;
useAlternateCommand = true;
}
else if (args[0] == "ec-enable-alt")
{
enableEcFanControl = true;
useAlternateCommand = true;
}
else if (args[0] == "fan1-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan1;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan1-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan1;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan1-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan1;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan2-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan2;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan2-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan2;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan2-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan2;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan3-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan3;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan3-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan3;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan3-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan3;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan4-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan4;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan4-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan4;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan4-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan4;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan5-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan5;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan5-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan5;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan5-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan5;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan6-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan6;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan6-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan6;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan6-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan6;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "fan7-level0")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan7;
fanLevel = BzhFanLevel.Level0;
}
else if (args[0] == "fan7-level1")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan7;
fanLevel = BzhFanLevel.Level1;
}
else if (args[0] == "fan7-level2")
{
setFanLevel = true;
fanSelection = BzhFanIndex.Fan7;
fanLevel = BzhFanLevel.Level2;
}
else if (args[0] == "rpm-fan1")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan1;
}
else if (args[0] == "rpm-fan2")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan2;
}
else if (args[0] == "rpm-fan3")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan3;
}
else if (args[0] == "rpm-fan4")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan4;
}
else if (args[0] == "rpm-fan5")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan5;
}
else if (args[0] == "rpm-fan6")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan6;
}
else if (args[0] == "rpm-fan7")
{
getFanRpm = true;
fanSelection = BzhFanIndex.Fan7;
}
else if (args[0] == "test")
{
runTest = true;
}
else if (args[0] == "test-alt")
{
runTest = true;
useAlternateCommand = true;
}
else
{
Usage();
return -3;
}
// Execute request.
// Load driver first.
if (LoadDriver())
{
if (disableEcFanControl)
{
// Disable EC fan control.
Console.WriteLine("Attempting to disable EC control of the fan...");
bool success = DellSmbiosBzh.DisableAutomaticFanControl(useAlternateCommand);
if (!success)
{
Console.Error.WriteLine("Failed.");
UnloadDriver();
return -1;
}
Console.WriteLine(" ...Success.");
if (setFansToMax)
{
// Crank the fans up, for safety.
Console.WriteLine("Setting fan 1 speed to maximum...");
success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level2);
if (!success)
{
Console.Error.WriteLine("Failed.");
}
Console.WriteLine("Setting fan 2 speed to maximum...");
success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level2);
if (!success)
{
Console.Error.WriteLine("Failed. (Maybe your system just has one fan?)");
}
}
else
{
Console.WriteLine("WARNING: CPU and GPU are not designed to run under load without active cooling.");
Console.WriteLine("Make sure that you have alternate fan speed control measures in place.");
}
}
else if (enableEcFanControl)
{
// Enable EC fan control.
Console.WriteLine("Attempting to enable EC control of the fan...");
bool success = DellSmbiosBzh.EnableAutomaticFanControl(useAlternateCommand);
if (!success)
{
Console.Error.WriteLine("Failed.");
UnloadDriver();
return -1;
}
Console.WriteLine(" ...Success.");
}
else if (setFanLevel)
{
// Set the fan to a specific level.
Console.WriteLine("Attempting to set the fan level...");
bool success = DellSmbiosBzh.SetFanLevel(fanSelection, fanLevel);
if (!success)
{
Console.Error.WriteLine("Failed.");
UnloadDriver();
return -1;
}
Console.WriteLine(" ...Success.");
}
else if (getFanRpm)
{
// Query the fan RPM.
Console.WriteLine("Attempting to query the fan RPM...");
uint? result = DellSmbiosBzh.GetFanRpm(fanSelection);
if (result == null)
{
Console.Error.WriteLine("Failed.");
UnloadDriver();
return -1;
}
Console.WriteLine(" Result: {0}", result);
if (result < int.MaxValue)
{
returnCode = int.Parse(result.ToString());
}
else
{
Console.WriteLine(" (Likely error)");
returnCode = -1;
}
}
else if (runTest)
{
// Test all of the fan levels and report RPMs.
uint? rpmIdleFan1;
uint? rpmLevel0Fan1;
uint? rpmLevel1Fan1;
uint? rpmLevel2Fan1;
uint? rpmIdleFan2 = null;
uint? rpmLevel0Fan2 = null;
uint? rpmLevel1Fan2 = null;
uint? rpmLevel2Fan2 = null;
int sleepInterval = 7500;
bool fan2Present = true;
// Disable EC fan control.
Console.WriteLine("Disabling EC fan control...");
DellSmbiosBzh.DisableAutomaticFanControl(useAlternateCommand);
// Query current idle fan levels.
rpmIdleFan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level0);
rpmIdleFan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
bool success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level0);
if (!success)
{
// No fan 2?
fan2Present = false;
Console.WriteLine("Looks like fan 2 is not present, system only has one fan?");
}
// Measure fan 1.
Console.WriteLine("Measuring: Fan 1, level 0...");
Thread.Sleep(sleepInterval);
rpmLevel0Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
Console.WriteLine("Measuring: Fan 1, level 1...");
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level1);
Thread.Sleep(sleepInterval);
rpmLevel1Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
Console.WriteLine("Measuring: Fan 1, level 2...");
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level2);
Thread.Sleep(sleepInterval);
rpmLevel2Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level0);
if (fan2Present)
{
// Measure fan 2.
Console.WriteLine("Measuring: Fan 2, level 0...");
rpmLevel0Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
Console.WriteLine("Measuring: Fan 2, level 1...");
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level1);
Thread.Sleep(sleepInterval);
rpmLevel1Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
Console.WriteLine("Measuring: Fan 2, level 2...");
DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level2);
Thread.Sleep(sleepInterval);
rpmLevel2Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
}
// Enable EC fan control.
Console.WriteLine("Enabling EC fan control...");
DellSmbiosBzh.EnableAutomaticFanControl(useAlternateCommand);
Console.WriteLine("Test procedure is finished.");
Console.WriteLine();
Console.WriteLine();
// Output results.
Console.WriteLine("Fan 1 initial speed: {0}", rpmIdleFan1);
if (fan2Present)
{
Console.WriteLine("Fan 2 initial speed: {0}", rpmIdleFan2);
}
Console.WriteLine();
Console.WriteLine("Fan 1 level 0 speed: {0}", rpmLevel0Fan1);
Console.WriteLine("Fan 1 level 1 speed: {0}", rpmLevel1Fan1);
Console.WriteLine("Fan 1 level 2 speed: {0}", rpmLevel2Fan1);
Console.WriteLine();
if (fan2Present)
{
Console.WriteLine("Fan 2 level 0 speed: {0}", rpmLevel0Fan2);
Console.WriteLine("Fan 2 level 1 speed: {0}", rpmLevel1Fan2);
Console.WriteLine("Fan 2 level 2 speed: {0}", rpmLevel2Fan2);
Console.WriteLine();
}
}
// Unload driver.
UnloadDriver();
}
}
}
catch (DllNotFoundException)
{
Console.Error.WriteLine("Unable to load DellSmbiosBzh.dll");
Console.Error.WriteLine("Make sure that the file is present. If it is, install the required Visual C++ redistributable:");
Console.Error.WriteLine("https://aka.ms/vs/16/release/vc_redist.x64.exe");
returnCode = -1;
}
catch (Exception exception)
{
Console.Error.WriteLine("Error: {0}", exception.Message);
Console.Error.WriteLine(exception.StackTrace);
returnCode = -1;
UnloadDriver();
}
return returnCode;
}
19
View Source File : SimpleLatencyBenchmark.cs
License : MIT License
Project Creator : Abc-Arbitrage
License : MIT License
Project Creator : Abc-Arbitrage
public static void PrintSummary(string replacedle, params (string name, SimpleLatencyBenchmarkResult result)[] results)
{
Console.WriteLine(replacedle);
Console.WriteLine(String.Join("", Enumerable.Range(0, replacedle.Length).Select(_ => "=")));
Console.WriteLine();
Console.WriteLine("+------------+--------+--------+--------+------------+------------+------------+------------+------------+------------+------------+");
Console.WriteLine("| Test | Mean | Median | P90 | P95 | P99 | P99.9 | P99.99 | P99.999 | Max | GC Count |");
Console.WriteLine("+------------+--------+--------+--------+------------+------------+------------+------------+------------+------------+------------+");
foreach (var (name, result) in results)
{
var histo = Concatenate(result.ExecutionTimes);
Console.WriteLine($"| {name,-10} | {histo.GetMean(),6:N0} | {histo.GetValueAtPercentile(50),6:N0} | {histo.GetValueAtPercentile(90),6:N0} | {histo.GetValueAtPercentile(95),10:N0} | {histo.GetValueAtPercentile(99),10:N0} | {histo.GetValueAtPercentile(99.9),10:N0} | {histo.GetValueAtPercentile(99.99),10:N0} | {histo.GetValueAtPercentile(99.999),10:N0} | {histo.GetMaxValue(),10:N0} | {result.CollectionCount,10:N0} |");
}
Console.WriteLine("+------------+--------+--------+--------+------------+------------+------------+------------+------------+------------+------------+");
}
19
View Source File : Program.cs
License : Microsoft Public License
Project Creator : abfo
License : Microsoft Public License
Project Creator : abfo
static void Main(string[] args)
{
// Preplaced the path to the shapefile in as the command line argument
if ((args.Length == 0) || (!File.Exists(args[0])))
{
Console.WriteLine("Usage: ShapefileDemo <shapefile.shp>");
return;
}
// construct shapefile with the path to the .shp file
using (Shapefile shapefile = new Shapefile(args[0]))
{
Console.WriteLine("ShapefileDemo Dumping {0}", args[0]);
Console.WriteLine();
// a shapefile contains one type of shape (and possibly null shapes)
Console.WriteLine("Type: {0}, Shapes: {1:n0}", shapefile.Type, shapefile.Count);
// a shapefile also defines a bounding box for all shapes in the file
Console.WriteLine("Bounds: {0},{1} -> {2},{3}",
shapefile.BoundingBox.Left,
shapefile.BoundingBox.Top,
shapefile.BoundingBox.Right,
shapefile.BoundingBox.Bottom);
Console.WriteLine();
// enumerate all shapes
foreach (Shape shape in shapefile)
{
Console.WriteLine("----------------------------------------");
Console.WriteLine("Shape {0:n0}, Type {1}", shape.RecordNumber, shape.Type);
// each shape may have replacedociated metadata
string[] metadataNames = shape.GetMetadataNames();
if (metadataNames != null)
{
Console.WriteLine("Metadata:");
foreach (string metadataName in metadataNames)
{
Console.WriteLine("{0}={1} ({2})", metadataName, shape.GetMetadata(metadataName), shape.DataRecord.GetDataTypeName(shape.DataRecord.GetOrdinal(metadataName)));
}
Console.WriteLine();
}
// cast shape based on the type
switch (shape.Type)
{
case ShapeType.Point:
// a point is just a single x/y point
ShapePoint shapePoint = shape as ShapePoint;
Console.WriteLine("Point={0},{1}", shapePoint.Point.X, shapePoint.Point.Y);
break;
case ShapeType.Polygon:
// a polygon contains one or more parts - each part is a list of points which
// are clockwise for boundaries and anti-clockwise for holes
// see http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
ShapePolygon shapePolygon = shape as ShapePolygon;
foreach (PointD[] part in shapePolygon.Parts)
{
Console.WriteLine("Polygon part:");
foreach (PointD point in part)
{
Console.WriteLine("{0}, {1}", point.X, point.Y);
}
Console.WriteLine();
}
break;
default:
// and so on for other types...
break;
}
Console.WriteLine("----------------------------------------");
Console.WriteLine();
}
}
Console.WriteLine("Done");
Console.WriteLine();
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : abishekaditya
private static void Main()
{
var remote = new RemoteControl(3);
var bike = new Garage("Bike");
var bikeDoorClose = new GarageDoorCloseCommand(bike);
var bikeDoorOpen = new GarageDoorOpenCommand(bike);
var car = new Garage("Car");
var carDoorClose = new GarageDoorCloseCommand(car);
var carDoorOpen = new GarageDoorOpenCommand(car);
var garageButton = new OnOffStruct
{
On = bikeDoorOpen,
Off = bikeDoorClose
};
remote[0] = garageButton;
remote.PushOn(0);
remote.PushUndo();
remote.PushUndo();
remote.PushOff(0);
Console.WriteLine();
var light = new Light("Hall");
ICommand[] partyOn = { new LightOffCommand(light), bikeDoorOpen, carDoorOpen };
ICommand[] partyOff = { new LightOnCommand(light), bikeDoorClose, carDoorClose };
remote[2] = new OnOffStruct { On = new MacroCommand(partyOn), Off = new MacroCommand(partyOff) };
try
{
remote.PushOn(2);
Console.WriteLine();
remote.PushOff(2);
}
catch (Exception)
{
Console.WriteLine("Oops");
}
}
19
View Source File : Menu.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : abishekaditya
public override void Print()
{
Console.WriteLine(Name);
Console.WriteLine("___________");
foreach (var menuComponent in _components)
{
menuComponent.Print();
}
Console.WriteLine();
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : abishekaditya
private static void Main()
{
var dimmer = new Dimmer();
var dvdPlayer = new DvdPlayer();
var dvd = new Dvd("Gone with the Wind 2 : Electric Bugaloo");
var homeTheater = new HomeTheatreFacade(dimmer, dvd, dvdPlayer);
homeTheater.WatchMovie();
Console.WriteLine();
homeTheater.Pause();
Console.WriteLine();
homeTheater.Resume();
Console.WriteLine();
homeTheater.Pause();
}
19
View Source File : CheesePizza.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : 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
View Source File : ClamPizza.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : 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
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : abishekaditya
static void Main()
{
Console.WriteLine("Yankees fan orders:");
var yankees = new NyPizzaFactory();
yankees.Order("Cheese");
Console.WriteLine();
Console.WriteLine("Cubs fan orders:");
var cubs = new ChicagoPizzaFactory();
cubs.Order("Clam");
}
19
View Source File : WeatherMonitor.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : 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
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : abishekaditya
public static void Main()
{
LegacyTest();
Console.WriteLine();
var gumballmachine = new GumballMachine(5);
gumballmachine.InsertQuarter();
gumballmachine.TurnCrank();
gumballmachine.InsertQuarter();
gumballmachine.TurnCrank();
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : abishekaditya
License : GNU General Public License v3.0
Project Creator : 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
View Source File : Program.cs
License : MIT License
Project Creator : abock
License : MIT License
Project Creator : abock
static int Main(string[] args)
{
var decode = false;
var wrap = 76;
var showHelp = false;
var showVersion = false;
var options = new OptionSet
{
{ "usage: ecoji [OPTIONS]... [FILE]" },
{ "" },
{ "Encode or decode data as Unicode emojis. 😻🍹" },
{ "" },
{ "Options:" },
{
"d|decode",
"Decode data.",
v => decode = v != null
},
{
"w|wrap=",
"Wrap encoded lines after {COLS} characters (default 76). " +
"Use 0 to disable line wrapping.",
(int v) => wrap = v
},
{
"h|help",
"Print this message.",
v => showHelp = v != null
},
{
"v|version",
"Print version information.",
v => showVersion = v != null
}
};
void ShowHelp()
=> options.WriteOptionDescriptions(Console.Out);
void ShowVersion()
{
Console.WriteLine($"Ecoji (.NET Core) version {version}");
Console.WriteLine($" Copyright : {copyright}");
Console.WriteLine($" License : MIT");
Console.WriteLine($" Source code : https://github.com/abock/dotnet-ecoji");
Console.WriteLine();
Console.WriteLine($"Based on Ecoji by Keith Turner:");
Console.WriteLine($" https://github.com/keith-turner/ecoji");
}
try
{
var positional = options.Parse(args);
if (showHelp)
{
ShowHelp();
return ExitShowHelp;
}
if (showVersion)
{
ShowVersion();
return ExitShowVersion;
}
Stream inputStream;
if (positional is null ||
positional.Count == 0 ||
positional[0] == "-")
inputStream = Console.OpenStandardInput();
else if (positional.Count == 1)
inputStream = new FileStream(
positional[0],
FileMode.Open,
FileAccess.Read);
else
throw new Exception("more than one file was provided");
try
{
using(inputStream)
{
if (decode)
{
using var stdout = Console.OpenStandardOutput();
Ecoji.Decode(inputStream, stdout);
}
else
{
Ecoji.Encode(inputStream, Console.Out, wrap);
}
}
}
catch (Exception e)
{
WriteError($"pipe or encoding/decoding error: {e}");
return ExitDataError;
}
return ExitSuccess;
}
catch (Exception e)
{
WriteError(e.Message);
ShowHelp();
return ExitArgumentsError;
}
static void WriteError(string error)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.Error.WriteLine($"error: {error}");
Console.Error.WriteLine();
Console.ResetColor();
}
}
19
View Source File : ClientDemoService.cs
License : MIT License
Project Creator : abpframework
License : MIT License
Project Creator : abpframework
private async Task TestWithHttpClientAndIdenreplacedyModelAuthenticationServiceAsync()
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdenreplacedyModelAuthenticationServiceAsync)} *****");
//Get access token using ABP's IIdenreplacedyModelAuthenticationService
var accessToken = await _authenticationService.GetAccessTokenAsync(
new IdenreplacedyClientConfiguration(
_configuration["IdenreplacedyClients:Default:Authority"],
_configuration["IdenreplacedyClients:Default:Scope"],
_configuration["IdenreplacedyClients:Default:ClientId"],
_configuration["IdenreplacedyClients:Default:ClientSecret"],
_configuration["IdenreplacedyClients:Default:GrantType"],
_configuration["IdenreplacedyClients:Default:UserName"],
_configuration["IdenreplacedyClients:Default:UserPreplacedword"]
)
);
//Perform the actual HTTP request
using (var httpClient = new HttpClient())
{
httpClient.SetBearerToken(accessToken);
var url = _configuration["RemoteServices:OrderingService:BaseUrl"] +
"api/OrderingService/sample/authorized";
var responseMessage = await httpClient.GetAsync(url);
if (responseMessage.IsSuccessStatusCode)
{
var responseString = await responseMessage.Content.ReadreplacedtringAsync();
Console.WriteLine("Result: " + responseString);
}
else
{
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode);
}
}
}
19
View Source File : ClientDemoService.cs
License : MIT License
Project Creator : abpframework
License : MIT License
Project Creator : abpframework
private async Task TestAllManuallyAsync()
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****");
//Obtain access token from the IDS4 server
// discover endpoints from metadata
var client = new HttpClient();
var disco = await client.GetDiscoveryDoreplacedentAsync(_configuration["IdenreplacedyClients:Default:Authority"]);
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return;
}
// request token
var tokenResponse = await client.RequestPreplacedwordTokenAsync(new PreplacedwordTokenRequest
{
Address = disco.TokenEndpoint,
ClientId = _configuration["IdenreplacedyClients:Default:ClientId"],
ClientSecret = _configuration["IdenreplacedyClients:Default:ClientSecret"],
UserName = _configuration["IdenreplacedyClients:Default:UserName"],
Preplacedword = _configuration["IdenreplacedyClients:Default:UserPreplacedword"],
Scope = _configuration["IdenreplacedyClients:Default:Scope"]
});
if (tokenResponse.IsError)
{
Console.WriteLine(tokenResponse.Error);
return;
}
Console.WriteLine(tokenResponse.Json);
//Perform the actual HTTP request
using (var httpClient = new HttpClient())
{
httpClient.SetBearerToken(tokenResponse.AccessToken);
var url = _configuration["RemoteServices:PaymentService:BaseUrl"] +
"api/PaymentService/sample/authorized";
var responseMessage = await httpClient.GetAsync(url);
if (responseMessage.IsSuccessStatusCode)
{
var responseString = await responseMessage.Content.ReadreplacedtringAsync();
Console.WriteLine("Result: " + responseString);
}
else
{
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode);
}
}
}
19
View Source File : ClientDemoService.cs
License : MIT License
Project Creator : AbpApp
License : MIT License
Project Creator : AbpApp
private async Task TestWithDynamicProxiesAsync()
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****");
var result = await _sampleAppService.GetAsync();
Console.WriteLine("Result: " + result.Value);
result = await _sampleAppService.GetAuthorizedAsync();
Console.WriteLine("Result (authorized): " + result.Value);
}
19
View Source File : ClientDemoService.cs
License : MIT License
Project Creator : AbpApp
License : MIT License
Project Creator : AbpApp
private async Task TestWithHttpClientAndIdenreplacedyModelAuthenticationServiceAsync()
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdenreplacedyModelAuthenticationServiceAsync)} *****");
//Get access token using ABP's IIdenreplacedyModelAuthenticationService
var accessToken = await _authenticationService.GetAccessTokenAsync(
new IdenreplacedyClientConfiguration(
_configuration["IdenreplacedyClients:Default:Authority"],
_configuration["IdenreplacedyClients:Default:Scope"],
_configuration["IdenreplacedyClients:Default:ClientId"],
_configuration["IdenreplacedyClients:Default:ClientSecret"],
_configuration["IdenreplacedyClients:Default:GrantType"],
_configuration["IdenreplacedyClients:Default:UserName"],
_configuration["IdenreplacedyClients:Default:UserPreplacedword"]
)
);
//Perform the actual HTTP request
using (var httpClient = new HttpClient())
{
httpClient.SetBearerToken(accessToken);
var url = _configuration["RemoteServices:Ordering:BaseUrl"] +
"api/Ordering/sample/authorized";
var responseMessage = await httpClient.GetAsync(url);
if (responseMessage.IsSuccessStatusCode)
{
var responseString = await responseMessage.Content.ReadreplacedtringAsync();
Console.WriteLine("Result: " + responseString);
}
else
{
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode);
}
}
}
19
View Source File : ClientDemoService.cs
License : MIT License
Project Creator : AbpApp
License : MIT License
Project Creator : AbpApp
private async Task TestAllManuallyAsync()
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****");
//Obtain access token from the IDS4 server
// discover endpoints from metadata
var client = new HttpClient();
var disco = await client.GetDiscoveryDoreplacedentAsync(_configuration["IdenreplacedyClients:Default:Authority"]);
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return;
}
// request token
var tokenResponse = await client.RequestPreplacedwordTokenAsync(new PreplacedwordTokenRequest
{
Address = disco.TokenEndpoint,
ClientId = _configuration["IdenreplacedyClients:Default:ClientId"],
ClientSecret = _configuration["IdenreplacedyClients:Default:ClientSecret"],
UserName = _configuration["IdenreplacedyClients:Default:UserName"],
Preplacedword = _configuration["IdenreplacedyClients:Default:UserPreplacedword"],
Scope = _configuration["IdenreplacedyClients:Default:Scope"]
});
if (tokenResponse.IsError)
{
Console.WriteLine(tokenResponse.Error);
return;
}
Console.WriteLine(tokenResponse.Json);
//Perform the actual HTTP request
using (var httpClient = new HttpClient())
{
httpClient.SetBearerToken(tokenResponse.AccessToken);
var url = _configuration["RemoteServices:Ordering:BaseUrl"] +
"api/Ordering/sample/authorized";
var responseMessage = await httpClient.GetAsync(url);
if (responseMessage.IsSuccessStatusCode)
{
var responseString = await responseMessage.Content.ReadreplacedtringAsync();
Console.WriteLine("Result: " + responseString);
}
else
{
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode);
}
}
}
See More Examples