Exemplo n.º 1
0
        public async Task OpenAsync()
        {
            try
            {
                await _blob.FetchAttributesAsync();
                _commitPosition = Get_Committed_Position();
            }
            catch (StorageException ex)
            {
                if (ex.RequestInformation.HttpStatusCode != 404)
                    throw;

                _commitPosition = Position.Start;
            }

            byte[] lastPage = new byte[PageSize];
            if (_commitPosition.ToLinearAddress() != 0)
            {
                using (var stream = _blob.OpenRead())
                {
                    stream.Seek(_commitPosition.Page * PageSize, SeekOrigin.Begin);
                    await stream.ReadAsync(lastPage, 0, PageSize);
                }
            }

            _lastPage = new Page(_commitPosition, lastPage);
        }