Ejemplo n.º 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetBlobResponse response = new GetBlobResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("content", targetDepth))
                {
                    var unmarshaller = MemoryStreamUnmarshaller.Instance;
                    response.Content = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        private async void Download()
        {
            var layer = SelectedLayer;

            if (layer == null)
            {
                return;
            }

            GetBlobResponse response = null;

            var ex = await Executor.ExecuteAsync(async() =>
            {
                response = await _registryClient.Blobs.GetBlobAsync(_parent.Repository, layer.Digest);
            });

            if (ex != null)
            {
                _messageBoxService.Show(ex.Message);
            }
            else
            {
                using (var stream = response.Stream)
                {
                    var result = _fileDialogService.ShowSaveFileDialog();

                    if (result != null)
                    {
                        using (var targetStream = File.Create(result.FileName))
                        {
                            stream.CopyTo(targetStream);
                        }
                    }
                }

                _messageBoxService.Show("Layer saved", "Complete");
            }
        }
 protected void AssertBlobCopyPropertiesMatch(string containerName, string blobName, GetBlobResponse response)
 {
     AssertBlobCopyPropertiesMatch(containerName, blobName, response.CopyStatus, response.CopyProgress, response.CopyCompletionTime, response.CopyStatusDescription, response.CopyId, response.CopySource);
 }