public Task<IProcessServiceResult> ProcessImageAsync(string processorName, IImage image)
        {
            var result = new ImageProcessServiceResult();
            var processor = _processors.FirstOrDefault(p => p.Name == processorName);
            if (processor != null)
            {
                try
                {
                    var imageForProcessing = image.Clone();
                    processor.ProcessImage(imageForProcessing);
                    result.ProcessedImage = imageForProcessing;
                    result.Successful = true;
                }
                catch (Exception e)
                {
                    result.Successful = false;
                    result.ErrorMessage = e.Message;
                }
            }
            else
            {
                result.Successful = false;
                result.ErrorMessage = $"Can't find processor with name {processorName}";
            }

            return Task.FromResult((IProcessServiceResult)result);
        }
示例#2
0
        public Task <IProcessServiceResult> ProcessImageAsync(string processorName, IImage image)
        {
            var result    = new ImageProcessServiceResult();
            var processor = _processors.FirstOrDefault(p => p.Name == processorName);

            if (processor != null)
            {
                try
                {
                    var imageForProcessing = image.Clone();
                    processor.ProcessImage(imageForProcessing);
                    result.ProcessedImage = imageForProcessing;
                    result.Successful     = true;
                }
                catch (Exception e)
                {
                    result.Successful   = false;
                    result.ErrorMessage = e.Message;
                }
            }
            else
            {
                result.Successful   = false;
                result.ErrorMessage = $"Can't find processor with name {processorName}";
            }

            return(Task.FromResult((IProcessServiceResult)result));
        }