class Generator { private static string[] Split(string str) { string[] flds = str.Split(new Char[] { ',' }); return flds; } private static string AddGetSet(string fld) { StringBuilder sb = new StringBuilder(); sb.Append("public string "); sb.Append(fld); sb.Append(" {get; private set;}"); return sb.ToString(); } public static string Generate(string fields) { string[] flds = Split(fields); StringBuilder sb = new StringBuilder(); foreach (var fld in flds) { sb.Append(AddGetSet(fld.Trim())); sb.Append(System.Environment.NewLine); } return sb.ToString(); } } public class GenUtil { public static string GetTimePart() { string sep = "."; DateTime dt = DateTime.Now; string sMonth = dt.Month.ToString(); string sDay = dt.Day.ToString(); string sHour = dt.Hour.ToString(); string sMin = dt.Minute.ToString(); string timePart = sMonth + sep + sDay + sep + sHour + sep + sMin; return timePart; } }
Generate Properties
Accepts a comma delimited string of property names
Subscribe to:
Posts (Atom)
No comments:
Post a Comment