private static void Main(string[] args)
        {
            var argsParser = new ArgsParser();
            var argsHelper = new ArgsHelper();
            Dictionary <ArgType, string> argsList;
            var hasAllRequiredArgs = argsParser.TryParseArgs(args, out argsList);

            if (!hasAllRequiredArgs)
            {
                Console.WriteLine(argsHelper.GetArgsHelp());
                return;
            }

            try
            {
                var typescriptServiceReferenceGenerator = new TypescriptServiceReferenceGenerator();
                typescriptServiceReferenceGenerator.GenerateServiceReferenceCode(argsList[ArgType.RemoteUri], argsList[ArgType.OutputFileName]);
            }
            catch (IOException)
            {
                Console.WriteLine("The generator failed to generate typescript code. Please check you have access to the file path");
            }
            catch (Exception)
            {
                Console.WriteLine("The generator failed to generate typescript code. Please check the arguments and ensure the Soap service is up and running.");
            }
        }
示例#2
0
        public async Task CommandLineAsync(string[] args)
        {
            _appSettings.Verbose         = ArgsHelper.NeedVerbose(args);
            _appSettings.ApplicationType = AppSettings.StarskyAppType.MetaThumbnail;

            if (new ArgsHelper().NeedHelp(args))
            {
                new ArgsHelper(_appSettings, _console).NeedHelpShowDialog();
                return;
            }

            new ArgsHelper().SetEnvironmentByArgs(args);

            var subPath            = new ArgsHelper(_appSettings).SubPathOrPathValue(args);
            var getSubPathRelative = new ArgsHelper(_appSettings).GetRelativeValue(args);

            if (getSubPathRelative != null)
            {
                subPath = new StructureService(_selectorStorage.Get(SelectorStorage.StorageServices.SubPath), _appSettings.Structure)
                          .ParseSubfolders(getSubPathRelative);
            }

            await _metaExifThumbnailService.AddMetaThumbnail(subPath);

            _console.WriteLine("Done!");
        }
        /// <summary>
        /// Run search fight process
        /// </summary>
        /// <returns></returns>
        public async Task RunAsync()
        {
            var args = Environment.CommandLine;

            args = args.Substring(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName.Length);
            string stringArgs;
            var    listArgs = new List <string>();

            if (args.Length == 0)
            {
                Console.WriteLine("Enter values to search");
                stringArgs = Console.ReadLine();
                if (!string.IsNullOrEmpty(stringArgs))
                {
                    listArgs = ArgsHelper.ExtractArgs(stringArgs);
                }
            }
            else
            {
                stringArgs = string.Join(" ", args);
                listArgs   = ArgsHelper.ExtractArgs(stringArgs);
            }

            try
            {
                var report = await _reportService.ExecuteSearchFightAsync(listArgs);

                PrintResult(report);
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#4
0
        private static void MMTime(ConCommandArgs args)
        {
            string scaleString = ArgsHelper.GetValue(args.userArgs, 0);
            float  scale       = 1f;

            if (args.Count == 0)
            {
                Debug.Log(Time.timeScale);
                return;
            }

            if (float.TryParse(scaleString, out scale))
            {
                Time.timeScale = scale;
                Debug.Log(args.sender.userName + " set time scale to " + scale);
                Chat.AddMessage("<style=cWorldEvent>" + args.sender.userName + " set time scale to " + scale + "</style>");
            }

            else
            {
                Debug.Log("Invalid arguments, example: 'mmtime {int} (0=pause,1=normal)'");
            }

            NetworkWriter networkWriter = new NetworkWriter();

            networkWriter.StartMessage(101);
            networkWriter.Write((double)Time.timeScale);
            networkWriter.FinishMessage();
            NetworkServer.SendWriterToReady(null, networkWriter, QosChannelIndex.time.intVal);
        }
示例#5
0
        public int Insert <T>(T tag, params string[] keys)
        {
            ExecArgs ea    = ArgsHelper.Insert <T>(tag, keys);
            int      count = ExecEditor(ea.Text, ea.Type, ea.Param);

            return(count);
        }
示例#6
0
        public void GivenMultipleArgs_WhenSetTypedArgs_ThenShouldReturnCorrectlyTypedArguments()
        {
            string[] args = { "-filePath",       "c:\temp",
                              "--fileCount",     "2",
                              "-verbose",
                              "-degrees",        "37",
                              "-numberAsString", "22",
                              "-humans",         "Josef Ottosson|Carl|Silvia",
                              "-ages",           "10|1337|2019",
                              "-temperatures",   "30|20|22|12,3" };
            ArgsHelper <TypedArguments> .SetTypedArgs(args);

            ArgsHelper <TypedArguments> .Value.FileCount.ShouldBe(2);

            ArgsHelper <TypedArguments> .Value.FilePath.ShouldBe("c:\temp");

            ArgsHelper <TypedArguments> .Value.Degrees.ShouldBe(37);

            ArgsHelper <TypedArguments> .Value.NumberAsString.ShouldBe("22");

            ArgsHelper <TypedArguments> .Value.Temperatures.Count.ShouldBe(4);

            ArgsHelper <TypedArguments> .Value.Ages.Count.ShouldBe(3);

            ArgsHelper <TypedArguments> .Value.Humans.Count.ShouldBe(3);

            ArgsHelper <TypedArguments> .Value.Humans.ShouldContain("Josef Ottosson");

            ArgsHelper <TypedArguments> .Value.Humans.ShouldContain("Carl");

            ArgsHelper <TypedArguments> .Value.Humans.ShouldContain("Silvia");

            ArgsHelper <TypedArguments> .Value.Verbose.ShouldBe(true);
        }
示例#7
0
        public object SelectToValue(QueryArgs args)
        {
            ExecArgs ea  = ArgsHelper.Select("Record", args);
            object   obj = ExecScalar(ea.Text, ea.Type, ea.Param);

            return(obj);
        }
示例#8
0
        public int Insert(AddedArgs args)
        {
            ExecArgs ea    = ArgsHelper.Insert("Record", args);
            int      count = ExecEditor(ea.Text, ea.Type, ea.Param);

            return(count);
        }
示例#9
0
        public void ArgsHelper_SetEnvironmentByArgsLongTestListTest()
        {
            var longNameList = new ArgsHelper(_appSettings).LongNameList.ToArray();
            var envNameList  = new ArgsHelper(_appSettings).EnvNameList.ToArray();

            var longTestList = new List <string>();

            for (int i = 0; i < longNameList.Length; i++)
            {
                longTestList.Add(longNameList[i]);
                longTestList.Add(i.ToString());
            }

            new ArgsHelper(_appSettings).SetEnvironmentByArgs(longTestList);

            for (int i = 0; i < envNameList.Length; i++)
            {
                Assert.AreEqual(Environment.GetEnvironmentVariable(envNameList[i]), i.ToString());
            }

            // Reset Environment after use
            foreach (var t in envNameList)
            {
                Environment.SetEnvironmentVariable(t, string.Empty);
            }
        }
示例#10
0
        public Task Execute(params string[] args)
        {
            string target;

            if (!ArgsHelper.GetTargetEnvironmentFromArgs(args, out target, true))
            {
                return(Task.FromResult(false));
            }

            if (args.Length < 2)
            {
                Console.Out.WriteLine("Must give dataset name as second argument to UploadData. " + AvailableDataSetNames);
                return(Task.FromResult(false));
            }

            string datasetName = args[1];

            if (!this.uploaders.ContainsKey(datasetName))
            {
                Console.Out.WriteLine("Invalid dataset name " + datasetName + ". " + AvailableDataSetNames);
                return(Task.FromResult(false));
            }

            Console.Out.WriteLine("Uploading data {0} to environment {1}.", datasetName, target);

            return(this.uploaders[datasetName].Upload(target));
        }
示例#11
0
        private static void MMEquip(ConCommandArgs args)
        {
            string         equipString  = ArgsHelper.GetValue(args.userArgs, 0);
            string         playerString = ArgsHelper.GetValue(args.userArgs, 1);
            NetworkUser    player       = GetNetUserFromString(playerString);
            Inventory      inventory    = player != null ? player.master.inventory : args.sender.master.inventory;
            int            equipIndex   = 0;
            EquipmentIndex equipType    = EquipmentIndex.None;

            if (int.TryParse(equipString, out equipIndex))
            {
                if (equipIndex < (int)EquipmentIndex.Count && equipIndex >= -1)
                {
                    inventory.SetEquipmentIndex((EquipmentIndex)equipIndex);
                }
            }

            else if (Enum.TryParse <EquipmentIndex>(equipString, true, out equipType))
            {
                inventory.SetEquipmentIndex(equipType);
            }

            else
            {
                Debug.Log("Invalid arguments. mmequip {name/id} {amount} {player}(optional)");
            }
        }
示例#12
0
        public T SelectToObject <T>(QueryArgs args) where T : class
        {
            ExecArgs ea   = ArgsHelper.Select("Record", args);
            List <T> list = ExecQuery <T>(ea.Text, ea.Type, ea.Param);

            return(list[0]);
        }
示例#13
0
        /// <summary>
        /// The main entry point.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        public static void Main(string[] args)
        {
            ConfigureLogging();

            try
            {
                Log.Logger.Information("Started");

                var commandLineArgs = ArgsHelper.Parse(args);
                if (commandLineArgs == null)
                {
                    ShowUsage();
                }
                else
                {
                    var app = new MainApp();
                    app.ProgressEvent += AppProgress;
                    app.Run(commandLineArgs);
                }

                Environment.ExitCode = 0;
                Log.Logger.Information("Finished");
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Error");

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                Environment.ExitCode = 1;
            }

            Log.CloseAndFlush();
        }
示例#14
0
        public void GivenTypedArgumentsWithDefaultValues_WhenSetTypedArgs_ThenShouldReturnDefaultValues()
        {
            string[] args = {};

            ArgsHelper <TypedArgumentsWithDefaultValues> .SetTypedArgs(args);

            ArgsHelper <TypedArgumentsWithDefaultValues> .Value.ShouldSatisfyAllConditions(
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.Count.ShouldBe(3),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(10),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(20),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(30),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.Count.ShouldBe(4),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(10f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(20f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(30f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(45.5f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.FileCount.ShouldBe(10),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.FilePath.ShouldBe("any path"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Degrees.ShouldBe(100f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.Count.ShouldBe(2),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.ShouldContain("Josef Ottosson"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.ShouldContain("Silvia"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Verbose.ShouldBeTrue()
                );
        }
示例#15
0
        public void GivenTypedArgumentsWithDefaultValues_WhenSetTypedArgsGetsCalledWithSuppliedParameters_ThenShouldReturnSuppliedValues()
        {
            string[] args = { "-filePath",       "c:\\temp",
                              "--fileCount",     "20",
                              "-verbose",        "false",
                              "-degrees",        "20",
                              "-numberAsString", "22",
                              "-humans",         "Eminem|Carl|Silvia Drottningsson",
                              "-ages",           "40|50|60",
                              "-temperatures",   "100|200|300|400.4" };

            ArgsHelper <TypedArgumentsWithDefaultValues> .SetTypedArgs(args);

            ArgsHelper <TypedArgumentsWithDefaultValues> .Value.ShouldSatisfyAllConditions(
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.Count.ShouldBe(3),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(40),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(50),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Ages.ShouldContain(60),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.Count.ShouldBe(4),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(100f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(200f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(300f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Temperatures.ShouldContain(400.4f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.FileCount.ShouldBe(20),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.FilePath.ShouldBe("c:\\temp"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Degrees.ShouldBe(20f),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.Count.ShouldBe(3),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.ShouldContain("Eminem"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.ShouldContain("Silvia Drottningsson"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Humans.ShouldContain("Carl"),
                () => ArgsHelper <TypedArgumentsWithDefaultValues> .Value.Verbose.ShouldBeFalse()
                );
        }
示例#16
0
        static async Task Main(string[] args)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.SetWindowSize(
                    Math.Min(140, Console.LargestWindowWidth),
                    Math.Min(50, Console.LargestWindowHeight));
                Console.Title = "MagentoScanner v0.1";
            }

            string banner = @"
__   __  _______  _______  _______  __    _  _______  _______  _______  _______  _______  __    _  __    _  _______  ______   
|  |_|  ||   _   ||       ||       ||  |  | ||       ||       ||       ||       ||   _   ||  |  | ||  |  | ||       ||    _ |  
|       ||  |_|  ||    ___||    ___||   |_| ||_     _||   _   ||  _____||       ||  |_|  ||   |_| ||   |_| ||    ___||   | ||  
|       ||       ||   | __ |   |___ |       |  |   |  |  | |  || |_____ |       ||       ||       ||       ||   |___ |   |_||_ 
|       ||       ||   ||  ||    ___||  _    |  |   |  |  |_|  ||_____  ||      _||       ||  _    ||  _    ||    ___||    __  |
| ||_|| ||   _   ||   |_| ||   |___ | | |   |  |   |  |       | _____| ||     |_ |   _   || | |   || | |   ||   |___ |   |  | |
|_|   |_||__| |__||_______||_______||_|  |__|  |___|  |_______||_______||_______||__| |__||_|  |__||_|  |__||_v_0.1_||___|  |_|
";

            Console.WriteLine(banner);
            ServiceProvider    serviceProvider   = new ServiceCollection().AddHttpClient().BuildServiceProvider();
            IHttpClientFactory httpClientFactory = serviceProvider.GetService <IHttpClientFactory>();
            TargetOptions      targetOptions     = ArgsHelper.ParseArgs(args);

            Logger.Log(Importance.Log, " Starting scan @ " + DateTime.Now, ConsoleColor.White);
            Logger.Log(Importance.Log, " Target set to " + targetOptions.Url, ConsoleColor.White);
            Console.WriteLine(string.Empty);
            await Task.Run(() => new HttpAsync(httpClientFactory, targetOptions).Start(targetOptions));
        }
示例#17
0
        private void CreateDb()
        {
            if (!IsHasDir(db))
            {
                AddedArgs param = new AddedArgs(new DbParams[]
                {
                    new DbParams("ID", "INTEGER PRIMARY KEY AUTOINCREMENT"),
                    new DbParams("Key", "String"),
                    new DbParams("Value", "String")
                });
                ExecArgs args = ArgsHelper.Create("Table", "Config", param);

                DataBase dbh = new DataBase(db);
                dbh.CreateTable(args);

                param = new AddedArgs(new DbParams[]
                {
                    new DbParams("ID", "INTEGER PRIMARY KEY AUTOINCREMENT"),
                    new DbParams("FID", "STRING"),
                    new DbParams("File", "STRING"),
                    new DbParams("Date", "DATETIME"),
                    new DbParams("TargetKey", "STRING"),
                    new DbParams("TargetName", "STRING"),
                    new DbParams("SampleKey", "STRING"),
                    new DbParams("SampleName", "STRING"),
                    new DbParams("Value", "DOUBLE")
                });
                args = ArgsHelper.Create("Table", "Record", param);
                dbh.CreateTable(args);
            }
        }
示例#18
0
        public int Update(AlterArgs args)
        {
            ExecArgs ea    = ArgsHelper.Update("Record", args);
            int      count = ExecEditor(ea.Text, ea.Type, ea.Param);

            return(count);
        }
示例#19
0
        public DataTable SelectToDT(QueryArgs args)
        {
            ExecArgs  ea = ArgsHelper.Select("Record", args);
            DataTable dt = ExecQuery(ea.Text, ea.Type, ea.Param);

            return(dt);
        }
示例#20
0
        public void GivenIntArgument_WhenSetTypedArgs_ThenShouldBindCorrectly()
        {
            string[] args = { "-fileCount", "2" };

            ArgsHelper <TypedArguments> .SetTypedArgs(args);

            ArgsHelper <TypedArguments> .Value.FileCount.ShouldBe(2);
        }
示例#21
0
        public void GivenFloatArgumentWithComma_WhenSetTypedArgs_ThenShouldBindCorrectly()
        {
            string[] args = { "-degrees", "37,8" };

            ArgsHelper <TypedArguments> .SetTypedArgs(args);

            ArgsHelper <TypedArguments> .Value.Degrees.ShouldBe(37.8f);
        }
示例#22
0
        public void GivenBoolArgument_WhenSetTypedArgs_ThenShouldBindCorrectly()
        {
            string[] args = { "-verbose" };

            ArgsHelper <TypedArguments> .SetTypedArgs(args);

            ArgsHelper <TypedArguments> .Value.Verbose.ShouldBe(true);
        }
示例#23
0
        public void ArgsHelper_GetColorClassFallback()
        {
            var args = new List <string> {
            }.ToArray();
            var value = ArgsHelper.GetColorClass(args);

            Assert.AreEqual(-1, value);
        }
示例#24
0
        public void GivenStringArgument_WhenSetTypedArgs_ThenShouldBindCorrectly()
        {
            string[] args = { "-filePath", "c:\\temp" };

            ArgsHelper <TypedArguments> .SetTypedArgs(args);

            ArgsHelper <TypedArguments> .Value.FilePath.ShouldBe("c:\\temp");
        }
示例#25
0
        public void GetUserInputPasswordLong()
        {
            var args = new List <string> {
                "--password", "test"
            }.ToArray();

            Assert.AreEqual("test", ArgsHelper.GetUserInputPassword(args));
        }
示例#26
0
        public object SelectToValue(QueryArgs args)
        {
            ExecArgs ea = ArgsHelper.Select("Config", args);

            object value = this.ExecScalar(ea.Text, ea.Type, ea.Param);

            return(value);
        }
示例#27
0
        public int Delete(AlterArgs args)
        {
            ExecArgs ea = ArgsHelper.Delete("Config", args);

            int count = this.ExecEditor(ea.Text, ea.Type, ea.Param);

            return(count);
        }
示例#28
0
        public async Task Thumbnail(string[] args)
        {
            _appSettings.Verbose         = ArgsHelper.NeedVerbose(args);
            _appSettings.ApplicationType = AppSettings.StarskyAppType.Thumbnail;

            if (new ArgsHelper().NeedHelp(args))
            {
                new ArgsHelper(_appSettings, _console).NeedHelpShowDialog();
                return;
            }

            new ArgsHelper().SetEnvironmentByArgs(args);

            var subPath            = new ArgsHelper(_appSettings).SubPathOrPathValue(args);
            var getSubPathRelative = new ArgsHelper(_appSettings).GetRelativeValue(args);

            if (getSubPathRelative != null)
            {
                subPath = new StructureService(_selectorStorage.Get(
                                                   SelectorStorage.StorageServices.SubPath), _appSettings.Structure)
                          .ParseSubfolders(getSubPathRelative);
            }

            if (new ArgsHelper(_appSettings).GetThumbnail(args))
            {
                var storage = _selectorStorage.Get(SelectorStorage.StorageServices.SubPath);

                var isFolderOrFile = storage.IsFolderOrFile(subPath);

                if (_appSettings.IsVerbose())
                {
                    _console.WriteLine(isFolderOrFile.ToString());
                }

                if (isFolderOrFile == FolderOrFileModel.FolderOrFileTypeList.File)
                {
                    // If single file => create thumbnail
                    var fileHash = (await new FileHash(storage).GetHashCodeAsync(subPath));
                    if (fileHash.Value)
                    {
                        await _thumbnailService.CreateThumb(subPath, fileHash.Key);                         // <= this uses subPath
                    }
                }
                else
                {
                    await _thumbnailService.CreateThumb(subPath);
                }
                _console.WriteLine("Thumbnail Done!");
            }

            if (new ArgsHelper(_appSettings).NeedCleanup(args))
            {
                _console.WriteLine(">>>>> Heavy CPU Feature => NeedCacheCleanup <<<<< ");
                await _thumbnailCleaner.CleanAllUnusedFilesAsync();

                _console.WriteLine("Done!");
            }
        }
示例#29
0
        public void Name()
        {
            _appSettings.StorageFolder = new CreateAnImage().BasePath;
            var args = new List <string> {
                "-n", "test"
            }.ToArray();

            Assert.AreEqual("test", ArgsHelper.GetName(args));
        }
示例#30
0
        private IEnumerable <ArgHelpInfo> ToArgHelpInfo(Type type, object instance)
        {
            var options = ArgsHelper.GetOptions(type).ToList();
            var args    = options.Where(o => o.ArgAttribute != null);
            var argSets = options.Where(p => p.ArgSetAttribute != null);

            return(args.Select(o => ToArgHelpInfo(o, instance))
                   .Union(argSets.SelectMany(o => ParseArgSet(o.PropertyInfo, instance))));
        }