예제 #1
0
        public UserAccount(ulong id, IDataStorage storage)
        {
            this.ID  = id;
            _storage = (InMemoryStorage)storage;
            _storage.Initialize(this, ID.ToString(), UserAccounts.UsersFolder);
            var User = _storage.RestoreObject <UserAccount>(ID.ToString());

            if (User != null)
            {
                this.Points     = User.Points;
                this.Xp         = User.Xp;
                this.Reputation = User.Reputation;
                _storage.StoreObject();
                Utilities.Log($"UserAccount [{ID}]", "User restored from storage.", LogSeverity.Verbose);
            }
            else
            {
                _storage.StoreObject();
                Utilities.Log($"UserAccount [{ID}]", "New user created.", LogSeverity.Verbose);
            }
        }