Esempio n. 1
0
        public async Task Save(IHaveIdentifier document)
        {
            var json      = JsonConvert.SerializeObject(document);
            var container = await EnsureContainer(document.Identifier);

            var blob =
                container.GetBlockBlobReference(document.Identifier.Split('/')[1]);

            await using var stream       = new MemoryStream();
            await using var streamWriter = new StreamWriter(stream);
            streamWriter.Write(json);
            await streamWriter.FlushAsync();

            stream.Position = 0;
            if (await blob.ExistsAsync())
            {
                var etag = _blobLookup[document.Identifier].Properties.ETag;
                await blob.UploadFromStreamAsync(stream,
                                                 AccessCondition.GenerateIfMatchCondition(etag), null,
                                                 null);
            }
            else
            {
                await blob.UploadFromStreamAsync(stream);
            }
        }
Esempio n. 2
0
 public void Show(IHaveIdentifier entity)
 {
     rtbDescription.Text = String.Empty;
     pbImage.Image       = null;
     entityType          = entity.GetEntityType();
     this.entity         = entity;
     Show();
 }
 public static EntityType GetEntityType(this IHaveIdentifier haveIdentifier)
 {
     if (haveIdentifier is Resource)
     {
         return(EntityType.Resource);
     }
     if (haveIdentifier is User)
     {
         return(EntityType.User);
     }
     throw new NotImplementedException();
 }
Esempio n. 4
0
 public Task Save(IHaveIdentifier document)
 {
     _documents[document.Identifier] = document;
     return(Task.CompletedTask);
 }