// ReSharper disable once RedundantAssignment public static void AddStudent(IList <Student> students, out Student currentStudent, ref CreationStudentWindow window) { Contract.Assert(students != null, "students != null"); window = new CreationStudentWindow { Owner = Application.Current.MainWindow }; if (window.ShowDialog() == true) { var newStudent = Activator.CreateInstance(window.Result) as Student; students.Add(newStudent); currentStudent = newStudent; } else { currentStudent = null; } }
public static void GetNewStudentType(string content, CreationStudentWindow window) { Contract.Assert(window != null, "window != null"); if (content == Properties.Resources.BachelorFriendlyName) { window.Result = typeof(Bachelor); } else if (content == Properties.Resources.MasterFriendlyName) { window.Result = typeof(Master); } else { throw new ArgumentException(Properties.Resources.UnexpectedStudentType); } window.DialogResult = true; window.Close(); }