Пример #1
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Signature;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Type != null)
            {
                dest.Type = new List <Hl7.Fhir.Model.Coding>(Type.DeepCopy());
            }
            if (WhenElement != null)
            {
                dest.WhenElement = (Hl7.Fhir.Model.Instant)WhenElement.DeepCopy();
            }
            if (Who != null)
            {
                dest.Who = (Hl7.Fhir.Model.DataType)Who.DeepCopy();
            }
            if (ContentTypeElement != null)
            {
                dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy();
            }
            if (BlobElement != null)
            {
                dest.BlobElement = (Hl7.Fhir.Model.Base64Binary)BlobElement.DeepCopy();
            }
            return(dest);
        }
Пример #2
0
        public async Task <BlobElement[]> ListAsync(string path, CancellationToken cancellationToken = default)
        {
            await _client.AutoConnectAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                var items = await _client.GetListingAsync(path).ConfigureAwait(false);

                return(items
                       .Select(i => i.Type == FtpFileSystemObjectType.Directory ?
                               BlobElement.CreateContainer(i.FullName, i.Name) :
                               new BlobElement(i.FullName, i.Name, BlobElementType.Blob, i.Size, i.Created.ToUniversalTime(), i.Modified.ToUniversalTime()))
                       .ToArray());
            }
            catch (FtpCommandException e) when(e.CompletionCode == "550")
            {
                throw new ContainerNotFoundException(path, e);
            }
        }
        public async Task <BlobElement[]> ListAsync(string path, CancellationToken cancellationToken = default)
        {
            var pathSegments = PathUtilities.GetSegments(path);

            if (pathSegments.Length == 0)
            {
                var cloudBlobClient = _storageAccount.CreateCloudBlobClient();

                BlobContinuationToken continuationToken = null;
                var results = new List <BlobElement>();
                do
                {
                    var response = await cloudBlobClient.ListContainersSegmentedAsync(continuationToken).ConfigureAwait(false);

                    continuationToken = response.ContinuationToken;
                    results.AddRange(response.Results.Select(c => BlobElement.CreateContainer(c.Name)));
                }while (continuationToken != null);

                return(results.ToArray());
            }
            else
            {
                var containerName = pathSegments.First();
                var containerPath = string.Join(PathUtilities.Delimiter, pathSegments.Skip(1));
                var container     = await GetCloudBlobContainerAsync(containerName, cancellationToken).ConfigureAwait(false);

                BlobContinuationToken continuationToken = null;
                var results = new List <BlobElement>();
                do
                {
                    var response = pathSegments.Skip(1).Any() ?
                                   await container.ListBlobsSegmentedAsync(containerPath + PathUtilities.Delimiter, continuationToken).ConfigureAwait(false) :
                                   await container.ListBlobsSegmentedAsync(continuationToken).ConfigureAwait(false);

                    continuationToken = response.ContinuationToken;
                    results.AddRange(response.Results.Select(i =>
                    {
                        if (i is CloudBlobDirectory directory)
                        {
                            return(BlobElement.CreateContainer(directory.Prefix, PathUtilities.GetSegments(directory.Prefix).Last()));
                        }
                        else if (i is CloudBlob blob)
                        {
                            var blobNameSegments = blob.Name.Split(PathUtilities.DelimiterChar);
                            return(new BlobElement(
                                       blob.Name,
                                       string.Join(PathUtilities.Delimiter, blobNameSegments.Skip(blobNameSegments.Length - 1)),
                                       BlobElementType.Blob,
                                       blob.Properties.Length,
                                       blob.Properties.Created,
                                       blob.Properties.LastModified));
                        }
                        else
                        {
                            return(null);
                        }
                    }).Where(c => c != null));
                }while (continuationToken != null);

                if (results.Count == 0)
                {
                    throw new ContainerNotFoundException(path, null);
                }

                return(results.ToArray());
            }
        }