public static UsersManager LoadUsers() { using (var stream = System.IO.File.OpenRead(usersPersistFile)) { var formatter = GetFormatter(); var users = (BindingList <User>)formatter.Deserialize(stream); var manager = new UsersManager(); manager.usersCollection = users; return(manager); } }
public static UsersManager LoadUsers() { using (var stream = System.IO.File.OpenRead(usersPersistFile)) { var formatter = GetFormatter(); var users = (BindingList<User>)formatter.Deserialize(stream); var manager = new UsersManager(); manager.usersCollection = users; return manager; } }
public OptionsForm(UsersManager mnger) { if (mnger == null) throw new ArgumentNullException("mnger", "mnger is null."); InitializeComponent(); this.cameraConfigurer1.Add.Click += this.Add_Click; this.cameraConfigurer1.Delete.Click += new EventHandler(Delete_Click); this.Shown += this.OptionsForm_Shown; this.userManager = mnger; }
public void SerialDeserialTest() { UsersManager mnger = new UsersManager(); var newUser = new User("admin", "admin"); newUser.Roles.Add("admin"); mnger.AddUser(newUser); mnger.Save(); UsersManager saved = UsersManager.LoadUsers(); foreach (var user in saved.Users) { Trace.Write(string.Format("name: {0}, pwd: {1}", user.Name, user.Password)); } Assert.IsNotNull(saved["admin"]); Assert.IsNull(saved["abc"]); }