예제 #1
0
        public void AddUser(string login, string password)
        {
            UserModel createdUser = new UserModel(login, password);

            Users.Add(createdUser.Login, createdUser);
            UserAdded?.Invoke(createdUser);
        }
예제 #2
0
        public void Init(SiteType siteType)
        {
            var userStore = _dict[siteType];

            userStore.UserAdded += (s, e) => UserAdded?.Invoke(s, e);
            userStore.Init();
        }
 public void AddUser(AddUserRequest request)
 {
     BroadcastAsync($"User {request.Name} joined").GetAwaiter().GetResult();
     UserAdded?.Invoke(this, new UserAddedEventArgs {
         UserName = request.Name
     });
 }
예제 #4
0
 private void AddUser(IUser userInfo)
 {
     if (_cacheDict.TryAdd(userInfo.UserId, userInfo))
     {
         UserAdded?.Invoke(this, userInfo);
     }
 }
예제 #5
0
파일: Chat.cs 프로젝트: mkantz84/Chat
 private void OnUserAdded(User user)
 {
     if (UserAdded == null)
     {
         return;
     }
     UserAdded.Invoke(user);
 }
예제 #6
0
 public virtual void Insert(int index, string Username)
 {
     if (generic.IndexOf(Username) == -1)
     {
         generic.Insert(index, Username);
         UserAdded?.Invoke(null, Username);
     }
 }
예제 #7
0
 public virtual void Add(string Username)
 {
     if (generic.IndexOf(Username) == -1)
     {
         generic.Add(Username);
         UserAdded?.Invoke(null, Username);
     }
 }
예제 #8
0
 public void AddUser(ProcessUser user)
 {
     if (Contract.Users.Any(u => user.Id == u.Id))
     {
         throw new DuplicateIdException($"Contract already contains user id {user.Id}");
     }
     Contract.Users.Add(user);
     UserAdded?.Invoke(this, user);
 }
예제 #9
0
        public ProcessUser AddNewUser()
        {
            var user = new ProcessUser {
                Id = Guid.NewGuid().ToString()
            };

            Contract.Users.Add(user);
            UserAdded?.Invoke(this, user);
            return(user);
        }
예제 #10
0
        public void Load(Stream stream)
        {
            _Users = Serializer.Deserialize <HashSet <User> >(stream);

            foreach (var user in _Users)
            {
                user.SetUserDataAndRaiseEvent(RaiseChangedEvent, this);
                UserAdded?.Invoke(this, new UserAddedEventArgs(user));
            }
        }
예제 #11
0
        public void AddUser(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            users.Add(user);

            UserAdded?.Invoke(this, new UserEventArgs(user, UserChangeType.Added));
        }
예제 #12
0
 public virtual void AddRange(string[] Usernames)
 {
     for (int i = 0; i < Usernames.Length; i++)
     {
         if (!this.Exists(Usernames[i]))
         {
             generic.Add(Usernames[i]);
             UserAdded?.Invoke(null, Usernames[i]);
         }
     }
 }
        public static TwitchUser AddUser(string username)
        {
            TwitchUser twitchUser = new TwitchUser(username);

            username = twitchUser.Username.ToUpper();
            if (HasUser(username))
            {
                return(users[username]);
            }
            users.Add(username, twitchUser);
            OnUserAdded?.Invoke(twitchUser);
            return(twitchUser);
        }
예제 #14
0
 public void AddUser(ProjectMember user)
 {
     if (Project == null)
     {
         return;
     }
     if (Project.ProjectMembersNotInRepository == null)
     {
         Project.ProjectMembersNotInRepository = new List <ProjectMember>();
     }
     Project.ProjectMembersNotInRepository.Add(user);
     UserAdded?.Invoke(user);
 }
예제 #15
0
        public void AddUser(string LastName, string FirstName, DateTime Birthdate,
                            DateTime TimeAdded, string City, string Address, string PhoneNumber,
                            string Gender, string Email)
        {
            User user = User.Fabric();

            user.LastName    = LastName;
            user.FirstName   = FirstName;
            user.Birthdate   = Birthdate;
            user.TimeAdded   = TimeAdded;
            user.City        = City;
            user.Address     = Address;
            user.PhoneNumber = PhoneNumber;
            user.Gender      = Gender;
            user.Email       = Email;
            this.Book.Add(user);
            UserAdded.Invoke();
        }
예제 #16
0
        public ChatMessage AddMessage(string username, string message)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentException("No username specified");
            }

            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException("No message specified");
            }

            username = username.Trim();

            var now = DateTime.UtcNow;

            var m = new ChatMessage {
                Username = username,
                Message  = message.Trim(),
                UtcTime  = now,
            };

            messages.Enqueue(m);
            while (messages.Count > 32)
            {
                messages.TryDequeue(out var _);
            }

            MessageAdded?.Invoke(this, new MessageEventArgs(m));

            if (!users.ContainsKey(username))
            {
                var u = new ChatUser {
                    Username = username,
                };
                if (users.TryAdd(username, u))
                {
                    UserAdded?.Invoke(this, new UserEventArgs(u));
                }
            }

            return(m);
        }
예제 #17
0
        public void AddUser(int id, string name, Dictionary <string, string> prms = null)
        {
            if (prms == null)
            {
                prms = new Dictionary <string, string>();
            }

            foreach (var kvp in DefaultValues)
            {
                if (!prms.ContainsKey(kvp.Key))
                {
                    prms.Add(kvp.Key, kvp.Value.ToString());
                }
            }

            var newuser = new User(id, name, RaiseChangedEvent, this, prms);

            _Users.Add(newuser);
            UserAdded?.Invoke(this, new UserAddedEventArgs(newuser));
        }
예제 #18
0
        public bool AddUser(User user)
        {
            try
            {
                var isUserAdded = false;

                if (_addressBook == null)
                {
                    throw new NullReferenceException("Книга не створена! ");
                }
                if (user == null)
                {
                    throw new NullReferenceException("Немає користувача! ");
                }

                UserAdded?.Invoke("debug", "Почався запис користувача в адресну книгу");

                if (IsUserInAdressBook(user, _addressBook)) //провірка на наявність юзера в книзі
                {
                    UserAdded?.Invoke("warning", "користувач з такими данними вже є!");
                }
                if (!IsUserInAdressBook(user, _addressBook)) //добавиться тільки тоді , коли не співпадає
                {
                    _addressBook.Add(user);
                    UserAdded?.Invoke("info", string.Format("Був доданий користувач " + user.FirstName + " " + user.LastName));
                    UserAdded?.Invoke("debug", "Закінчився запис користувача в адресну книгу");
                    isUserAdded = true;
                }
                return(isUserAdded);
            }
            catch (NullReferenceException ex)
            {
                UserAdded?.Invoke("error", string.Format(ex.Message + "StackTrace :" + ex.StackTrace));
                return(false);
            }
            catch (Exception ex)
            {
                UserAdded?.Invoke("error", string.Format(ex.Message + "StackTrace :" + ex.StackTrace));
                return(false);
            }
        }
        public IUser GetUser(string userId)
        {
            //UserInfoのインスタンスは一つのuserIdにつき一つだけ作る。
            if (_cacheDict.ContainsKey(userId))
            {
                return(_cacheDict[userId]);
            }

            //TODO:最初にデータベース上のユーザ情報を全てメモリに読み込むべきでは?その方が絶対に効率がいい。
            if (TryGet(userId, out IUser userInfo))
            {
                _cacheDict.TryAdd(userId, userInfo);
                return(userInfo);
            }

            //キャッシュにもデータベースにも無いので、新たに作成
            userInfo = new UserTest(userId);
            _cacheDict.TryAdd(userId, userInfo);
            UserAdded?.Invoke(this, userInfo);
            return(userInfo);
        }
예제 #20
0
 private void UserAddedEvent()
 {
     UserAdded?.Invoke(this, EventArgs.Empty);
 }
예제 #21
0
 public void AddUser(ChannelUser user)
 {
     users.Add(user.IRCUser.Name, user);
     UserAdded?.Invoke(this, new ChannelUserEventArgs(user));
 }
예제 #22
0
 public void AddUser(ChannelUser user)
 {
     users.Add(user);
     users = users.OrderBy(u => u.IRCUser.Name).OrderBy(u => !u.IsAdmin).ToList();
     UserAdded?.Invoke(this, new ChannelUserEventArgs(-1, user));
 }
예제 #23
0
 protected virtual void OnUserAdded(UserAddedEventArgs e)
 {
     UserAdded?.Invoke(this, e);
 }
예제 #24
0
 public void AddUser(params object[] data)
 {
     this.Book.Add((User)data);
     UserAdded.Invoke();
 }
예제 #25
0
 protected virtual void OnUserAdded(object sender, BllUser user)
 {
     UserAdded?.Invoke(sender, user);
 }
예제 #26
0
 private void AddUserToGlobalUserList(IRCUser user)
 {
     UserList.Add(user);
     UserList = UserList.OrderBy(u => u.Name).ToList();
     UserAdded?.Invoke(this, new UserEventArgs(user));
 }
예제 #27
0
 public void AddUser(User user)
 {
     userList.Add(user);
     UserAdded?.Invoke(this, user);
 }