예제 #1
0
 public Task <IOperationResult <IFarmList> > FarmListAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new FarmListOperation(),
                cancellationToken));
 }
예제 #2
0
        public async Task RunAsync()
        {
            // Commands
            var decoratedCommand = new FooCommand {
                Name = "Decorated command"
            };
            await _executor.ExecuteAsync(decoratedCommand);

            await _writer.WriteLineAsync("----------------");

            var regularCommand = new BarCommand {
                Name = "Regular command"
            };
            var regularCommandResult = await _executor.ExecuteAsync(regularCommand);

            await _writer.WriteLineAsync("----------------");

            var syncCommand       = new BazCommand();
            var syncCommandResult = await _executor.ExecuteAsync(syncCommand);

            await _writer.WriteLineAsync($"Sync command result is `{syncCommandResult}`");

            await _writer.WriteLineAsync("----------------");

            // Queries
            var regularQuery = new FooQuery {
                Number1 = 3, Number2 = 4
            };
            var regularQueryResult = await _executor.ExecuteAsync(regularQuery);

            await _writer.WriteLineAsync("----------------");
        }
예제 #3
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation(),
                cancellationToken));
 }
예제 #4
0
        public Task <IOperationResult <IPublishSchema> > PublishSchemaAsync(
            Optional <string> schemaName              = default,
            Optional <string> environmentName         = default,
            Optional <string> sourceText              = default,
            Optional <IReadOnlyList <TagInput>?> tags = default,
            CancellationToken cancellationToken       = default)
        {
            if (schemaName.HasValue && schemaName.Value is null)
            {
                throw new ArgumentNullException(nameof(schemaName));
            }

            if (environmentName.HasValue && environmentName.Value is null)
            {
                throw new ArgumentNullException(nameof(environmentName));
            }

            if (sourceText.HasValue && sourceText.Value is null)
            {
                throw new ArgumentNullException(nameof(sourceText));
            }

            return(_executor.ExecuteAsync(
                       new PublishSchemaOperation
            {
                SchemaName = schemaName,
                EnvironmentName = environmentName,
                SourceText = sourceText,
                Tags = tags
            },
                       cancellationToken));
        }
예제 #5
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     Episode?episode,
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation {
         Episode = episode
     },
                cancellationToken));
 }
예제 #6
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     Optional <Episode> episode          = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation {
         Episode = episode
     },
                cancellationToken));
 }
예제 #7
0
 public Task <IOperationResult <IMediaDetails> > MediaDetailsAsync(
     Optional <System.Guid> id           = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new MediaDetailsOperation {
         Id = id
     },
                cancellationToken));
 }
 public Task <IOperationResult <IGetProducts> > GetProductsAsync(
     Optional <int> currentPage          = default,
     Optional <double> highPrice         = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetProductsOperation
     {
         CurrentPage = currentPage,
         HighPrice = highPrice
     },
                cancellationToken));
 }
예제 #9
0
        public Task <IOperationResult <IGetHuman> > GetHumanAsync(
            Optional <string> id = default,
            CancellationToken cancellationToken = default)
        {
            if (id.HasValue && id.Value is null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(_executor.ExecuteAsync(
                       new GetHumanOperation {
                Id = id
            },
                       cancellationToken));
        }
예제 #10
0
        public Task <IOperationResult <IGetUser> > GetUserAsync(
            Optional <string> login             = default,
            CancellationToken cancellationToken = default)
        {
            if (login.HasValue && login.Value is null)
            {
                throw new ArgumentNullException(nameof(login));
            }

            return(_executor.ExecuteAsync(
                       new GetUserOperation {
                Login = login
            },
                       cancellationToken));
        }
예제 #11
0
 public Task <IOperationResult <IMyQuery> > MyQueryAsync(
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new MyQueryOperation(),
                cancellationToken));
 }
예제 #12
0
 public Task <IOperationResult <IGetValues> > GetValuesAsync(
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new GetValuesOperation(),
                cancellationToken));
 }
예제 #13
0
        public async Task <IOperationResult <GetHeroResult> > ExecuteAsync(
            CancellationToken cancellationToken = default)
        {
            OperationRequest request = CreateRequest();

            return(await _operationExecutor
                   .ExecuteAsync(request, cancellationToken)
                   .ConfigureAwait(false));
        }
 public Task <IOperationResult <IGetCustomers> > GetCustomersAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetCustomersOperation(),
                cancellationToken));
 }
예제 #15
0
 private async Task <TResult> ExecuteAsync <TResult>(IOperation <TResult> operation)
 {
     try
     {
         return(await _executor.ExecuteAsync(operation));
     }
     catch (ValidationException ex)
     {
         var commandType = operation.GetType().Name;
         foreach (var failure in ex.ValidationResult)
         {
             await _writer.WriteLineAsync($"Validation {failure.Level} ({commandType}): {failure.Message}");
         }
         return(default);
예제 #16
0
        public Task <IOperationResult <IGetUser> > GetUserAsync(
            string login,
            CancellationToken cancellationToken)
        {
            if (login is null)
            {
                throw new ArgumentNullException(nameof(login));
            }

            return(_executor.ExecuteAsync(
                       new GetUserOperation {
                Login = login
            },
                       cancellationToken));
        }
        public Task <IOperationResult <IPeople> > GetPeopleAsync(
            Optional <string> userId            = default,
            CancellationToken cancellationToken = default)
        {
            if (userId.HasValue && userId.Value is null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            return(_executor.ExecuteAsync(
                       new GetPeopleOperation {
                UserId = userId
            },
                       cancellationToken));
        }