Ejemplo n.º 1
0
        /// <summary>
        /// Saves the account information.
        /// </summary>
        /// <param name="activatedEvent">The activated event.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task SaveAccountInfo(ActivatedEvent activatedEvent, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(activatedEvent.PublicKey))
            {
                throw new AddonValidationException($"Invalid {nameof(activatedEvent.PublicKey)} provided.", new Details {
                    Code = ErrorCodes.InvalidInput, Name = nameof(activatedEvent.PublicKey), Value = null
                });
            }

            if (string.IsNullOrEmpty(activatedEvent.TenantId))
            {
                throw new AddonValidationException($"Invalid {nameof(activatedEvent.TenantId)} provided.", new Details {
                    Code = ErrorCodes.InvalidInput, Name = nameof(activatedEvent.TenantId), Value = null
                });
            }

            if (string.IsNullOrEmpty(activatedEvent.ClientCredentials?.ClientId))
            {
                throw new AddonValidationException($"Invalid {nameof(activatedEvent.ClientCredentials.ClientId)} provided.", new Details {
                    Code = ErrorCodes.InvalidInput, Name = nameof(activatedEvent.ClientCredentials.ClientId), Value = null
                });
            }

            if (string.IsNullOrEmpty(activatedEvent.ClientCredentials?.ClientSecret))
            {
                throw new AddonValidationException($"Invalid {nameof(activatedEvent.ClientCredentials.ClientSecret)} provided.", new Details {
                    Code = ErrorCodes.InvalidInput, Name = nameof(activatedEvent.ClientCredentials.ClientSecret), Value = null
                });
            }

            var accountInfoEntity = new AccountInfoEntity()
            {
                PublicKey         = activatedEvent.PublicKey,
                TenantId          = activatedEvent.TenantId,
                ClientCredentials = activatedEvent.ClientCredentials
            };

            var accountInfo = await _repository.GetAccountInfoByTenantId(activatedEvent.TenantId).ConfigureAwait(false);

            if (accountInfo != null)
            {
                throw new AccountValidationException($"Account {activatedEvent.TenantId} is already activated.", new Details {
                    Code = ErrorCodes.AccountAlreadyActivated, Name = nameof(activatedEvent.TenantId), Value = activatedEvent.TenantId
                });
            }

            await _repository.SaveAccount(accountInfoEntity).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
 public void Activate(GameCharacter character)
 {
     this.character = character;
     ActivatedEvent?.Invoke();
 }
Ejemplo n.º 3
0
 public bool TryPickActivatedEvent(out ActivatedEvent value, out OneOf <SetTagsEvent, LogEvent, FinishedEvent> remainder)
 {
     return(base.TryPickT2(out value, out remainder));
 }
Ejemplo n.º 4
0
 public TraceEvent(int index, SetTagsEvent value0 = null, LogEvent value1 = null, ActivatedEvent value2 = null, FinishedEvent value3 = null)
     : base(index, value0, value1, value2, value3)
 {
 }