Ejemplo n.º 1
0
        public bool IsRuleApplicable(string sourceCode, ConversionParameters conversionParameters)
        {
            // Get first Line
            var regex = new Regex(RuleApplicablePattern);

            return(regex.IsMatch(sourceCode));
        }
Ejemplo n.º 2
0
        private ConversionParameters GetConversionParamters(string sourceCode)
        {
            ConversionParameters conversionParameters = new ConversionParameters();

            var regex   = new Regex(RegexManger.NoOfMethodsPattern);
            var matches = regex.Matches(sourceCode);

            if (matches.Count == 0)
            {
                conversionParameters.SourceCodeType = SourceCodeType.LinesOfCode;
            }
            else if (matches.Count == 1)
            {
                conversionParameters.SourceCodeType = SourceCodeType.Method;
                if (Regex.IsMatch(sourceCode, RegexManger.ProcedurePattern))
                {
                    conversionParameters.VoidMethodBuilder = new VoidMethodBuilder();
                }
                else
                {
                    conversionParameters.MethodBuilder = new MethodBuilder();
                }
            }
            else
            {
                conversionParameters.SourceCodeType = SourceCodeType.File;
            }

            return(conversionParameters);
        }
Ejemplo n.º 3
0
        public string ApplyConversionRule(string sourceCode, ConversionParameters conversionParamters)
        {
            Logger.AddLog(String.Format("ApplyingRule Name: {0}-Type: {1}-Priority: {2}", RuleName, RuleType, RuleTypePriority));

            var match = Regex.Match(sourceCode, RuleApplicablePattern);

            if (match.Success)
            {
                Logger.AddLog("SourceCode:" + match.Value);

                var regex         = new Regex(RuleApplicablePattern);
                var convertedCode = regex.Replace(match.Value, ConversionRule.ReplacePattern);
                conversionParamters.AddConvertedCode(convertedCode);

                Logger.AddLog("ConvertedCode:" + convertedCode);

                return(sourceCode.Remove(match.Index, match.Length));
            }

            Logger.AddLog("MatchFailed");
            return(sourceCode);
        }