Esempio n. 1
0
        async Task <ClipboardSnapshot> GetSnapshot(ClipboardSnapshotPointer pointer)
        {
            ClipboardSnapshot snapshot;

            if (Cache.TryGetValue(pointer, out snapshot))
            {
                return(snapshot);
            }

            var blob = BlobContainer.GetBlockBlobReference(pointer.GetId());

            var data = new MemoryStream();
            await blob.DownloadToStreamAsync(data);

            if (data.Length == 0)
            {
                return(ClipboardSnapshot.CreateEmptySnapshot(pointer.Date, pointer.GetId()));
            }

            data.Position  = 0;
            snapshot       = ClipboardSnapshot.Deserialize(data);
            snapshot.Id    = pointer.GetId();
            Cache[pointer] = snapshot;
            return(snapshot);
        }
Esempio n. 2
0
        public async Task Save(ClipboardSnapshot snapshot)
        {
            var pointer = new ClipboardSnapshotPointer(GetPartitionKey(snapshot.Date), snapshot.Date, snapshot.Data.Select(f => f.Format).ToArray());
            snapshot.Id = pointer.GetId();
            KnownPointers.Add(pointer);
            Cache[pointer] = snapshot;

            var blob = BlobContainer.GetBlockBlobReference(pointer.GetId());
            await blob.UploadFromStreamAsync(snapshot.Serialize());

            var insertOperation = TableOperation.Insert(pointer);
            var result = await Table.ExecuteAsync(insertOperation);
        }
Esempio n. 3
0
        public async Task Save(ClipboardSnapshot snapshot)
        {
            var pointer = new ClipboardSnapshotPointer(GetPartitionKey(snapshot.Date), snapshot.Date, snapshot.Data.Select(f => f.Format).ToArray());

            snapshot.Id = pointer.GetId();
            KnownPointers.Add(pointer);
            Cache[pointer] = snapshot;

            var blob = BlobContainer.GetBlockBlobReference(pointer.GetId());
            await blob.UploadFromStreamAsync(snapshot.Serialize());

            var insertOperation = TableOperation.Insert(pointer);
            var result          = await Table.ExecuteAsync(insertOperation);
        }
Esempio n. 4
0
        async Task<ClipboardSnapshot> GetSnapshot(ClipboardSnapshotPointer pointer)
        {
            ClipboardSnapshot snapshot;
            if (Cache.TryGetValue(pointer, out snapshot))
                return snapshot;

            var blob = BlobContainer.GetBlockBlobReference(pointer.GetId());

            var data = new MemoryStream();
            await blob.DownloadToStreamAsync(data);
            if (data.Length == 0)
                return ClipboardSnapshot.CreateEmptySnapshot(pointer.Date, pointer.GetId());

            data.Position = 0;
            snapshot = ClipboardSnapshot.Deserialize(data);
            snapshot.Id = pointer.GetId();
            Cache[pointer] = snapshot;
            return snapshot;
        }