Esempio n. 1
0
        public void Apply(ConventionContext context, MemberInfo member)
        {
            context.Application.OnParsingComplete(_ =>
            {
                if (_.ShowHelp())
                {
                    return;
                }

                var solution = context.GetStringValue(nameof(NewSubcommand.Solution));

                var fileSystemService = context.Application.GetService <IFileSystemService>();

                IOperationResponse <string> response = solution.IsNotProvidedByUser()
                ? fileSystemService.GetSolutionPath(InitDirectory)
                : fileSystemService.GetSolutionPath(solution);

                if (context.ModelAccessor?.GetModel() is NewSubcommand model && model != null)
                {
                    if (!response.IsSuccessful && response.Message.Exists())
                    {
                        model.SetResolvedSolutionErrorMessage(response.Message);
                    }

                    model?.SetResolvedSolution(response?.Payload ?? string.Empty);

                    var solutionValidator = context.GetValidator <SolutionValidator>();

                    solutionValidator.Validate(model !);
                }
            });
        }
 public void WriteResponse(IOperation operation, IOperationResponse response)
 {
     _transport.SendOperation(OperationCode.HandleResponse, new Dictionary <byte, object>
     {
         [(byte)OperationParameterCode.OperationId]           = _map.GetMappedOperation(operation.GetType()).Id,
         [(byte)OperationParameterCode.OperationResponseData] = _serializer.WriteObject(response.GetType(), response)
     });
 }
Esempio n. 3
0
 private ObjectResult BuildObjectResult <THandlerResponse>(IOperationResponse <THandlerResponse> response)
     where THandlerResponse : class, IHandlerResponse
 {
     return(new ObjectResult(response)
     {
         StatusCode = (int)response.StatusCode
     });
 }
 public void WriteResponse(IOperation operation, IOperationResponse response)
 {
     _transport.SendOperation(OperationCode.HandleResponse, new Dictionary<byte, object>
     {
         [(byte) OperationParameterCode.OperationId] = _map.GetMappedOperation(operation.GetType()).Id,
         [(byte) OperationParameterCode.OperationResponseData] = _serializer.WriteObject(response.GetType(), response)
     });
 }
Esempio n. 5
0
        protected T Return <T>(IOperationResponse <T> response)
            where T : class
        {
            if (!response.IsOk)
            {
                throw new MyPegasusFactoryException <T>(response.Message);
            }

            return(response.Payload);
        }
Esempio n. 6
0
        public void Apply(ConventionContext context, MemberInfo member)
        {
            context.Application.OnParsingComplete(_ =>
            {
                if (_.ShowHelp())
                {
                    return;
                }

                var project = context.GetStringValue(nameof(InfoSubcommand.Project));

                var fileSystemService = context.Application.GetService <IFileSystemService>();

                IOperationResponse <IEnumerable <string> > response = project.IsNotProvidedByUser()
                 ? fileSystemService.GetNSeedProjectPaths(InitDirectory)
                 : fileSystemService.GetNSeedProjectPaths(project);

                if (context.ModelAccessor?.GetModel() is InfoSubcommand model && model != null)
                {
                    if (response.IsSuccessful)
                    {
                        var dependencyGraphService = context.Application.GetService <IDependencyGraphService>();

                        var projectPaths = response !.Payload;

                        foreach (var path in projectPaths !)
                        {
                            var frameworkResponse = dependencyGraphService.GetProjectFramework(path);

                            if (frameworkResponse.IsSuccessful && frameworkResponse.Payload !.IsDefined)
                            {
                                var resolvedProject = new Project(path, frameworkResponse.Payload);

                                var verifier = GetSeedBucketVerifier(frameworkResponse.Payload);

                                var verifyResponse = verifier.Verify(resolvedProject);

                                if (!verifyResponse.IsSuccessful)
                                {
                                    resolvedProject.ErrorMessage = verifyResponse.Message;
                                }

                                model.SetResolvedProject(resolvedProject);
                            }
                        }
                    }
                }

                ISeedBucketVerifier GetSeedBucketVerifier(IFramework framework)
                {
                    var seedBucketVerifierDiReolver = context.Application.GetService <Func <FrameworkType, ISeedBucketVerifier> >();
                    return(seedBucketVerifierDiReolver(framework.Type));
                }
            });
        }
Esempio n. 7
0
            public void Setup()
            {
                var createCustomerResponse = Task.Run(async() => await
                                                      Customer.CreateAsync("Bosko",
                                                                           "Kovacevic",
                                                                           "*****@*****.**",
                                                                           DateTimeOffset.Parse("03/11/1983")
                                                                           ).ConfigureAwait(false)).Result;

                _customer = createCustomerResponse.Payload;
                _response = _customer.SetEmail(NewEmailAddress);
            }
Esempio n. 8
0
            public void Setup()
            {
                var createCustomerResponse = Task.Run(async() => await
                                                      Customer.CreateAsync("Bosko",
                                                                           "Kovacevic",
                                                                           OriginalEmailAddress,
                                                                           DateTimeOffset.Parse("03/11/1983")
                                                                           ).ConfigureAwait(false)).Result;

                _customer = createCustomerResponse.Payload;
                _response = _customer.SetEmail("SomeInvalidEmail");
            }
        /// <summary>
        /// Processes the response.
        /// </summary>
        /// <param name="response">The response.</param>
        public void ProcessResponse <TLocalised>(IOperationResponse response)
            where TLocalised : struct, IComparable, IFormattable
        {
            if (!response.IsSuccess() &&
                !ProcessError <CommonLocalised>(response) &&
                !ProcessError <TLocalised>(response))
            {
                //Emitter.Publish(response.Exception.StackTrace);
                //Emitter.Publish(response.Exception.Message);

                Emitter.Publish(response.Message);
            }
        }
        public bool ProcessError <TLocalised>(IOperationResponse response)
            where TLocalised : struct, IComparable, IFormattable
        {
            if (FromSet <TLocalised> .GetNames().Any(x => Format.ComparesWith(x, response.Message)))
            {
                var candidate = FromSet <TLocalised> .Get(response.Message);

                Emitter.Publish(candidate);

                return(true);
            }

            return(false);
        }
Esempio n. 11
0
        public void Complete(TResponse response)
        {
            if (IsCompleted)
            {
                throw new InvalidOperationException($"Failed to complete operation '{GetType()}', the operation may only be completed once");
            }

            foreach (var callback in _callbacks)
            {
                callback(response);
            }

            Response    = response;
            IsCompleted = true;
        }
Esempio n. 12
0
        public void RegisterOperation(string trackId, IOperationRequest request, IOperationResponse response, DateTime date)
        {
            var journalFound = _journal.TryGetValue(trackId, out var journalOperations);

            if (!journalFound)
            {
                journalOperations = new List <JournalOperation>();
            }

            var calculation = $"{request.GetFormatedRequest()} = {response.GetFormatedResponse()}";
            var operation   = new JournalOperation
            {
                Operation   = request.GetOperationName(),
                Calculation = calculation,
                Date        = date
            };

            journalOperations.Add(operation);
            _journal.TryAdd(trackId, journalOperations);
        }
Esempio n. 13
0
        public void HandleResponse(IOperationResponse response)
        {
            var promise = _activeOperations.RetrieveAndRemoveOperation(response.PromiseId);

            typeof(OperationPromise <>).MakeGenericType(response.GetType()).GetMethod("Complete").Invoke(promise, new object[] { response });
        }
Esempio n. 14
0
 public OperationAction(IOperationRequest <T> operationRequest, IOperationResponse <U> operationResponse, IOperationContext <V> operationContext)
 {
     this.operationRequest  = operationRequest;
     this.operationResponse = operationResponse;
     this.operationContext  = operationContext;
 }
 public StatusCodeMismatchException(IOperationResponse response, Type expectedType)
 {
     Response     = response;
     ExpectedType = expectedType;
 }
Esempio n. 16
0
 protected void WhenRequestIsHandled() => Response = Handler.Handle();
Esempio n. 17
0
 public Operation(RedisSocket socket, IOperationRequest request, IOperationResponse <T> response)
 {
     this.socket   = socket;
     this.request  = request;
     this.response = response;
 }
Esempio n. 18
0
 public void HandleResponse(IOperationResponse response)
 {
     var promise = _activeOperations.RetrieveAndRemoveOperation(response.PromiseId);
     typeof (OperationPromise<>).MakeGenericType(response.GetType()).GetMethod("Complete").Invoke(promise, new object[] {response});
 }
 protected void WhenRequestIsHandled() => Response = Task.Run(async() => await Handler.ExecuteHandlerAsync(Request)).Result;
 public void WriteResponse(IOperation operation, IOperationResponse response)
 {
     _writtenResponses.Add(response);
 }
 public void WriteResponse(IOperation operation, IOperationResponse response)
 {
     _writtenResponses.Add(response);
 }
 /// <summary>
 /// Creates the message.
 /// </summary>
 /// <param name="lastState">if set to <c>true</c> [last state].</param>
 /// <returns>a last operation state message</returns>
 public ICarryLastOperationState CreateMessage(IOperationResponse lastState)
 {
     return(new OperationStateMessage {
         Payload = lastState
     });
 }