protected override void OnExecute()
        {
            var getUploadLinkOp = new GetUploadLinkOperation(
                this.LiveClient,
                this.Url,
                this.FileName,
                this.OverwriteOption,
                null);

            getUploadLinkOp.OperationCompletedCallback = this.OnGetUploadLinkCompleted;
            getUploadLinkOp.Execute();
        }
        public void TestExecute()
        {
            WebRequestFactory.Current = new TestWebRequestFactory();
            LiveConnectClient connectClient = new LiveConnectClient(new LiveConnectSession());
            Uri requestUri = new Uri("http://foo.com");
            string fileName = string.Empty;
            OverwriteOption overwriteOption = OverwriteOption.Overwrite;
            SynchronizationContextWrapper syncContextWrapper = SynchronizationContextWrapper.Current;

            var apiOperation =
                new GetUploadLinkOperation(connectClient, requestUri, fileName, overwriteOption, syncContextWrapper);
        }
        protected override void OnExecute()
        {
            var getUploadLinkOp = new GetUploadLinkOperation(
                    this.LiveClient,
                    this.Url,
                    this.FileName,
                    this.OverwriteOption,
                    null);

            getUploadLinkOp.OperationCompletedCallback = this.OnGetUploadLinkCompleted;
            getUploadLinkOp.Execute();
        }
        /// <summary>
        /// Performs the BackgroundUploadOperation.
        /// </summary>
        public async Task<LiveOperationResult> ExecuteAsync()
        {
            Debug.Assert(this.status != OperationStatus.Completed, "Cannot execute on a completed operation.");

            if (this.status == OperationStatus.Cancelled)
            {
                return await this.tcs.Task;
            }

            this.status = OperationStatus.Started;

            string filename = Path.GetFileName(this.uploadLocationOnDevice.OriginalString);
            Debug.Assert(!string.IsNullOrEmpty(filename));

            Uri requestUri = this.client.GetResourceUri(this.path, ApiMethod.Upload);
            // TODO: Figure out how to mock out GetUploadLinkOperation elegantly so this can be tested.
            this.getUploadLinkOperation = new GetUploadLinkOperation(
                this.client,
                requestUri,
                filename,
                this.overwriteOption,
                null);

            LiveOperationResult uploadLinkResult = await this.getUploadLinkOperation.ExecuteAsync();

            var uploadRequestUri = new Uri(uploadLinkResult.RawResult, UriKind.Absolute);
            var downloadLocationOnDevice = 
                new Uri(this.uploadLocationOnDevice.OriginalString + ".json", UriKind.RelativeOrAbsolute);
            var builder = new BackgroundUploadRequestBuilder
            {
                RequestUri = uploadRequestUri,
                AccessToken = (this.client.Session != null) ? this.client.Session.AccessToken : "",
                UploadLocationOnDevice = this.uploadLocationOnDevice,
                DownloadLocationOnDevice = downloadLocationOnDevice,
                TransferPreferences = this.transferPreferences
            };

            this.request = builder.Build();

            var eventAdapter = new BackgroundUploadEventAdapter(this.backgroundTransferService, this.tcs);
            Task<LiveOperationResult> task = progress == null ? 
                                             eventAdapter.ConvertTransferStatusChangedToTask(this.request) :
                                             eventAdapter.ConvertTransferStatusChangedToTask(this.request, progress);

            Debug.Assert(this.tcs.Task == task, "EventAdapter returned a different task. This could affect cancel.");

            if (this.status != OperationStatus.Cancelled)
            {
                this.backgroundTransferService.Add(this.request);
                this.requestAddedToService = true;
            }

            LiveOperationResult result = await task;
            this.status = OperationStatus.Completed;
            return result;
        }