Ejemplo n.º 1
0
        protected override void ParseProgramArgs()
        {
            //get and test the cmd line arg key\values
            var argHash = ConsoleCmd.ArgHash(_args);

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting("NoFuture.ToolsCustomTools.InvokeNfTypeName");
            if (argHash.ContainsKey(AssemblyAnalysis.GET_TOKEN_IDS_PORT_CMD_SWITCH))
            {
                _getTokenIdsCmdPort = ResolveInt(argHash[AssemblyAnalysis.GET_TOKEN_IDS_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.GET_TOKEN_NAMES_PORT_CMD_SWITCH))
            {
                _getTokenNamesCmdPort = ResolveInt(argHash[AssemblyAnalysis.GET_TOKEN_NAMES_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.GET_ASM_INDICES_PORT_CMD_SWITCH))
            {
                _getasmIndicesCmdPort = ResolveInt(argHash[AssemblyAnalysis.GET_ASM_INDICES_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.GET_TOKEN_TYPES_PORT_CMD_SWITCH))
            {
                _getTokenTypesCmdPort = ResolveInt(argHash[AssemblyAnalysis.GET_TOKEN_TYPES_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.GET_TOKEN_PAGE_RANK_PORT_CMD_SWITCH))
            {
                _getTokenPageRankCmdPort = ResolveInt(argHash[AssemblyAnalysis.GET_TOKEN_PAGE_RANK_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.REASSIGN_TOKEN_NAMES_PORT_CMD_SWITCH))
            {
                _reassignTokenNamesCmdPort = ResolveInt(argHash[AssemblyAnalysis.REASSIGN_TOKEN_NAMES_PORT_CMD_SWITCH].ToString());
            }
            if (argHash.ContainsKey(AssemblyAnalysis.RESOLVE_GAC_ASM_SWITCH))
            {
                _resolveGacAsms = ResolveBool(argHash[AssemblyAnalysis.RESOLVE_GAC_ASM_SWITCH].ToString());
            }
        }
Ejemplo n.º 2
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            if (argHash.ContainsKey(NfTypeNameProcess.GET_NF_TYPE_NAME_CMD_SWITCH))
            {
                _getNfTypeNamePort = ResolveInt(argHash[NfTypeNameProcess.GET_NF_TYPE_NAME_CMD_SWITCH].ToString());
            }
        }
Ejemplo n.º 3
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting("NoFuture.ToolsCustomTools.InvokeNfTypeName");
            if (argHash.ContainsKey(Flatten.GET_FLAT_ASM_PORT_CMD_SWITCH))
            {
                _getFlattenAssemblyCmdPort = ResolveInt(argHash[Flatten.GET_FLAT_ASM_PORT_CMD_SWITCH].ToString());
            }
        }
Ejemplo n.º 4
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting("NoFuture.ToolsCustomTools.InvokeNfTypeName");

            if (!argHash.ContainsKey(Dpx.BIN_DIR) ||
                argHash[Dpx.BIN_DIR] == null)
            {
                throw new RahRowRagee(
                          $"the switch '{Dpx.BIN_DIR}' could not be " +
                          $"parsed from cmd line arg \n{string.Join(" ", _args)}");
            }
            BinDir = argHash[Dpx.BIN_DIR].ToString();
        }
Ejemplo n.º 5
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            GetFileCmdArgs(argHash);

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting("NoFuture.ToolsCustomTools.InvokeNfTypeName");

            if (MyFileParameters.FileCommand == InvokeKind.HostSjcl)
            {
                return;
            }

            GetHostSjclCmdArgs(argHash);
        }
Ejemplo n.º 6
0
        public void TestArgHash()
        {
            var testCmd = new[]
            {
                "-connStr=Server=localhost;Database=ApexQA01;Trusted_Connection=True;",
                @"-spmFilePath=C:\ProgramFiles (x86)\Somepath\SomeFile.bin",
                "-mySwitchHere"
            };
            var testResult = ConsoleCmd.ArgHash(testCmd);

            Assert.IsNotNull(testResult);
            foreach (var k in testResult.Keys)
            {
                Console.WriteLine(string.Format("{0}\n\t\t{1}", k, testResult[k]));
            }
        }
Ejemplo n.º 7
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            if (!argHash.ContainsKey(Settings.INVOKE_ASM_PATH_SWITCH) ||
                argHash[Settings.INVOKE_ASM_PATH_SWITCH] == null)
            {
                throw new RahRowRagee(
                          $"the switch '{Settings.INVOKE_ASM_PATH_SWITCH}' could not be " +
                          $"parsed from cmd line arg \n{string.Join(" ", _args)}");
            }
            if (!argHash.ContainsKey(Settings.INVOKE_FULL_TYPE_NAME_SWITCH) ||
                argHash[Settings.INVOKE_FULL_TYPE_NAME_SWITCH] == null)
            {
                throw new RahRowRagee(
                          $"the switch '{Settings.INVOKE_FULL_TYPE_NAME_SWITCH}' could not " +
                          $"be parsed from cmd line arg \n{string.Join(" ", _args)}");
            }

            ResolveDependencies = argHash.ContainsKey(Settings.INVOKE_RESOLVE_ALL_DEPENDENCIES) &&
                                  string.Equals(argHash[Settings.INVOKE_RESOLVE_ALL_DEPENDENCIES].ToString(),
                                                bool.TrueString,
                                                StringComparison.OrdinalIgnoreCase);

            AsmPath = argHash[Settings.INVOKE_ASM_PATH_SWITCH].ToString();
            if (!File.Exists(AsmPath))
            {
                throw new RahRowRagee($"There is no assembly at '{AsmPath}'.");
            }

            NfConfig.AssemblySearchPaths.Add(Path.GetDirectoryName(AsmPath));
            Assembly = NfConfig.UseReflectionOnlyLoad
                ? Asm.NfReflectionOnlyLoadFrom(AsmPath)
                : Asm.NfLoadFrom(AsmPath);
            if (Assembly == null)
            {
                throw new RahRowRagee(
                          $"The assembly at '{AsmPath}' could not be loaded, " +
                          $"see the log at '{Asm.ResolveAsmLog}' for more info.");
            }

            TypeName = argHash[Settings.INVOKE_FULL_TYPE_NAME_SWITCH].ToString();

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting("NoFuture.ToolsCustomTools.InvokeNfTypeName");
        }
Ejemplo n.º 8
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            MyParameters = new DomainParameters
            {
                AppDomain = argHash.ContainsKey(Engine.APP_DOMAIN_SWITCH) ? $"{argHash[Engine.APP_DOMAIN_SWITCH]}"
                    : ConfigFileAppDomain,
                AspListenerPrefix = argHash.ContainsKey(Engine.ASP_LISTENER_SWITCH) ?
                                    $"{argHash[Engine.ASP_LISTENER_SWITCH]}"
                    : ConfigFileAspHttp
            };
            if (string.IsNullOrWhiteSpace(MyParameters.AppDomain) || !System.IO.Directory.Exists(MyParameters.AppDomain))
            {
                throw new ItsDeadJim($"The '{Engine.APP_DOMAIN_SWITCH}' value is missing or invalid.");
            }

            if (string.IsNullOrWhiteSpace(MyParameters.AspListenerPrefix))
            {
                throw new ItsDeadJim($"The '{Engine.ASP_LISTENER_SWITCH}' value is missing or invalid");
            }
        }
Ejemplo n.º 9
0
        protected override void ParseProgramArgs()
        {
            var argHash = ConsoleCmd.ArgHash(_args);

            if (argHash == null || argHash.Keys.Count <= 0)
            {
                var msg = $"could not parse cmd line arg \n{string.Join(" ", _args)}";
                throw new ItsDeadJim(msg);
            }

            NfConfig.CustomTools.InvokeNfTypeName = SysCfg.GetAppCfgSetting(AppSettingKeyNames.NF_TYPE_NAME_EXE);

            if (!argHash.ContainsKey(InvokeStoredProcManager.HBM_STORED_PROX_DIR_SWITCH) ||
                argHash[InvokeStoredProcManager.HBM_STORED_PROX_DIR_SWITCH] == null)
            {
                var msg =
                    $"the switch '{InvokeStoredProcManager.HBM_STORED_PROX_DIR_SWITCH}' could not " +
                    $"be parsed from cmd line arg \n{string.Join(" ", _args)}";
                throw new ItsDeadJim(msg);
            }

            Settings.HbmStoredProcsDirectory = argHash[InvokeStoredProcManager.HBM_STORED_PROX_DIR_SWITCH].ToString();

            if (!argHash.ContainsKey(InvokeStoredProcManager.CONNECTION_STR_SWITCH) ||
                argHash[InvokeStoredProcManager.CONNECTION_STR_SWITCH] == null)
            {
                var msg =
                    $"the switch '{InvokeStoredProcManager.CONNECTION_STR_SWITCH}' could not " +
                    $"be parsed from cmd line arg \n{string.Join(" ", _args)}";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }

            if (!argHash.ContainsKey(InvokeStoredProcManager.FILE_PATH_SWITCH) ||
                argHash[InvokeStoredProcManager.FILE_PATH_SWITCH] == null)
            {
                var msg =
                    $"the switch '{InvokeStoredProcManager.FILE_PATH_SWITCH}' could not " +
                    $"be parsed from cmd line arg \n{string.Join(" ", _args)}";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }

            if (!argHash.ContainsKey(InvokeStoredProcManager.SEND_MESSAGES_BACK_ON_SOCKET) ||
                argHash[InvokeStoredProcManager.SEND_MESSAGES_BACK_ON_SOCKET] == null)
            {
                var msg =
                    $"the switch '{InvokeStoredProcManager.SEND_MESSAGES_BACK_ON_SOCKET}' could not " +
                    $"be parsed from cmd line arg \n{string.Join(" ", _args)}";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }


            if (
                !bool.TryParse(argHash[InvokeStoredProcManager.SEND_MESSAGES_BACK_ON_SOCKET].ToString(),
                               out _sendSocketMessages))
            {
                var msg =
                    "could not parse the value 'True' nor 'False' from " +
                    $"the '{InvokeStoredProcManager.SEND_MESSAGES_BACK_ON_SOCKET}' switch " +
                    $"using the cmd line arg \n{string.Join(" ", _args)}";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }

            ConnectionString = argHash[InvokeStoredProcManager.CONNECTION_STR_SWITCH].ToString();
            SpmFilePath      = argHash[InvokeStoredProcManager.FILE_PATH_SWITCH].ToString();

            if (!File.Exists(SpmFilePath))
            {
                var msg = $"bad path or file name '{SpmFilePath}'";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }

            if (!SortingContainers.StoredProcMetadata.TryDeserializeFromDisk(SpmFilePath, out _myProcMetadata))
            {
                var msg =
                    $"could not deserialize the file \n'{SpmFilePath}' " +
                    $"into the type \n'{typeof(SortingContainers.StoredProcMetadata).FullName}'";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }

            if (string.IsNullOrWhiteSpace(_myProcMetadata.ProcName))
            {
                var msg = "there isn't a stored proc name in " +
                          $"the deserialized file at \n'{SpmFilePath}'";
                Settings.WriteToStoredProcLog(msg);
                throw new ItsDeadJim(msg);
            }
        }
Ejemplo n.º 10
0
        protected override void ParseProgramArgs()
        {
            //get and test the cmd line arg key\values
            var argHash = ConsoleCmd.ArgHash(_args);

            if (argHash == null || argHash.Keys.Count <= 0)
            {
                throw new RahRowRagee($"could not parse cmd line arg \n{string.Join(" ", _args)}");
            }

            if (!argHash.ContainsKey(Settings.INVOKE_ASM_PATH_SWITCH) ||
                argHash[Settings.INVOKE_ASM_PATH_SWITCH] == null)
            {
                throw new RahRowRagee(
                          $"the switch '{Settings.INVOKE_ASM_PATH_SWITCH}' could not " +
                          $"be parsed from cmd line arg \n{string.Join(" ", _args)}");
            }

            AsmPath = argHash[Settings.INVOKE_ASM_PATH_SWITCH].ToString();
            if (!File.Exists(AsmPath))
            {
                throw new RahRowRagee($"There is no assembly at '{AsmPath}'.");
            }

            NfConfig.AssemblySearchPaths.Add(Path.GetDirectoryName(AsmPath));

            Assembly = NfConfig.UseReflectionOnlyLoad
                ? Asm.NfReflectionOnlyLoadFrom(AsmPath)
                : Asm.NfLoadFrom(AsmPath);
            GraphText      = string.Empty;
            OutputFileName = string.Empty;

            if (Assembly == null)
            {
                throw new RahRowRagee(
                          $"The assembly at '{AsmPath}' could not " +
                          $"be loaded, see the log at '{Asm.ResolveAsmLog}' for more info.");
            }
            LimitOn      = argHash[Settings.INVOKE_GRAPHVIZ_FLATTENED_LIMIT_TYPE];
            DisplayEnums = argHash.ContainsKey(Settings.INVOKE_GRAPHVIZ_DISPLAY_ENUMS);
            DiagramType  = argHash[Settings.INVOKE_GRAPHVIZ_DIAGRAM_TYPE].ToString();
            if (DiagramType == Settings.ASM_OBJ_GRAPH_DIAGRAM || DiagramType == Settings.ASM_ADJ_GRAPH)
            {
                WithNamespaceOutlines = argHash.ContainsKey(Settings.ASM_OBJ_OUTLINE_NS);
                return;
            }

            if (!argHash.ContainsKey(Settings.INVOKE_FULL_TYPE_NAME_SWITCH) ||
                argHash[Settings.INVOKE_FULL_TYPE_NAME_SWITCH] == null)
            {
                throw new RahRowRagee(
                          $"the switch '{Settings.INVOKE_FULL_TYPE_NAME_SWITCH}' could not " +
                          $"be parsed from cmd line arg \n{string.Join(" ", _args)}");
            }
            TypeName = argHash[Settings.INVOKE_FULL_TYPE_NAME_SWITCH].ToString();

            MaxDepth = argHash.ContainsKey(Settings.INVOKE_GRAPHVIZ_FLATTEN_MAX_DEPTH)
                ? ResolveInt(argHash.ContainsKey(Settings.INVOKE_GRAPHVIZ_FLATTEN_MAX_DEPTH).ToString())
                       .GetValueOrDefault(FlattenLineArgs.MAX_DEPTH)
                : FlattenLineArgs.MAX_DEPTH;

            if (string.IsNullOrWhiteSpace(DiagramType) || !_implementedDiagrams.Contains(DiagramType))
            {
                throw new RahRowRagee("choose a valid type of diagram listed in the help ");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Handles a specific set of formatted runtime commands as printed in <see cref="RuntimeHelp"/>
        /// </summary>
        /// <param name="ut">User entered text</param>
        protected internal void RtCommands(string ut)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(ut))
                {
                    return;
                }
                if (!ut.StartsWith(NfConfig.CmdLineArgSwitch))
                {
                    return;
                }

                var cmds      = ut.Split(' ');
                var rtArgHash = ConsoleCmd.ArgHash(cmds);

                if (rtArgHash.ContainsKey(ASSIGN_REGEX_PATTERN_RT_CMD))
                {
                    var regexPattern = rtArgHash[ASSIGN_REGEX_PATTERN_RT_CMD];
                    if (string.IsNullOrWhiteSpace(regexPattern?.ToString()))
                    {
                        return;
                    }
                    AssemblyNameRegexPattern = regexPattern.ToString().Trim();
                    PrintToConsole($"AssemblyNameRegexPattern = {AssemblyNameRegexPattern}");
                }
                if (rtArgHash.ContainsKey(RESOLVE_TOKEN_ID_CMD))
                {
                    var tokenCmd = rtArgHash[RESOLVE_TOKEN_ID_CMD];
                    if (string.IsNullOrWhiteSpace(tokenCmd?.ToString()))
                    {
                        return;
                    }
                    var tokenCmdStr = tokenCmd.ToString().Trim();
                    if (!Regex.IsMatch(tokenCmdStr, @"^[0-9]\.([0-9]+|0x[0-9a-fA-F]+)$"))
                    {
                        return;
                    }
                    var asmIdxStr  = tokenCmdStr.Split('.')[0];
                    var tokenIdStr = tokenCmdStr.Split('.')[1];

                    int tokenId;
                    int asmIdx;
                    if (!int.TryParse(asmIdxStr, out asmIdx))
                    {
                        return;
                    }
                    if (Regex.IsMatch(tokenIdStr, "0x[0-9a-fA-F]+"))
                    {
                        tokenIdStr = tokenIdStr.Substring(2);
                        if (!int.TryParse(tokenIdStr, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out tokenId))
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (!int.TryParse(tokenIdStr, out tokenId))
                        {
                            return;
                        }
                    }

                    var mdt = new MetadataTokenId {
                        Id = tokenId, RslvAsmIdx = asmIdx
                    };
                    MetadataTokenName tokenName;
                    if (!_utilityMethods.ResolveSingleTokenName(mdt, out tokenName))
                    {
                        PrintToConsole($"could not resolve name {ut}");
                        return;
                    }
                    PrintToConsole(tokenName.Name);

                    if (!tokenName.IsMethodName())
                    {
                        return;
                    }
                    var resolveDepth = 0;
                    var st           = new Stack <MetadataTokenId>();
                    var msg          = new StringBuilder();
                    var tTokensIds   = new GetTokenIds(this);
                    tTokensIds.ResolveCallOfCall(mdt, ref resolveDepth, st, msg);
                    if (mdt.Items == null || mdt.Items.Length <= 0)
                    {
                        PrintToConsole("ResolveCallOfCall returned nothing");
                        PrintToConsole(msg.ToString(), false);
                        return;
                    }
                    Console.WriteLine();
                    PrintToConsole(MetadataTokenId.Print(mdt), false);
                }
            }
            catch (Exception ex)
            {
                PrintToConsole("console entry error");
                PrintToConsole(ex);
            }
        }