public StreamCopyOperation(
            LiveConnectClient client, 
            ApiMethod method, 
            Stream inputStream, 
            Stream outputStream, 
            long contentLength, 
            object progress,
            SynchronizationContextWrapper syncContext, 
            Action<bool, Exception> onCopyCompleted)
            : base(syncContext)
        {
            Debug.Assert(client != null, "client must not be null.");
            Debug.Assert(
                method == ApiMethod.Download || method == ApiMethod.Upload,
                "Only Download and Upload methods are allowed.");
            Debug.Assert(inputStream.CanRead, "Input stream is not readable.");
            Debug.Assert(outputStream.CanWrite, "Output stream is not writable.");

            this.LiveClient = client;
            this.Method = method;
            this.InputStream = inputStream;
            this.OutputStream = outputStream;
            this.ContentLength = contentLength;
            this.buffer = new byte[StreamCopyOperation.BufferSize];
            this.copyCompletedCallback = onCopyCompleted;
            this.progress = progress;
        }
        protected WebOperation(Uri url, string body, SynchronizationContextWrapper syncContext)
            : base(syncContext)
        {
            Debug.Assert(url != null, "url must not be null.");

            this.Url = url;
            this.Body = body;
        }
 public ForegroundUploadOperation(LiveConnectClient client, Uri url, string filename, IFileSource inputFile, OverwriteOption option, IProgress<LiveOperationProgress> progress, SynchronizationContextWrapper syncContext)
     : base(client, url, ApiMethod.Upload, null, syncContext)
 {
     this.Filename = filename;
     this.Progress = progress;
     this.OverwriteOption = option;
     this.FileSource = inputFile;
 }
 public ApiWriteOperation(
     LiveConnectClient client, 
     Uri url, 
     ApiMethod method, 
     string body, 
     SynchronizationContextWrapper syncContext)
     : base(client, url, method, body, syncContext)
 {
 }
 public DownloadOperation(
     LiveConnectClient client, 
     Uri url, 
     object progress, 
     SynchronizationContextWrapper syncContext)
     : base(client, url, ApiMethod.Download, null, syncContext)
 {
     this.progress = progress;
 }
Пример #6
0
 /// <summary>
 /// Constructs a new ApiOperation object.
 /// </summary>
 public ApiOperation(
     LiveConnectClient client, 
     Uri url, 
     ApiMethod method, 
     string body, 
     SynchronizationContextWrapper syncContext)
     : base(url, body, syncContext)
 {
     this.Method = method;
     this.LiveClient = client;
 }
 /// <summary>
 /// Creates a new TailoredDownloadOperation instance.
 /// </summary>
 public TailoredDownloadOperation(
     LiveConnectClient client, 
     Uri url, 
     IStorageFile outputFile, 
     IProgress<LiveOperationProgress> progress,
     SynchronizationContextWrapper syncContext)
     : base(client, url, ApiMethod.Download, null, syncContext)
 {
     this.OutputFile = outputFile;
     this.Progress = progress;
 }
 public GetUploadLinkOperation(
     LiveConnectClient client, 
     Uri url, 
     string fileName, 
     OverwriteOption option, 
     SynchronizationContextWrapper syncContext)
     : base(client, url, ApiMethod.Get, null, syncContext)
 {
     this.FileName = fileName;
     this.OverwriteOption = option;
 }
 /// <summary>
 /// This class implements the upload operation on Windows 8 using the background uploader.
 /// </summary>
 /// <remarks>This constructor is used when uploading a stream created by the application.</remarks>
 public TailoredUploadOperation(
     LiveConnectClient client,
     Uri url,
     string fileName,
     IInputStream inputStream,
     OverwriteOption option,
     IProgress<LiveOperationProgress> progress,
     SynchronizationContextWrapper syncContext)
     : this(client, url, fileName, option, progress, syncContext)
 {
     Debug.Assert(inputStream != null, "inputStream is null.");
     this.InputStream = inputStream;
 }
 /// <summary>
 /// This class implements the upload operation on Windows 8 using the background uploader.
 /// </summary>
 /// <remarks>This constructor is used when uploading a stream created by the application.</remarks>
 internal TailoredUploadOperation(
     LiveConnectClient client,
     Uri url,
     string fileName,
     OverwriteOption option,
     IProgress<LiveOperationProgress> progress,
     SynchronizationContextWrapper syncContext)
     : base(client, url, ApiMethod.Upload, null, syncContext)
 {
     this.FileName = fileName;
     this.Progress = progress;
     this.OverwriteOption = option;
 }
Пример #11
0
        public UploadOperation(
            LiveConnectClient client, 
            Uri url, 
            string fileName,
            Stream inputStream, 
            OverwriteOption option,
            object progress,
            SynchronizationContextWrapper syncContext)
            : base(client, url, ApiMethod.Upload, null, syncContext)
        {
            this.FileName = fileName;
            this.OverwriteOption = option;
            this.InputStream = inputStream;
            this.progress = progress;

            this.totalBytesToSend = this.InputStream.CanSeek ?
                                    this.InputStream.Length :
                                    UploadOperation.UnknownFileSize;
        }
        /// <summary>
        /// Create a new RefreshTokenOperation object.
        /// </summary>
        /// <remarks>This constructor is used when exchanging the refresh token for the access token.</remarks>
        public RefreshTokenOperation(
            LiveAuthClient authClient, 
            string clientId, 
            string refreshToken, 
            IEnumerable<string> scopes,
            SynchronizationContextWrapper syncContext)
            : base(new Uri(authClient.ConsentEndpoint + LiveAuthClient.TokenEndpoint), 
                   null,   
                   syncContext)
        {
            Debug.Assert(authClient != null, "authClient must not be null.");
            Debug.Assert(!string.IsNullOrEmpty(clientId));
            Debug.Assert(!string.IsNullOrEmpty(refreshToken));

            this.AuthClient = authClient;

            this.Body = String.Format(
                RefreshTokenOperation.RefreshTokenPostBodyTemplate,
                HttpUtility.UrlEncode(clientId),
                refreshToken,
                HttpUtility.UrlEncode(LiveAuthClient.BuildScopeString(scopes)));
        }
        /// <summary>
        /// Create a new RefreshTokenOperation object.
        /// </summary>
        /// <remarks>This constructor is used when exchanging the verification code for the access token.</remarks>
        public RefreshTokenOperation(
            LiveAuthClient authClient,
            string clientId,
            string verificationCode,
            string redirectUri,
            SynchronizationContextWrapper syncContext)
            : base(new Uri(authClient.ConsentEndpoint + LiveAuthClient.TokenEndpoint), 
                   null, 
                   syncContext)
        {
            Debug.Assert(authClient != null, "authClient must not be null.");
            Debug.Assert(!string.IsNullOrEmpty(clientId));
            Debug.Assert(!string.IsNullOrEmpty(verificationCode));

            this.AuthClient = authClient;

            this.Body = String.Format(
                        RefreshTokenOperation.AuthCodePostBodyTemplate,
                        HttpUtility.UrlEncode(clientId),
                        HttpUtility.UrlEncode(verificationCode),
                        HttpUtility.UrlEncode(redirectUri));
        }
Пример #14
0
 protected Operation(SynchronizationContextWrapper syncContext)
 {
     this.Status = OperationStatus.NotStarted;
     this.Dispatcher = syncContext ?? SynchronizationContextWrapper.Current;
 }
 public ApiOperation GetUploadOperation(LiveConnectClient client, Uri url, IFileSource inputFile, OverwriteOption option, IProgress<LiveOperationProgress> progress, SynchronizationContextWrapper syncContext)
 {
     return new UploadOperation(client, url, inputFile.Filename, inputFile.GetReadStream(), option, progress, syncContext);
 }
 public DownloadOperation GetDownloadOperation(LiveConnectClient client, Uri url, IFileSource outputFile, IProgress<LiveOperationProgress> progress, SynchronizationContextWrapper syncContext)
 {
     // TODO: This is include since we aren't download to outputFile.
     var downloadOp = new DownloadOperation(client, url, progress, syncContext);
     return downloadOp;
 }