Beispiel #1
0
        /// <summary>
        ///     Creates or gets an existing account.
        /// </summary>
        /// <param name="username">Unique user name.</param>
        /// <param name="password">Password string.</param>
        /// <returns>Created or existing account with username.</returns>
        public Account CreateAccount(
            string username,
            string password)
        {
            if (Accounts.ContainsKey(username))
            {
                Logger.Trace(
                    "Found an account with name:{0} returning.",
                    username);
                return(Accounts[username]);
            }

            Logger.Trace("Creating a new account with name:{0}", username);
            var a = new Account(username, password);

            Accounts.Add(username, a);

            if (NewAccount != null)
            {
                NewAccount.Invoke(a);
            }

            return(a);
        }