// Build back a UserType List with the grid content List <UserType> GetEdition() { List <UserType> UserTypeList = new List <UserType>(); UserType? ut = null; foreach (DataGridViewRow dtr in AttGridView.Rows) { try { if ((dtr.Cells[0].Value != null) && (dtr.Cells[0].Value.ToString() != "")) { if (ut != null) { UserTypeList.Add(ut.Value); } ut = new UserType(dtr.Cells[0].Value.ToString()); } else if ((dtr.Cells[1].Value != null) && (dtr.Cells[1].ToString() != "")) { UserAttribut ua = new UserAttribut(dtr.Cells[1].Value.ToString(), (CIPType)dtr.Cells[2].Value); ut.Value.AddAtt(ua); } } catch { } } if (ut != null) { UserTypeList.Add(ut.Value); } return(UserTypeList); }
public static List <UserType> LoadUserTypes(string filename) { List <UserType> t = new List <UserType>(); UserType?ut = null; int line = 0; try { StreamReader sr = new StreamReader(filename); while (!sr.EndOfStream) { string content = sr.ReadLine(); line++; string[] attdescr = content.Split(';'); if (attdescr.Length == 1) { if (ut != null) { t.Add(ut.Value); } ut = new UserType(attdescr[0]); } else { CIPType ciptype; if (Enum.TryParse <CIPType>(attdescr[1], out ciptype) == true) { UserAttribut at = new UserAttribut(attdescr[0], ciptype); ut.Value.AddAtt(at); } else { Trace.TraceError("Error in UserTypeFile, line " + line.ToString()); } } } if (ut != null) { t.Add(ut.Value); } sr.Close(); } catch { Trace.TraceError("Error in UserTypeFile, line " + line.ToString()); } return(t); }
public void AddAtt(UserAttribut ua) { Lattr.Add(ua); }