System.Console.ReadKey()

Here are the examples of the csharp api System.Console.ReadKey() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2140 Examples 7

19 Source : Program.cs
with MIT License
from 0ffffffffh

static void Main(string[] args)
        {
            Process apache=null, backend=null, sbmon=null;
            List<Process> memcachedInsts = null;

            appExePath = System.Reflection.replacedembly.GetExecutingreplacedembly().Location;
            appWorkDir = Path.GetDirectoryName(appExePath);

            CheckAdminRights();

            var procList = Process.GetProcesses();

            foreach (var proc in procList)
            {
                if (stricmp(proc.ProcessName, "httpd") == 0)
                {
                    Log("Httpd still running");
                    apache = proc;
                }
                else if (stricmp(proc.ProcessName, "sozluk_backend") == 0)
                {
                    Log("Backend process still running");
                    backend = proc;
                }
                else if (stricmp(proc.ProcessName, "sbmon") == 0)
                {
                    Log("Sbmon still running");
                    sbmon = proc;
                }
                else if (stricmp(proc.ProcessName, "memcached") == 0)
                {
                    Log("A memcached instance found");
                    if (memcachedInsts == null)
                        memcachedInsts = new List<Process>();

                    memcachedInsts.Add(proc);
                }
            }

            if (apache == null)
            {
                Log("starting httpd");
                Run(HttpdExePath,string.Empty);
            }

            if (backend==null)
            {
                if (sbmon != null)
                {
                    Log("there is no backend but sbmon. Sbmon killing");
                    sbmon.Kill();
                }

                if (memcachedInsts!=null)
                {
                    Log("There some memcached instances. Killing em");

                    foreach (var mcp in memcachedInsts)
                    {
                        mcp.Kill();
                    }
                }


                Log("Starting up backend");
                Run(BackendExePath, string.Empty);
            }

            Console.ReadKey();

        }

19 Source : Program.cs
with MIT License
from 0ffffffffh

static void Main(string[] args)
        {
            int mpid;
            ushort mport;

            Log.Init("backend");

            Log.EnableLogType(LogType.Critical);
            Log.EnableLogType(LogType.Verbose);
            Log.EnableLogType(LogType.Info);
            Log.EnableLogType(LogType.Error);
            Log.EnableLogType(LogType.Warning);

            if (!Config.Get().IsOK)
            {
                Log.Critical("Some of required config settings missing.");
                return;
            }

            Log.DisableAll();
            Log.EnableLogType((LogType)Config.Get().LogLevel);

            Log.Info("Booting up memcached instance");

            mpid = TryGetOpt<int>("-mpid", args, 0);
            mport = TryGetOpt<ushort>("-mport", args, 0);

            if (mpid > 0 && mport > 0)
            {
                Log.Warning("Attach requested at pid: {0} and port {1}", mpid, mport);
                DataCacheInstance = Memcached.AttachExist("GeneralCache", mport, mpid);
            }
            else
                DataCacheInstance = Memcached.Create("GeneralCache", 512, 11211);

            if (Program.DataCacheInstance == null)
                Log.Critical("Memcached could not started");
            else
                Log.Info("Memcached ok");



            Init();

            Console.CancelKeyPress += Console_CancelKeyPress;

            while (running)
                Thread.Sleep(10);

            Uninit();

            Console.WriteLine("All resources released. press any key to exit");

            Log._Finalize();

            Console.ReadKey();
            Environment.Exit(0);
        }

19 Source : Program.cs
with zlib License
from 0x0ade

public static void Main(string[] args) {
            XnaToFnaUtil xtf = new XnaToFnaUtil();

            Console.WriteLine($"XnaToFna {XnaToFnaUtil.Version}");
            Console.WriteLine($"using MonoMod {MonoModder.Version}");

            bool showHelp = false;
            bool showVersion = false;
            bool relinkOnly = false;

            OptionSet options = new OptionSet {
                { "h|help", "Show this message and exit.", v => showHelp = v != null },
                { "v|version", "Show the version and exit.", v => showVersion = v != null },
                { "profile=", "Choose between multiple base profiles:\ndefault, minimal, forms", v => {
                    switch (v.ToLowerInvariant()) {
                        case "default":
                            xtf.HookCompat = true;
                            xtf.HookHacks = true;
                            xtf.HookEntryPoint = false;
                            xtf.HookLocks = false;
                            xtf.FixOldMonoXML = false;
                            xtf.HookBinaryFormatter = true;
                            xtf.HookReflection = true;
                            break;

                        case "minimal":
                            xtf.HookCompat = false;
                            xtf.HookHacks = false;
                            xtf.HookEntryPoint = false;
                            xtf.HookLocks = false;
                            xtf.FixOldMonoXML = false;
                            xtf.HookBinaryFormatter = false;
                            xtf.HookReflection = false;
                            break;

                        case "forms":
                            xtf.HookCompat = true;
                            xtf.HookHacks = false;
                            xtf.HookEntryPoint = true;
                            xtf.HookLocks = false;
                            xtf.FixOldMonoXML = false;
                            xtf.HookBinaryFormatter = false;
                            xtf.HookReflection = false;
                            break;
                    }
                } },

                { "relinkonly=", "Only read and write the replacedemblies listed.", (bool v) => relinkOnly = v },

                { "hook-compat=", "Toggle Forms and P/Invoke compatibility hooks.", (bool v) => xtf.HookCompat = v },
                { "hook-hacks=", "Toggle some hack hooks, f.e.\nXNATOFNA_DISPLAY_FULLSCREEN", (bool v) => xtf.HookEntryPoint = v },
                { "hook-locks=", "Toggle if locks should be \"destroyed\" or not.", (bool v) => xtf.HookLocks = v },
                { "hook-oldmonoxml=", "Toggle basic XML serialization fixes.\nPlease try updating mono first!", (bool v) => xtf.FixOldMonoXML = v },
                { "hook-binaryformatter=", "Toggle BinaryFormatter-related fixes.", (bool v) => xtf.HookBinaryFormatter = v },
                { "hook-reflection=", "Toggle reflection-related fixes.", (bool v) => xtf.HookBinaryFormatter = v },
                { "hook-patharg=", "Hook the given method to receive fixed paths.\nCan be used multiple times.", v => xtf.FixPathsFor.Add(v) },

                { "ilplatform=", "Choose the target IL platform:\nkeep, x86, x64, anycpu, x86pref", v => xtf.PreferredPlatform = ParseEnum(v, ILPlatform.Keep) },
                { "mixeddeps=", "Choose the action performed to mixed dependencies:\nkeep, stub, remove", v => xtf.MixedDeps = ParseEnum(v, MixedDepAction.Keep) },
                { "removepublickeytoken=", "Remove the public key token of a dependency.\nCan be used multiple times.", v => xtf.DestroyPublicKeyTokens.Add(v) },
            };

            void WriteHelp(TextWriter writer) {
                writer.WriteLine("Usage: <mono> XnaToFna.exe [options] <--> FileOrDir <FileOrDir> <...>");
                options.WriteOptionDescriptions(writer);
            }

            List<string> extra;
            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.Error.Write("Command parse error: ");
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine();
                WriteHelp(Console.Error);
                return;
            }

            if (showVersion) {
                return;
            }

            if (showHelp) {
                WriteHelp(Console.Out);
                return;
            }

            foreach (string arg in extra)
                xtf.ScanPath(arg);

            if (!relinkOnly && !Debugger.IsAttached) // Otherwise catches XnaToFna.vshost.exe
                xtf.ScanPath(Directory.GetCurrentDirectory());

            xtf.OrderModules();

            xtf.RelinkAll();

            xtf.Log("[Main] Done!");

            if (Debugger.IsAttached) // Keep window open when running in IDE
                Console.ReadKey();
        }

19 Source : Program.cs
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

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 : Program.cs
with GNU General Public License v3.0
from 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 Source : Program.cs
with GNU General Public License v3.0
from 0xfd3

static void Main(string[] args)
        {
            var a = Chromium.Grab();

            foreach (var b in a)
            {
                Console.WriteLine("Url: " + b.URL);
                Console.WriteLine("Username: " + b.UserName);
                Console.WriteLine("Preplacedword: " + b.Preplacedword);
                Console.WriteLine("Application: " + b.Application);
                Console.WriteLine("=============================");
            }

            Console.ReadKey();

        }

19 Source : Program.cs
with MIT License
from 1100100

static void Main(string[] args)
        {
            DapperFactory.CreateInstance().ConfigureServices(service =>
            {
                service.AddDapperForSQLite();
            }).ConfigureContainer(container =>
            {
                container.AddDapperForSQLite("Sqlite2", "sqlite2");
            }).ConfigureConfiguration(builder =>
            {
                builder.SetBasePath(Directory.GetCurrentDirectory());
                builder.AddJsonFile("appsettings.json");
            }).Build();

            DapperFactory.Step(dapper =>
            {
                var query = dapper.Query("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            });

            var result7 = DapperFactory.Step(dapper => { return dapper.Query("select * from Contact;"); });
            Console.WriteLine(JsonConvert.SerializeObject(result7));

            DapperFactory.StepAsync(async dapper =>
            {
                var query = await dapper.QueryAsync("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            }).Wait();

            var result8 = DapperFactory.StepAsync(async dapper => await dapper.QueryAsync("select * from Contact;")).Result;
            Console.WriteLine(JsonConvert.SerializeObject(result8));


            DapperFactory.Step("sqlite2", dapper =>
             {
                 var query = dapper.Query("select * from Contact;");
                 Console.WriteLine(JsonConvert.SerializeObject(query));
             });

            var result9 = DapperFactory.Step("sqlite2", dapper => { return dapper.Query("select * from Contact;"); });
            Console.WriteLine(JsonConvert.SerializeObject(result9));

            DapperFactory.StepAsync("sqlite2", async dapper =>
            {
                var query = await dapper.QueryAsync("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            }).Wait();

            var result10 = DapperFactory.StepAsync("sqlite2", async dapper => await dapper.QueryAsync("select * from Contact;")).Result;
            Console.WriteLine(JsonConvert.SerializeObject(result10));



            DapperFactory.Step(context =>
            {
                var dapper = context.ResolveDapper();
                var query = dapper.Query("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            });

            DapperFactory.StepAsync(async context =>
            {
                var dapper = context.ResolveDapper();
                var queryAsync = await dapper.QueryAsync("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(queryAsync));
            }).Wait();

            DapperFactory.Step((context, dapper) =>
            {
                var query = dapper.Query("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            });

            DapperFactory.StepAsync(async (context, dapper) =>
            {
                var query = await dapper.QueryAsync("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            }).Wait();

            DapperFactory.Step("sqlite2", (context, dapper) =>
            {
                var query = dapper.Query("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            });

            DapperFactory.StepAsync("sqlite2", async (context, dapper) =>
            {
                var query = await dapper.QueryAsync("select * from Contact;");
                Console.WriteLine(JsonConvert.SerializeObject(query));
            }).Wait();

            var result1 = DapperFactory.Step(context =>
            {
                var dapper = context.ResolveDapper();
                return dapper.Query("select * from Contact;");
            });
            Console.WriteLine(JsonConvert.SerializeObject(result1));

            var result2 = DapperFactory.StepAsync(context =>
            {
                var dapper = context.ResolveDapper();
                return dapper.QueryAsync("select * from Contact;");
            }).Result;
            Console.WriteLine(JsonConvert.SerializeObject(result2));

            var result3 = DapperFactory.Step((context, dapper) => dapper.Query("select * from Contact;"));
            Console.WriteLine(JsonConvert.SerializeObject(result3));

            var result4 = DapperFactory.StepAsync(async (context, dapper) => await dapper.QueryAsync("select * from Contact;")).Result;
            Console.WriteLine(JsonConvert.SerializeObject(result4));

            var result5 = DapperFactory.Step("sqlite2", (context, dapper) => dapper.Query("select * from Contact;"));
            Console.WriteLine(JsonConvert.SerializeObject(result5));

            var result6 = DapperFactory.StepAsync("sqlite2", async (context, dapper) => await dapper.QueryAsync("select * from Contact;")).Result;
            Console.WriteLine(JsonConvert.SerializeObject(result6));

            Console.ReadKey();
        }

19 Source : Program.cs
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 : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            using (var local = cli.GetDatabase())
            {
                var r1 = local.Call(new CommandPacket("Subscribe").Input("abc"));
                var r2 = local.Ping();
                var r3 = local.Ping("testping123");
                //var r4 = local.Call(new CommandPacket("punSubscribe").Input("*"));
            }

            using (cli.Subscribe("abc", ondata))
            {
                using (cli.Subscribe("abcc", ondata))
                {
                    using (cli.PSubscribe("*", ondata))
                    {
                        Console.ReadKey();
                    }
                    Console.ReadKey();
                }
                Console.ReadKey();
            }
            Console.WriteLine("one more time");
            Console.ReadKey();
            using (cli.Subscribe("abc", ondata))
            {
                using (cli.Subscribe("abcc", ondata))
                {
                    using (cli.PSubscribe("*", ondata))
                    {
                        Console.ReadKey();
                    }
                    Console.ReadKey();
                }
                Console.ReadKey();
            }
            void ondata(string channel, object data)
            {
                Console.WriteLine($"{channel} -> {data}");
            }
            //return;
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            cli.UseClientSideCaching(new ClientSideCachingOptions
            {
                //本地缓存的容量
                Capacity = 3,
                //过滤哪些键能被本地缓存
                KeyFilter = key => key.StartsWith("Interceptor"),
                //检查长期未使用的缓存
                CheckExpired = (key, dt) => DateTime.Now.Subtract(dt) > TimeSpan.FromSeconds(2)
            });

            cli.Set("Interceptor01", "123123"); //redis-server

            var val1 = cli.Get("Interceptor01"); //redis-server
            var val2 = cli.Get("Interceptor01"); //本地
            var val3 = cli.Get("Interceptor01"); //断点等3秒,redis-server

            cli.Set("Interceptor01", "234567"); //redis-server
            var val4 = cli.Get("Interceptor01"); //redis-server
            var val5 = cli.Get("Interceptor01"); //本地

            var val6 = cli.MGet("Interceptor01", "Interceptor02", "Interceptor03"); //redis-server
            var val7 = cli.MGet("Interceptor01", "Interceptor02", "Interceptor03"); //本地
            var val8 = cli.MGet("Interceptor01", "Interceptor02", "Interceptor03"); //本地

            cli.MSet("Interceptor01", "Interceptor01Value", "Interceptor02", "Interceptor02Value", "Interceptor03", "Interceptor03Value");  //redis-server
            var val9 = cli.MGet("Interceptor01", "Interceptor02", "Interceptor03");  //redis-server
            var val10 = cli.MGet("Interceptor01", "Interceptor02", "Interceptor03");  //本地

            //以下 KeyFilter 返回 false,从而不使用本地缓存
            cli.Set("123Interceptor01", "123123"); //redis-server

            var val11 = cli.Get("123Interceptor01"); //redis-server
            var val12 = cli.Get("123Interceptor01"); //redis-server
            var val23 = cli.Get("123Interceptor01"); //redis-server


            cli.Set("Interceptor011", Clreplaced); //redis-server
            var val0111 = cli.Get<TestClreplaced>("Interceptor011"); //redis-server
            var val0112 = cli.Get<TestClreplaced>("Interceptor011"); //本地
            var val0113 = cli.Get<TestClreplaced>("Interceptor011"); //断点等3秒,redis-server


            Console.ReadKey();

            cli.Dispose();
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            //网络出错后,断熔,后台线程定时检查恢复
            for (var k = 0; k < 1; k++)
            {
                new Thread(() =>
                {
                    for (var a = 0; a < 10000; a++)
                    {
                        try
                        {
                            cli.Get(Guid.NewGuid().ToString());
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        Thread.CurrentThread.Join(100);
                    }
                }).Start();
            }

            Console.ReadKey();
            return;
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {

            for (var k = 0; k < 1; k++)
            {
                new Thread(() =>
                {
                    for (var a = 0; a < 10000; a++)
                    {
                        try
                        {
                            cli.Get(Guid.NewGuid().ToString());
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        Thread.CurrentThread.Join(100);
                    }
                }).Start();
            }

            Console.ReadKey();
            return;
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            //预热
            cli.Set(Guid.NewGuid().ToString(), "我也不知道为什么刚刚好十五个字");
            sedb.StringSet(Guid.NewGuid().ToString(), "我也不知道为什么刚刚好十五个字");

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            for (int i = 0; i < 10000; i++)
            {
                var tmp = Guid.NewGuid().ToString();
                cli.Set(tmp, "我也不知道为什么刚刚好十五个字");
                var val = cli.Get(tmp);
                if (val != "我也不知道为什么刚刚好十五个字") throw new Exception("not equal");
            }

            stopwatch.Stop();
            Console.WriteLine("FreeRedis:"+stopwatch.ElapsedMilliseconds);

            //stopwatch.Restart();
            // csredis 会出现连接不能打开的情况
            //for (int i = 0; i < 100; i++)
            //{
            //    var tmp = Guid.NewGuid().ToString();
            //    csredis.Set(tmp, "我也不知道为什么刚刚好十五个字");
            //    _ = csredis.Get(tmp);
            //}

            //stopwatch.Stop();
            //Console.WriteLine("csredis:" + stopwatch.ElapsedMilliseconds);

            stopwatch.Restart();

            for (int i = 0; i < 10000; i++)
            {
                var tmp = Guid.NewGuid().ToString();
                sedb.StringSet(tmp, "我也不知道为什么刚刚好十五个字");
                var val = sedb.StringGet(tmp);
                if (val != "我也不知道为什么刚刚好十五个字") throw new Exception("not equal");
            }

            stopwatch.Stop();
            Console.WriteLine("Seredis:" + stopwatch.ElapsedMilliseconds);

            cli.Subscribe("abc", (chan, msg) =>
            {
                Console.WriteLine($"FreeRedis {chan} => {msg}");
            });

            seredis.GetSubscriber().Subscribe("abc", (chan, msg) =>
            {
                Console.WriteLine($"Seredis {chan} => {msg}");
            });
            Console.ReadKey();

            return;
        }

19 Source : Program.cs
with MIT License
from 2881099

async static Task Main(string[] args)
        {
            using (var fsql = new FreeSqlCloud<DbEnum>("app001"))
            {
                fsql.DistributeTrace += log => Console.WriteLine(log.Split('\n')[0].Trim());

                fsql.Register(DbEnum.db1, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db1.db")
                    .Build());

                fsql.Register(DbEnum.db2, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db2.db")
                    .Build());

                fsql.Register(DbEnum.db3, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db3.db")
                    .Build());

                //for (var a = 0; a < 1000; a++)
                //{

                //TCC
                var tid = Guid.NewGuid().ToString();
                await fsql
                    .StartTcc(tid, "创建订单")
                    .Then<Tcc1>()
                    .Then<Tcc2>()
                    .Then<Tcc3>()
                    .ExecuteAsync();

                tid = Guid.NewGuid().ToString();
                await fsql.StartTcc(tid, "支付购买",
                    new TccOptions
                    {
                        MaxRetryCount = 10,
                        RetryInterval = TimeSpan.FromSeconds(10)
                    })
                .Then<Tcc1>(new LocalState { Id = 1, Name = "tcc1" })
                .Then<Tcc2>()
                .Then<Tcc3>(new LocalState { Id = 3, Name = "tcc3" })
                .ExecuteAsync();

                //Saga
                tid = Guid.NewGuid().ToString();
                await fsql
                    .StartSaga(tid, "注册用户")
                    .Then<Saga1>()
                    .Then<Saga2>()
                    .Then<Saga3>()
                    .ExecuteAsync();

                tid = Guid.NewGuid().ToString();
                await fsql.StartSaga(tid, "发表评论",
                    new SagaOptions
                    {
                        MaxRetryCount = 5,
                        RetryInterval = TimeSpan.FromSeconds(5)
                    })
                    .Then<Saga1>(new LocalState { Id = 1, Name = "tcc1" })
                    .Then<Saga2>()
                    .Then<Saga3>(new LocalState { Id = 3, Name = "tcc3" })
                    .ExecuteAsync();

                Console.ReadKey();
            }
        }

19 Source : Program.cs
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 2881099

static void Main(string[] args)
        {
            using (var fsql = new FreeSqlCloud<DbEnum>("app001"))
            {
                fsql.DistributeTrace += log => Console.WriteLine(log.Split('\n')[0].Trim());

                fsql.Register(DbEnum.db1, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db1.db")
                    .Build());

                fsql.Register(DbEnum.db2, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db2.db")
                    .Build());

                fsql.Register(DbEnum.db3, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db3.db")
                    .Build());

                //for (var a = 0; a < 1000; a++)
                //{

                //TCC
                var tid = Guid.NewGuid().ToString();
                fsql
                    .StartTcc(tid, "创建订单")
                    .Then<Tcc1>()
                    .Then<Tcc2>()
                    .Then<Tcc3>()
                    .Execute();

                tid = Guid.NewGuid().ToString();
                fsql.StartTcc(tid, "支付购买",
                    new TccOptions
                    {
                        MaxRetryCount = 10,
                        RetryInterval = TimeSpan.FromSeconds(10)
                    })
                .Then<Tcc1>(new LocalState { Id = 1, Name = "tcc1" })
                .Then<Tcc2>()
                .Then<Tcc3>(new LocalState { Id = 3, Name = "tcc3" })
                .Execute();

                //Saga
                tid = Guid.NewGuid().ToString();
                fsql
                    .StartSaga(tid, "注册用户")
                    .Then<Saga1>()
                    .Then<Saga2>()
                    .Then<Saga3>()
                    .Execute();

                tid = Guid.NewGuid().ToString();
                fsql.StartSaga(tid, "发表评论",
                    new SagaOptions
                    {
                        MaxRetryCount = 5,
                        RetryInterval = TimeSpan.FromSeconds(5)
                    })
                    .Then<Saga1>(new LocalState { Id = 1, Name = "tcc1" })
                    .Then<Saga2>()
                    .Then<Saga3>(new LocalState { Id = 3, Name = "tcc3" })
                    .Execute();

                Console.ReadKey();
            }
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            DependencyInjectionBuilder builder = new DependencyInjectionBuilder();
            // 依赖注入容器
            IServiceProvider services = builder
                .AddService<CustomRepository>().Build();

            // 获取服务
            CustomRepository cus = services.Get<CustomRepository>();
            
            // 执行方法
            cus.Get("source");

            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from 2881099

static void Main(string[] args)
        {
            using (var fsql = new FreeSqlCloud<DbEnum>("app001"))
            {
                fsql.DistributeTrace += log => Console.WriteLine(log.Split('\n')[0].Trim());

                fsql.Register(DbEnum.db1, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db1.db")
                    .Build());

                fsql.Register(DbEnum.db2, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db2.db")
                    .Build());

                fsql.Register(DbEnum.db3, () => new FreeSqlBuilder()
                    .UseConnectionString(DataType.Sqlite, @"Data Source=db3.db")
                    .Build());

                //for (var a = 0; a < 1000; a++)
                //{

                //TCC
                var tid = Guid.NewGuid().ToString();
                fsql
                    .StartTcc(tid, "创建订单")
                    .Then<Tcc1>()
                    .Then<Tcc2>()
                    .Then<Tcc3>()
                    .Execute();

                tid = Guid.NewGuid().ToString();
                fsql.StartTcc(tid, "支付购买",
                    new TccOptions
                    {
                        MaxRetryCount = 10,
                        RetryInterval = TimeSpan.FromSeconds(10)
                    })
                .Then<Tcc1>(new LocalState { Id = 1, Name = "tcc1" })
                .Then<Tcc2>()
                .Then<Tcc3>(new LocalState { Id = 3, Name = "tcc3" })
                .Execute();

                //Saga
                tid = Guid.NewGuid().ToString();
                fsql
                    .StartSaga(tid, "注册用户")
                    .Then<Saga1>()
                    .Then<Saga2>()
                    .Then<Saga3>()
                    .Execute();

                tid = Guid.NewGuid().ToString();
                fsql.StartSaga(tid, "发表评论",
                    new SagaOptions
                    {
                        MaxRetryCount = 5,
                        RetryInterval = TimeSpan.FromSeconds(5)
                    })
                    .Then<Saga1>(new LocalState { Id = 1, Name = "tcc1" })
                    .Then<Saga2>()
                    .Then<Saga3>(new LocalState { Id = 3, Name = "tcc3" })
                    .Execute()
;
                Console.ReadKey();
            }
        }

19 Source : Program.cs
with GNU General Public License v3.0
from 3xpl01tc0d3r

static void Main(string[] args)
        {
            try
            {
                RunAsync().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from 499116344

private static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                throw new Exception("参数数量错误:账号 密码。");
            }
            var user = new QQUser(long.Parse(args[0]), args[1]); // 虽然已经太迟了,但是还是把密码去掉了... 起码总比在这里好啊!(塞口球
            var socketServer = new SocketServiceImpl(user);
            var transponder = new Transponder();
            var sendService = new SendMessageServiceImpl(socketServer, user);

            var manage = new MessageManage(socketServer, user, transponder);

            var robot = new TestRobot(sendService, transponder, user);

            manage.Init();
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from 4egod

static void Main(string[] args)
        {
            SendMessages();

            Console.WriteLine("Press anykey for exit...");
            Console.ReadKey();
        }

19 Source : DebugProgramTemplate.cs
with MIT License
from 71

public static int Main(string[] args)
    {
        try
        {
            Diagnosticreplacedyzer replacedyzer = new Cometaryreplacedyzer();
            CSharpParseOptions parseOptions = new CSharpParseOptions(preprocessorSymbols: new[] { "DEBUGGING" });

            if (IsWrittenToDisk && ShouldBreakAtStart)
                Debugger.Break();

            CompilationWithreplacedyzers compilation = CSharpCompilation.Create(
                replacedemblyName + "+Debugging",
                Files.Split(';').Select(x => CSharpSyntaxTree.ParseText(File.ReadAllText(x), parseOptions)),
                References.Split(';').Select(x => MetadataReference.CreateFromFile(x))
            ).Withreplacedyzers(ImmutableArray.Create(replacedyzer));

            ExecuteAsync(compilation).Wait();

            return 0;
        }
        catch (Exception e)
        {
            Console.Error.WriteLine(e.Message);
            Console.Error.WriteLine();
            Console.Error.WriteLine(e.StackTrace);

            Console.ReadKey();

            return 1;
        }
    }

19 Source : ToolsMain.cs
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 : Program.cs
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 : Program.cs
with Apache License 2.0
from aadreja

static void Main(string[] args)
        {
            DapperTry();

            var t = new { Id = 1 };
            Console.WriteLine("Type {0} Hash {1}", t.GetType().Name, t.GetHashCode());

            var t1 = new { Id = "abc" };
            Console.WriteLine("Type {0} Hash {1}", t1.GetType().Name, t1.GetHashCode());

            var t2 = new { Id = 2 };
            Console.WriteLine("Type {0} Hash {1}", t2.GetType().Name, t2.GetHashCode());

            var t3 = new { Id = "xyz" };
            Console.WriteLine("Type {0} Hash {1}", t3.GetType().Name, t3.GetHashCode());

            defaultColor = Console.ForegroundColor;

            WriteLine("-------------------------------------------", ConsoleColor.Green);
            WriteLine("Vega(Fastest .net ORM) - Sample Application", ConsoleColor.Green);
            WriteLine("-------------------------------------------", ConsoleColor.Green);

            WriteLine("Creating Database with Sample Data");

            CreateDBWithSampleData();

            long id = InsertSample();
            UpdateSample(id);
            ReadById(id);
            DeleteSample(id);
            Read();
            ReadPaged();
            AuditTrial(id);
            PerformanceTest pTest = new PerformanceTest();
            pTest.Run();

            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static void AuditTrial(long id)
        {
            WriteLine("Read Audit Trial", ConsoleColor.Green);

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);

                List<City> cities = cityRepo.ReadHistory(id).ToList();

                WriteLine($"Found {cities.Count} Records in Audit Trial", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    //,Operation ={ city.Operation}
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive},ModifiedOn={city.UpdatedOn},ModifiedBy={city.UpdatedBy}");
                }
            }
            WriteLine("Press any key to continue...");
            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static void ReadPaged()
        {
            WriteLine("Paging Sample", ConsoleColor.Green);

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);

                List<City> cities = cityRepo.ReadAllPaged("name", 1, 5).ToList();

                WriteLine($"Found {cities.Count} Records in Page 1", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }

                cities = cityRepo.ReadAllPaged("name", 2, 5).ToList();
                WriteLine($"Found {cities.Count} Records in Page 2", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }

                cities = cityRepo.ReadAllPaged("name", 1, 5, null, new { State = "GU" }).ToList();
                WriteLine($"Found {cities.Count} Records where State=GU in Page 1", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},State={city.State},IsActive={city.IsActive}");
                }
            }

            WriteLine("Paging Sample No Offset", ConsoleColor.Green);

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);

                List<City> cities = cityRepo.ReadAllPaged("name", 5, PageNavigationEnum.First).ToList();

                WriteLine($"Found {cities.Count} Records in First Page", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }

                cities = cityRepo.ReadAllPaged("name", 5, PageNavigationEnum.Next, null, null, new object[] { cities.LastOrDefault().Name }, cities.LastOrDefault().Id).ToList();
                WriteLine($"Found {cities.Count} Records in Next Page", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }

                cities = cityRepo.ReadAllPaged("name", 5, PageNavigationEnum.First, null, null, null, new { State = "GU" }).ToList();
                WriteLine($"Found {cities.Count} Records where State=GU in First Page", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},State={city.State},IsActive={city.IsActive}");
                }
            }
            WriteLine("Press any key to continue...");
            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static void ReadById(long id)
        {
            WriteLine("ReadById Sample", ConsoleColor.Green);

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                City city = cityRepo.ReadOne(id);

                WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType}");
            }
            WriteLine("Press any key to continue...");
            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static void DeleteSample(long id)
        {
            WriteLine("Delete Sample", ConsoleColor.Green);

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                cityRepo.Delete(id, 1);

                WriteLine($"City Id={id} deleted");
            }
            WriteLine("Press any key to continue...");
            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static void Read()
        {
            WriteLine("Read All", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                List<City> cities = cityRepo.ReadAll().ToList();

                WriteLine($"Found {cities.Count} Records", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }

                cities = cityRepo.ReadAll(RecordStatusEnum.Active).ToList();
                WriteLine($"Found {cities.Count} Active Records", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},Type={city.CityType},IsActive={city.IsActive}");
                }
            }

            WriteLine("Read by Criteria", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                List<City> cities = cityRepo.ReadAll(null, "State=@State", new { State = "GU" }).ToList();
                WriteLine($"Found {cities.Count} Records", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"City Id={city.Id},Name={city.Name},State={city.State},IsActive={city.IsActive}");
                }
            }

            WriteLine("Read Name by Criteria", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                List<City> cities = cityRepo.ReadAll("Name", "State=@State", new { State = "GU" }).ToList();
                WriteLine($"Found {cities.Count} Records", ConsoleColor.Green);
                foreach (City city in cities)
                {
                    WriteLine($"Name={city.Name}");
                }
            }

            WriteLine("Exists", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                bool isExists = cityRepo.Exists("Name=@Name", new { Name = "Ahmedabad" });
                WriteLine($"Ahmedabad exists {isExists}");

                isExists = cityRepo.Exists("Name=@Name", new { Name = "Dubai" });
                WriteLine($"Dubai exists {isExists}");
            }

            WriteLine("Read one value", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                decimal lareplacedude = cityRepo.Query<decimal>("SELECT lareplacedude FROM city WHERE Name=@Name", new { Name = "Ahmedabad" });

                WriteLine($"Lareplacedude of Ahmedabad is {lareplacedude}");
            }

            WriteLine("Count", ConsoleColor.Green);
            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                long count = cityRepo.Count();// "SELECT lareplacedude FROM city WHERE Name=@Name", new { Name = "Ahmedabad" });

                WriteLine($"Record count is {count}");

                count = cityRepo.Count("State=@State", new { State = "GU" });
                WriteLine($"Record count with State=GU is {count}");
            }

            WriteLine("Press any key to continue...");
            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from aadreja

static long InsertSample()
        {
            WriteLine("Insert Sample", ConsoleColor.Green);
            City city = new City()
            {
                Name = Common.Random(10),
                State = "GU",
                CountryId = 1,
                CityType = EnumCityType.Metro,
                Longitude = 100.23m,
                Lareplacedude = 123.23m,
                CreatedBy = 1
            };

            using (SqlConnection con = new SqlConnection(Common.ConnectionString))
            {
                Repository<City> cityRepo = new Repository<City>(con);
                city.Id = (long)cityRepo.Add(city);
            }
            WriteLine($"City {city.Name} added with Id {city.Id}");

            WriteLine("Press any key to continue...");
            Console.ReadKey();

            return city.Id;
        }

19 Source : ServerManager.cs
with Apache License 2.0
from AantCoder

public bool StartPrepare(string path)
        {
            var jsonFile = GetSettingsFileName(path);
            if (!File.Exists(jsonFile))
            {
                using (StreamWriter file = File.CreateText(jsonFile))
                {
                    var jsonText = JsonSerializer.Serialize(ServerSettings, new JsonSerializerOptions() { WriteIndented = true });
                    file.WriteLine(jsonText);
                }

                Console.WriteLine("Created Settings.json, server was been stopped");
                Console.WriteLine($"RU: Настройте сервер, заполните {jsonFile}");
                Console.WriteLine("Enter some key");
                Console.ReadKey();
                return false;
            }
            else
            {
                try
                {
                    using (var fs = new StreamReader(jsonFile, Encoding.UTF8))
                    {
                        var jsonString = fs.ReadToEnd();
                        ServerSettings = JsonSerializer.Deserialize<ServerSettings>(jsonString);
                    }

                    ServerSettings.WorkingDirectory = path;
                    var results = new List<ValidationResult>();
                    var context = new ValidationContext(ServerSettings);
                    if (!Validator.TryValidateObject(ServerSettings, context, results, true))
                    {
                        foreach (var error in results)
                        {
                            Console.WriteLine(error.ErrorMessage);
                            Loger.Log(error.ErrorMessage);
                        }

                        Console.ReadKey();
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine($"RU: Проверьте настройки сервера {jsonFile}");
                    Console.WriteLine("EN: Check Settings.json");
                    Console.ReadKey();
                    return false;
                }
            }

            MainHelper.OffAllLog = false;
            Loger.PathLog = path;
            Loger.IsServer = true;

            var rep = Repository.Get;
            rep.SaveFileName = GetWorldFileName(path);
            rep.Load();
            CheckDiscrordUser();
            FileHashChecker = new FileHashChecker(ServerSettings);

            return true;
        }

19 Source : Program.cs
with MIT License
from Abc-Arbitrage

public static void Main()
        {
            var test = new PerformanceTests();
            
            test.SetUp();

            try
            {
                test.should_run_test();
            }
            finally
            {
                test.Teardown();
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from abelperezok

private static async Task TestProjectRepositoryCRUD()
        {
            IProjectRepository repo = new ProjectRepository(_tableName);

            var pA = new Project { Id = "A", Name = "Project A", Description = "Desc proj A" };
            Console.WriteLine("* Creating project A");
            await repo.AddProject(pA);

            Console.WriteLine("* Retrieving project A");
            var ppA = await repo.GetProject("A");
            if (ppA != null)
                Console.WriteLine(JsonSerializer.Serialize(ppA));
            else
                Console.WriteLine("not found");

            Console.ReadKey();


            pA.Name = "Project AA";
            pA.Description = "Desc proj AA";
            Console.WriteLine("* Updating project A - renamed to AA");
            await repo.UpdateProject(pA);

            Console.WriteLine("* Retrieving project A after update");
            var pAUpdated = await repo.GetProject("A");
            if (pAUpdated != null)
                Console.WriteLine(JsonSerializer.Serialize(pAUpdated));
            else
                Console.WriteLine("not found");

            Console.ReadKey();

            Console.WriteLine("* Deleting project A");
            await repo.DeleteProject("A");

            Console.WriteLine("* Retrieving project A after deletion");
            var deletedA = await repo.GetProject("A");
            if (deletedA != null)
                Console.WriteLine(JsonSerializer.Serialize(deletedA));
            else
                Console.WriteLine("not found");
        }

19 Source : Program.cs
with MIT License
from abelperezok

public static async Task TestCRUD_PersonRepository()
        {
            // Create a new PersonRepository
            ISimpleRepository<int, Person> repo = new PersonRepository(_tableName);

            // Prepare a Person instance
            var p1 = new Person
            {
                Id = 1,
                Name = "personA",
                Email = "[email protected]",
                Age = 35
            };

            Console.WriteLine("* Adding Person 1");
            // Add a new person
            await repo.Add(p1);

            Console.WriteLine("* Getting the list");
            // Get the full list
            var list = await repo.GetList();
            foreach (var item in list)
            {
                Console.WriteLine(JsonSerializer.Serialize(item));
            }

            Console.ReadKey();

            Console.WriteLine("* Getting Person 1");
            // Get an individual Person by its Id
            var found1 = await repo.Get(p1.Id);
            Console.WriteLine(JsonSerializer.Serialize(found1));

            Console.WriteLine("* Deleting Person 1");
            // Delete an individual Person by its Id
            await repo.Delete(p1.Id);
        }

19 Source : Program.cs
with MIT License
from abelperezok

private static async Task TestGameRepositorySpecificOperations()
        {
            var userId = "U1";
            IGameRepository repo = new GameRepository(_tableName);

            for (int i = 0; i < 5; i++)
            {
                var g = new Game { Id = "GA" + i, Name = "Game A" + i };
                Console.WriteLine($"Adding {g.Id}");
                await repo.AddGame(userId, g);
            }

            Console.ReadKey();

            var games = await repo.GetGameList(userId);
            foreach (var item in games)
            {
                Console.WriteLine(JsonSerializer.Serialize(item));
            }

            Console.ReadKey();

            for (int i = 0; i < 5; i++)
            {
                var gameId = "GA" + i;
                Console.WriteLine($"Deleting {gameId}");
                await repo.DeleteGame(userId, gameId);
            }
        }

19 Source : Program.cs
with MIT License
from Accelerider

public static async Task Main()
        {
            var downloader = FileTransferService.GetDownloaderBuilder()
                .UseDefaultConfigure()
                .From("https://file.mrs4s.me/file/3898c738090be65fc336577605014534")
                .To($@"{Environment.CurrentDirectory}\download-multi-thread.test")
                .Build();

            ReadyToRun(downloader);

            //await TimeSpan.FromSeconds(10);
            //WriteLine("Try to Stop... ");
            //downloader.Stop();
            //downloader.Dispose();

            //var data = downloader.ToJsonString();
            //var jObject = downloader.ToJObject();
            //var json = jObject.ToString();
            //var downloaderFromJson = FileTransferService
            //    .GetDownloaderBuilder()
            //    .UseDefaultConfigure()
            //    .Build(data);

            //ReadyToRun(downloaderFromJson);

            ReadKey();
        }

19 Source : Program.cs
with MIT License
from Accelerider

public static void Main(string[] args)
        {
            const string packageDirectory = "package-define-files";

            var packageNames = new[]
            {
                "shell.package.xml",
                "shell.bin.package.xml",
                "any-drive.package.xml",
            };

            try
            {
                packageNames
                    .Select(item => File.ReadAllText(Path.Combine(packageDirectory, item)))
                    .Select(FolderElement.Create)
                    .ForEach(item => Pack(item));
            }
            catch (FileNotFoundException e)
            {
                Print.Error($"Missing {e.FileName}!");
            }

            Print.EndLine();
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from ADeltaX

static async Task Main(string[] args)
        {
            Console.WriteLine("Freshy EdgeUpdate Bot!");
            Console.WriteLine("Release version: " + TelegramBotSettings.BOT_VERSION);

            Console.WriteLine("\nInitializing Directories...");
            InitializeDirectory();

            Console.WriteLine("\nInitializing Database...");
            Db = new DBEngine();

            Console.WriteLine("\nInitializing TDLIB engine...");
            TDLibHost tdHost = new TDLibHost();
            Console.WriteLine("\nTDLIB engine ready!");
			
            Task.Factory.StartNew(o => SearchAutomation.PreExecute(), null, TaskCreationOptions.LongRunning);

            string cmd = "";

            do
            {
                cmd = Console.ReadKey().KeyChar.ToString().ToLower();
            } while (cmd != "q");
        }

19 Source : Program.cs
with MIT License
from adoconnection

static void Main(string[] args)
        {
            IRazorEngine razorEngine = new RazorEngine();
            IRazorEngineCompiledTemplate template = razorEngine.Compile(Content);

            string result = template.Run(
                new
                {
                    Name = "Alexander",
                    Items = new List<string>()
                    {
                            "item 1",
                            "item 2"
                    }
                });

            Console.WriteLine(result);
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from adoconnection

static void Main(string[] args)
        {
            IRazorEngine razorEngine = new RazorEngine();
            IRazorEngineCompiledTemplate template = razorEngine.Compile(Content);

            string result = template.Run(new
            {
                Name = "Alexander",
                Items = new List<string>()
                {
                    "item 1",
                    "item 2"
                }
            });

            Console.WriteLine(result);
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from adoconnection

static void Main(string[] args)
        {
            IRazorEngine razorEngine = new RazorEngine();
            IRazorEngineCompiledTemplate template = razorEngine.Compile(Content);

            string result = template.Run(new
            {
                    Name = "Alexander",
                    Items = new List<string>()
                    {
                            "item 1",
                            "item 2"
                    }
            });

            Console.WriteLine(result);
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from AeonLucid

public static async Task Main()
        {
            Console.replacedle = "Fortnite";
            Console.ForegroundColor = ConsoleColor.White;

            await DoStuff();

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from AeonLucid

private static async Task Main(string[] args)
        {
            // Get user credentials from environment variables.
            //      Environment is used for this example because it makes it easier to rest the library.
            var username = Environment.GetEnvironmentVariable("USERNAME");
            var preplacedword = Environment.GetEnvironmentVariable("PreplacedWORD");

            // Initialize cache.
            //      This makes sure there is consistency between device identifiers per user and gets rid of
            //      repeated authentications.
            var cacheDirectory = Path.Combine(Path.GetDirectoryName(typeof(Program).replacedembly.Location), "Cache");
            var cacheHandler = new FileCacheHandler(cacheDirectory);

            // Create a musical.ly client.
            //      Using to dispose properly.
            using (var client = new MusicallyClient(username, cacheHandler))
            {
                DiscoverUserMe profile = null;

                // Check if this instance is not logged in yet.
                //      ALWAYS do this check, because the access token gets cached and loaded when the client is created.
                if (!client.IsLoggedIn())
                {
                    var login = await client.LoginAsync(preplacedword);
                    if (login.success)
                    {
                        profile = await client.DiscoverUserMeAsync();
                    }
                }
                else
                {
                    profile = await client.DiscoverUserMeAsync();
                }

                // Sanity check.
                if (profile == null)
                {
                    throw new Exception("Profile was null..?");
                }

                // We are now properly authenticated.
                if (client.IsLoggedIn())
                {
                    Console.WriteLine($"Logged in as {profile.result.displayName}.");

                    // Do stuff with client.*
                }
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }

19 Source : Debug.cs
with The Unlicense
from aeroson

public static void Pause()
        {
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.BackgroundColor = ConsoleColor.Black;
            Console.WriteLine("Press any key to continue ...");
            Console.ReadKey();
        }

19 Source : Sample1.cs
with MIT License
from afucher

public static void Run()
        {
            var numbersOnly = new RegexValidator("^[0-9]*$");
            var nameInput = new Input("name", "What is your name?");
            var ageInput = new Input("age", "What is your age?");
            ageInput.SetValid(numbersOnly);

            var preplacedwordInput = new PreplacedwordInput("preplacedword", "What is the preplacedword?");
            
            var inquirer = new Inquirer(nameInput, ageInput, preplacedwordInput);

            inquirer.Ask();

            System.Console.WriteLine($@"Hello {nameInput.Answer()}! Your age is {ageInput.Answer()}");
            System.Console.WriteLine($@"Secret preplacedword: {preplacedwordInput.Answer()}!");
            System.Console.ReadKey();
        }

19 Source : Sample2.cs
with MIT License
from afucher

public static void Run()
        {
            var options = new string[] { "Option 1", "Option 2" };
            var listInput = new ListInput("option", "Which option?", options);
            var sureInput = new InputConfirmation("confirm", "Are you sure?");

            var inquirer = new Inquirer(listInput, sureInput);

            inquirer.Ask();

            var answer = listInput.Answer();
            Console.WriteLine($@"You have selected option: {answer} - {options[Int32.Parse(answer)-1]}");
            Console.WriteLine(sureInput.Answer() == "y" ? "And you are sure!" : "And you are not sure!");
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from afxw

private void Run()
        {
            client = new PaceClient();
            client.PacketReceived += Client_PacketReceived;
            client.PacketSent += Client_PacketSent;

            var packetChannel = new PacketChannel();

            packetChannel.RegisterHandler<GetSystemInfoRequestPacket>(SystemHandlers.HandleGetSystemInfo);
            packetChannel.RegisterHandler<GetDrivesRequestPacket>(SystemHandlers.HandleGetDrives);
            packetChannel.RegisterHandler<TakeScreenshotRequestPacket>(SystemHandlers.HandleTakeScreenshot);
            packetChannel.RegisterHandler<RestartRequestPacket>(SystemHandlers.HandleRestart);

            packetChannel.RegisterHandler<DownloadFileRequestPacket>(FileHandlers.HandleDownloadFile);
            packetChannel.RegisterHandler<GetDirectoryRequestPacket>(FileHandlers.HandleGetDirectory);
            packetChannel.RegisterHandler<DeleteFileRequestPacket>(FileHandlers.HandleDeleteFile);
            packetChannel.RegisterHandler<SendFileRequestPacket>(FileHandlers.HandleSendFile);

            TryConnect();

            while (isConnected)
            {
                try
                {
                    var packet = client.ReadPacket();
                    packetChannel.HandlePacket(client, packet);
                }
                catch (IOException ex)
                {
                    if (ex.InnerException == null)
                    {
                        throw ex;
                    }

                    if (ex.InnerException.GetType() == typeof(SocketException))
                    {
                        var socketException = (ex.InnerException as SocketException);

                        if (socketException.ErrorCode == (int)SocketError.ConnectionReset)
                        {
                            PrintDebug("Disconnected!");
                            TryConnect();
                        }
                    }
                }
            }

            Console.ReadKey();
        }

19 Source : Program.cs
with Apache License 2.0
from agoda-com

public static async Task Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();
            serviceCollection.AddLogging(b =>
            {
                b.AddFilter((category, level) => true); // Spam the world with logs.

                // Add console logger so we can see all the logging produced by the client by default.
                b.AddConsole(c => c.IncludeScopes = true);
            });

            Configure(serviceCollection);

            var services = serviceCollection.BuildServiceProvider();

            Console.WriteLine("Creating a client...");
            var stackExchange = services.GetRequiredService<StackExchangeClient>();

            Console.WriteLine("Sending a request...");
            var response = await stackExchange.GetJson();

            var data = await response.Content.ReadreplacedtringAsync();
            Console.WriteLine("Response data:");
            Console.WriteLine(data);

            Console.WriteLine("Press the ANY key to exit...");
            Console.ReadKey();
        }

See More Examples