コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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;

            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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"]);
        }