/// <summary> /// Deserialization constructor. /// </summary> /// <param name="serial"></param> internal APIKey(SerializableAPIKey serial) : this() { ID = serial.ID; VerificationCode = serial.VerificationCode; Type = serial.Type; Expiration = serial.Expiration; AccessMask = serial.AccessMask; m_monitored = serial.Monitored; IdentityIgnoreList.Import(serial.IgnoreList); }
/// <summary> /// Updates the API key. /// </summary> /// <param name="e">The <see cref="APIKeyCreationEventArgs" /> instance containing the event data.</param> /// <exception cref="System.ArgumentNullException">e</exception> public void Update(APIKeyCreationEventArgs e) { e.ThrowIfNull(nameof(e)); VerificationCode = e.VerificationCode; AccessMask = e.AccessMask; Type = e.Type; Expiration = e.Expiration; m_apiKeyInfoMonitor.UpdateWith(e.APIKeyInfo); // Notifies for the API key expiration NotifyAPIKeyExpiration(); // Clear the API key for the currently associated identities foreach (CharacterIdentity id in EveMonClient.CharacterIdentities.Where(id => id.APIKeys.Contains(this))) { id.APIKeys.Remove(this); } // Assign this API key to the new identities and create CCP characters foreach (CharacterIdentity id in e.Identities) { // Update the corporation info as they may have changed id.CorporationID = e.Identities.First(x => x.CharacterID == id.CharacterID).CorporationID; id.CorporationName = e.Identities.First(x => x.CharacterID == id.CharacterID).CorporationName; id.APIKeys.Add(this); // Skip if in the ignore list if (IdentityIgnoreList.Contains(id)) { continue; } // Retrieves the ccp character and create one if none if (id.CCPCharacter != null) { // Update the corporation info id.CCPCharacter.CorporationID = id.CorporationID; id.CCPCharacter.CorporationName = id.CorporationName; // Notify subscribers EveMonClient.OnCharacterUpdated(id.CCPCharacter); continue; } EveMonClient.Characters.Add(new CCPCharacter(id)); } }
/// <summary> /// Exports the data to a serialization object. /// </summary> /// <returns></returns> internal SerializableAPIKey Export() { SerializableAPIKey serial = new SerializableAPIKey { ID = ID, VerificationCode = VerificationCode, Type = Type, AccessMask = AccessMask, Expiration = Expiration, Monitored = m_monitored, LastUpdate = m_apiKeyInfoMonitor.LastUpdate, }; serial.IgnoreList.AddRange(IdentityIgnoreList.Export()); return(serial); }