private bool MakePropertyLine(string currentLine, string searchToken, string defaultValue) { string padding = " "; currentLine = currentLine.Replace(@"?", "questionmark"); searchToken = searchToken.Replace(@"?", "questionmark"); if (currentLine.Contains("public " + searchToken + " ")) { Regex regex = new Regex(@"(?<=\bpublic " + searchToken + @" )(\w+)"); Match match = regex.Match(currentLine); if (match.Success) { PropertyRecord.Add(match.Value); var neLine = padding + @"public Property<" + searchToken + "> " + match.Value + " { get; set; } = new Property<" + searchToken + ">(){" + defaultValue + "};"; neLine = neLine.Replace("questionmark", @"?"); searchToken = searchToken.Replace("questionmark", @"?"); TargetLines.Add(neLine); //this.ID = Property<int>.Make(test.ID); var makeLine = padding + @"this." + match.Value + " = Property<" + searchToken + ">.Make(test." + match.Value + ");"; MakeLines.Add(makeLine); //ConvertToDtoLines var convertLine = padding + "returnVal." + match.Value + " = " + match.Value + ".Value;"; ConvertToDtoLines.Add(convertLine); var cloneLines = padding + "" + match.Value + " = this." + match.Value + ";"; CloneLines.Add(cloneLines); var resetLine = padding + "" + match.Value + ".Revert();"; ResetLines.Add(resetLine); return(true); } } return(false); }
private bool MakeListLine(string currentLine, string searchType) { string padding = " "; currentLine = currentLine.Replace(@"?", "questionmark"); searchType = searchType.Replace(@"?", "questionmark"); if (currentLine.Contains("public " + searchType + " ")) { Regex regex = new Regex(@"(?<=\bpublic " + searchType + @" )(\w+)"); Match match = regex.Match(currentLine); if (match.Success) { PropertyRecord.Add(match.Value); var neLine = padding + @"public " + searchType + " " + match.Value + " { get => _current." + match.Value + "; set { _current." + match.Value + " = value; OnPropertyChanged(); } }"; neLine = neLine.Replace("questionmark", @"?"); searchType = searchType.Replace("questionmark", @"?"); TargetLines.Add(neLine); //public bool Completed { get => _current.Completed; set { _current.Completed = value; OnPropertyChanged(); } } MakeLines.Add(padding + @"_original." + match.Value + " = test." + match.Value + ";"); MakeLines.Add(padding + @"_current." + match.Value + " = test." + match.Value + ";"); var convertLine = padding + "returnVal." + match.Value + " = this." + match.Value + ";"; ConvertToDtoLines.Add(convertLine); var cloneLines = padding + "" + match.Value + " = this." + match.Value + ";"; var resetLine = padding + "" + match.Value + ".Revert();"; CloneLines.Add(cloneLines); return(true); } } return(false); }