Exemplo n.º 1
0
        public void AddObserver(StorageTaskStatus status, Action <IStorageTaskSnapshot> observer)
        {
            if (TransferTask == null)
            {
                throw new ArgumentException($"You have to set the {nameof(TransferTask)} property before calling this method");
            }

            var handle = TransferTask.ObserveStatus(status.ToNative(), x => observer.Invoke(x.ToAbstract()));

            _observerDict[observer] = handle;
        }
Exemplo n.º 2
0
        public static NativeStorageTaskStatus ToNative(this StorageTaskStatus @this)
        {
            switch (@this)
            {
            case StorageTaskStatus.Unknown:
                return(NativeStorageTaskStatus.Unknown);

            case StorageTaskStatus.Progress:
                return(NativeStorageTaskStatus.Progress);

            case StorageTaskStatus.Pause:
                return(NativeStorageTaskStatus.Pause);

            case StorageTaskStatus.Success:
                return(NativeStorageTaskStatus.Success);

            case StorageTaskStatus.Failure:
                return(NativeStorageTaskStatus.Failure);

            default:
                throw new ArgumentException($"Couldn't convert {nameof(StorageTaskStatus)} {@this} to native status");
            }
        }