コード例 #1
0
        public override string calculate(string input)
        {
            String        output = "";
            List <String> lines  = splitTextToLines(input);

            String oldStart  = variables[0].Trim();
            String oldLength = variables[1].Trim();
            String newStart  = variables[2].Trim();
            String newEnd    = variables[3].Trim();

            InnerReadNode innerReadValue = new InnerReadNode();

            innerReadValue.parseArgs(QUOTES);

            foreach (String line in lines)
            {
                if (line.Contains(oldStart) && line.Contains(oldLength))
                {
                    List <String> attributes = splitTextToAttributes(line);

                    String startAttribute  = getAttribute(attributes, oldStart);
                    String lengthAttribute = getAttribute(attributes, oldLength);

                    int startVal, endVal, lengthVal;

                    startVal  = int.Parse(innerReadValue.calculate(startAttribute).Trim());
                    lengthVal = int.Parse(innerReadValue.calculate(lengthAttribute).Trim());
                    endVal    = startVal + lengthVal;

                    String newStartReplace = newStart + "=\"" + startVal + "\"";
                    String newEndReplace   = newEnd + "=\"" + endVal + "\"";

                    String updatedLine = line.Replace(startAttribute, newStartReplace).Replace(lengthAttribute, newEndReplace);
                    output += updatedLine + Environment.NewLine;
                }
                else
                {
                    output += line + Environment.NewLine;
                }
            }

            return(output);
        }
コード例 #2
0
        static LogProcessor()
        {
            ConfigFile.loadConfig();

            argReader.parseArgs(new String[] { "(", ")" });

            allNodes                 = new Dictionary <string, ProgramNode>();
            allBlockNodes            = new Dictionary <string, BlockNode>();
            allProgramNodeInterfaces = new List <ProgramNodeInterface>();
            allConditions            = new Dictionary <string, Condition>();
            specialCharacters        = new Dictionary <string, string>();

            addAllNode(new InnerReadNode());
            addAllNode(new FilterNode());
            addAllNode(new FilterExclude());
            addAllNode(new WordSearch());
            addAllNode(new DirectoryLoad());
            addAllNode(new LoadFiles());
            addAllNode(new ProcessFiles());
            addAllNode(new NextFile());

            addAllNode(new SetOutput());
            addAllNode(new GetFileName());
            addAllNode(new RemoveDuplicates());
            //Register Code
            addAllNode(new ReadFromRegister());
            addAllNode(new WriteToRegister());
            addAllNode(new VariableTransform());
            addAllNode(new RegisterFindAndReplace());
            addAllNode(new RegisterFilter());

            addAllNode(new FindPlusLines());
            addAllNode(new LineInstanceCount());
            addAllNode(new ReplaceCount());
            addAllNode(new ReplaceIn());
            addAllNode(new StartLineWith());
            addAllNode(new EndLineWith());
            addAllNode(new LineTrim());
            addAllNode(new CSVCombine());
            addAllNode(new CallFunctionBlock());
            addAllNode(new GetWordInLine());
            addAllNode(new SyntaxParse());
            addAllNode(new LoadProgram());

            //xml
            addAllNode(new ReadXML());
            addAllNode(new GetAllElements());
            addAllNode(new GetParentNode());

            //Code

            addAllNode(new MultilineFindAndReplace());
            addAllNode(new IfStatement());
            addAllNode(new FunctionalBlock());
            addAllNode(new SimpleForeachReplace());
            addAllNode(new ConditionalForeachReplace());


            //conditions
            addCondition(new Contains());
            addCondition(new ContainsAny());


            //special characters
            specialCharacters.Add(CLOSING_PARENTHSES, ")");
            specialCharacters.Add(COMMA, ",");
            specialCharacters.Add(SPACE, " ");
            specialCharacters.Add(TAB, "\t");
            specialCharacters.Add(SINGLE_QUOTE, "'");
            specialCharacters.Add(NEWLINE, Environment.NewLine);
        }