/// <summary> /// Initializes a new instance of the <see cref="APIKeyCreationEventArgs"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="verificationCode">The verification code.</param> /// <param name="apiKeyInfo">The API key info.</param> /// <exception cref="System.ArgumentNullException">apiKeyInfo</exception> public APIKeyCreationEventArgs(long id, string verificationCode, CCPAPIResult <SerializableAPIKeyInfo> apiKeyInfo) { apiKeyInfo.ThrowIfNull(nameof(apiKeyInfo)); ID = id; VerificationCode = verificationCode; KeyTestError = String.Empty; APIKeyInfo = apiKeyInfo; Identities = new Collection <CharacterIdentity>(); // Determine the API key type Type = APIKey.GetCredentialsType(apiKeyInfo); // On error, retrieve the error message and quit if (Type == CCPAPIKeyType.Unknown) { KeyTestError = apiKeyInfo.ErrorMessage; CCPError = apiKeyInfo.CCPError ?? new CCPAPIError(); return; } AccessMask = apiKeyInfo.Result.Key.AccessMask; Expiration = apiKeyInfo.Result.Key.Expiration; // Retrieves the characters list foreach (SerializableCharacterListItem character in apiKeyInfo.Result.Key.Characters) { // Look for an existing character ID and update its name CharacterIdentity identity = EveMonClient.CharacterIdentities[character.ID]; if (identity != null) { identity.CharacterName = character.Name; identity.CorporationID = character.CorporationID; identity.CorporationName = character.CorporationName; identity.AllianceID = character.AllianceID; identity.AllianceName = character.AllianceName; identity.FactionID = character.FactionID; identity.FactionName = character.FactionName; } else { // Create an identity if necessary identity = EveMonClient.CharacterIdentities.Add(character.ID, character.Name, character.CorporationID, character.CorporationName, character.AllianceID, character.AllianceName, character.FactionID, character.FactionName); } Identities.Add(identity); } }