public bool IsRuleApplicable(string sourceCode, ConversionParameters conversionParameters) { // Get first Line var regex = new Regex(RuleApplicablePattern); return(regex.IsMatch(sourceCode)); }
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); }
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); }