public void CreateDtoClass() { var padding = " "; SourceAsLines.AddRange(Source.Split( new[] { Environment.NewLine }, StringSplitOptions.None )); foreach (var l in SourceAsLines) { bool result = false; MakeNames(l, ""); if (MakeDtoLine(l, "string")) { result = true; } if (MakeDtoLine(l, "double")) { result = true; } if (MakeDtoLine(l, @"double?")) { result = true; } if (MakeDtoLine(l, "int")) { result = true; } if (MakeDtoLine(l, @"int?")) { result = true; } if (MakeDtoLine(l, "DateTime")) { result = true; } if (MakeDtoLine(l, @"DateTime?")) { result = true; } if (MakeDtoLine(l, "bool")) { result = true; } if (MakeDtoLine(l, @"bool?")) { result = true; } if (MakeDtoLine(l, @"ComboBoxValue")) { result = true; } if (MakeDtoLine(l, @"CATPlotObj")) { result = true; } if (MakeDtoLine(l, @"CATPlotObjBool")) { result = true; } if (l.Contains("public class")) { TargetLines.Add("public class " + OldName + " : BaseDto, IRecord "); } else { if (l.Trim() != "}") { if (l.Trim() != "{") { TargetLines.Add(padding + l.TrimStart()); } else { TargetLines.Add(l.TrimStart()); } } } } TargetLines.AddRange(CreateCloneMethod(this.CloneLines, OldName)); TargetLines.Add("}"); }
public void CreateEditClass() { SourceAsLines.AddRange(Source.Split( new[] { Environment.NewLine }, StringSplitOptions.None )); var constructorCreated = false; foreach (var l in SourceAsLines) { bool result = false; MakeNames(l, "Edit"); if (!constructorCreated) { constructorCreated = MakeConstructor(OldName, NewName); continue; } if (l.Replace(" ", "") == "{") { // TargetLines.Add("{"); result = true; } if (l.Replace(" ", "") == "}") { result = true; } if (MakePropertyLine(l, "string", @"Value = string.Empty, Original = string.Empty")) { result = true; } if (MakePropertyLine(l, "double", @"Value = 0.0, Original = 0.0")) { result = true; } if (MakePropertyLine(l, @"double?", @"Value = 0.0, Original = 0.0")) { result = true; } if (MakePropertyLine(l, "int", @"Value = 0, Original = 0")) { result = true; } if (MakePropertyLine(l, @"int?", @"Value = 0, Original = 0")) { result = true; } if (MakePropertyLine(l, "DateTime", @"Value = DateTime.Today,Original = DateTime.Today")) { result = true; } if (MakePropertyLine(l, @"DateTime?", @"Value = DateTime.Today,Original = DateTime.Today")) { result = true; } if (MakePropertyLine(l, "bool", @"Value = false, Original = false")) { result = true; } if (MakePropertyLine(l, @"bool?", @"Value = false, Original = false")) { result = true; } if (MakePropertyLine(l, @"ComboBoxValue", @"Value = null, Original = null")) { result = true; } if (MakePropertyLine(l, @"CATPlotObj", @"Value = null, Original = null")) { result = true; } if (MakePropertyLine(l, @"CATPlotObjBool", @"Value = null, Original = null")) { result = true; } if (!result) { TargetLines.Add(l); } } TargetLines.Add(""); TargetLines.Add(""); TargetLines.Add("public int RecordId => Id.Value;"); TargetLines.Add(""); TargetLines.Add(""); TargetLines.AddRange(CreateConvertToDto(ConvertToDtoLines, OldName, "Edit")); TargetLines.Add(""); TargetLines.Add(""); TargetLines.AddRange(CreateMakeFromExistingMethod(MakeLines, NewName)); TargetLines.Add(""); TargetLines.Add(""); TargetLines.AddRange(CreateMakeMethod(MakeLines, OldName, true)); TargetLines.Add(""); TargetLines.Add(""); TargetLines.AddRange(CreateEditResetChangesMethod(ResetLines, OldName)); TargetLines.Add(""); TargetLines.Add(""); TargetLines.AddRange(CreateEditMakeCollectionMethod()); TargetLines.Add("}//endofclass"); }