Example #1
0
        protected override IObservable <byte[]> BeforeWriteToDiskFilter(byte[] data, IScheduler scheduler)
        {
            try
            {
                var ret = Observable.Return(DataProtectionApi.Encrypt(DataProtectionApi.KeyType.UserKey, data, null, null));

                // NB: MemoizedRequests will be null as we're disposing
                if (MemoizedRequests != null)
                {
                    lock (MemoizedRequests) MemoizedRequests.InvalidateAll();
                }
                return(ret);
            }
            catch (Exception ex)
            {
                return(Observable.Throw <byte[]>(ex));
            }
        }
Example #2
0
        protected override IObservable <byte[]> AfterReadFromDiskFilter(byte[] data, IScheduler scheduler)
        {
            try
            {
                string dontcare;
                var    ret = Observable.Return(DataProtectionApi.Decrypt(data, null, out dontcare));

                // NB: MemoizedRequests will be null as we're disposing
                if (MemoizedRequests != null)
                {
                    lock (MemoizedRequests) MemoizedRequests.InvalidateAll();
                }
                return(ret);
            }
            catch (Exception ex)
            {
                return(Observable.Throw <byte[]>(ex));
            }
        }