Ejemplo n.º 1
0
 /// <summary>
 /// Adds an account to this collection.
 /// </summary>
 /// <param name="account"></param>
 /// <param name="notify"></param>
 internal void Add(Account account, bool notify)
 {
     m_items.Add(account.UserID, account);
     if (notify)
     {
         EveClient.OnAccountCollectionChanged();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Imports the serialized accounts
        /// </summary>
        /// <param name="serial"></param>
        internal void Import(IEnumerable <SerializableAccount> serial)
        {
            m_items.Clear();
            foreach (var serialAccount in serial)
            {
                m_items.Add(serialAccount.ID, new Account(serialAccount));
            }

            EveClient.OnAccountCollectionChanged();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the provided account from this collection
        /// </summary>
        /// <param name="account">The account to remove</param>
        /// <param name="removeCharacters">When true, the associated characters will be removed.</param>
        /// <exception cref="InvalidOperationException">The account does not exist in the list.</exception>
        public void Remove(Account account, bool removeCharacters)
        {
            // Clears the account on the owned identities.
            foreach (var identity in account.CharacterIdentities.Where(x => x.Account == account))
            {
                identity.Account = null;
            }

            // Remove the account
            if (!m_items.Remove(account.UserID))
            {
                throw new InvalidOperationException("This account does not exist in the list.");
            }

            EveClient.OnAccountCollectionChanged();
        }
        /// <summary>
        /// Imports the serialized accounts.
        /// </summary>
        /// <param name="serial"></param>
        internal void Import(IEnumerable <SerializableAccount> serial)
        {
            m_items.Clear();
            foreach (var serialAccount in serial)
            {
                try
                {
                    m_items.Add(serialAccount.ID, new Account(serialAccount));
                }
                catch (ArgumentException ex)
                {
                    EveClient.Trace("GlobalAccountCollection.Import - An account with id {0} already existed; additional instance ignored.", serialAccount.ID);
                    ExceptionHandler.LogException(ex, true);
                }
            }

            EveClient.OnAccountCollectionChanged();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates or updates the account.
        /// </summary>
        /// <returns></returns>
        public Account CreateOrUpdate()
        {
            // Checks whether this account already exists to update it.
            var account = EveClient.Accounts[m_userID];

            if (account != null)
            {
                account.UpdateAPIKey(m_apiKey, m_keyLevel, m_identities, m_serialCharacterList);

                // Collection did not change but there is no "AccountChanged" event
                EveClient.OnAccountCollectionChanged();
            }
            else
            {
                account = new Account(m_userID);
                account.UpdateAPIKey(m_apiKey, m_keyLevel, m_identities, m_serialCharacterList);
                EveClient.Accounts.Add(account, true);
            }

            return(account);
        }