示例#1
0
 public LargeFileUploader(ODConnection connection, ODUploadSession uploadSession, Stream dataSource, ItemUploadOptions options)
 {
     Connection    = connection;
     UploadSession = uploadSession;
     DataSource    = dataSource;
     UploadOptions = options;
 }
        public FormSyncResults(ODConnection connection, ODDataModel result)
        {
            InitializeComponent();

            Connection = connection;
            Results = result;
        }
 public LargeFileUploader(ODConnection connection, ODUploadSession uploadSession, Stream dataSource, ItemUploadOptions options)
 {
     Connection = connection;
     UploadSession = uploadSession;
     DataSource = dataSource;
     UploadOptions = options;
 }
示例#4
0
        /// <summary>
        /// Returns a paged children collection for the item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static async Task<ODItemCollection> PagedChildrenCollectionAsync(this ODItem item, ODConnection connection, ChildrenRetrievalOptions options)
        {
            if (item.Children == null)
            {
                var firstPage = await connection.GetChildrenOfItemAsync(item.ItemReference(), options);
                item.Children = firstPage.Collection;
                item.ChildrenNextLinkAnnotation = firstPage.NextLink;
            }

            return new ODItemCollection { Collection = item.Children, NextLink = item.ChildrenNextLinkAnnotation };
        }
 /// <summary>
 /// Returns an item reference instance for the item, based on the item's ID and item's parent's drive ID.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static ODItemReference ItemReference(this ODItem item)
 {
     if (item.ParentReference == null)
     {
         return(ODConnection.ItemReferenceForItemId(item.Id));
     }
     else
     {
         return(ODConnection.ItemReferenceForItemId(item.Id, item.ParentReference.DriveId));
     }
 }
        /// <summary>
        /// Login and create the connection, if necessary.
        /// </summary>
        public static async Task Login()
        {
            if (Connection == null || !LiveOAuth.IsSignedIn)
            {
                // Get an OAuth2 access token through REST.           
                var token = await LiveOAuth.GetAuthToken();

                // Initialize connection
                Connection = new ODConnection("https://api.onedrive.com/v1.0", new OneDriveSdkAuthenticationInfo(token));
            }
        }
示例#7
0
        /// <summary>
        /// Returns the default thumbnail for a particular size
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connnection"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static async Task<ODThumbnail> GetDefaultThumbnailUrlAsync(this ODItem item, ODConnection connnection, string size)
        {
            if (item.Thumbnails == null)
            {
                // Item wasn't loaded with thumbnails, so do that now
                item.Thumbnails = await connnection.GetThumbnailsForItemAsync(item.ItemReference(), ThumbnailRetrievalOptions.Default);
            }

            if (null != item.Thumbnails && item.Thumbnails.Length > 0)
            {
                return item.Thumbnails[0].ThumbnailForSize(size);
            }

            return null;
        }
示例#8
0
 /// <summary>
 /// Returns a stream for the contents of an item.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="connection"></param>
 /// <returns></returns>
 public static async Task<System.IO.Stream> GetContentStreamAsync(this ODItem item, ODConnection connection, StreamDownloadOptions downloadOptions)
 {
     return await connection.DownloadStreamForItemAsync(item.ItemReference(), downloadOptions);
 }
示例#9
0
 private async Task LoadOneDriveFile(string p, ODConnection item)
 {
     OneDriveFolder Ones = new OneDriveFolder(item);
     await Ones.AddFiles(p);
     Ones.ToString();
     folder.Add(Ones);
 }
        /// <summary>
        /// Returns the default thumbnail for a particular size
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connnection"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static async Task <ODThumbnail> GetDefaultThumbnailUrlAsync(this ODItem item, ODConnection connnection, string size)
        {
            if (item.Thumbnails == null)
            {
                // Item wasn't loaded with thumbnails, so do that now
                item.Thumbnails = await connnection.GetThumbnailsForItemAsync(item.ItemReference(), ThumbnailRetrievalOptions.Default);
            }

            if (null != item.Thumbnails && item.Thumbnails.Length > 0)
            {
                return(item.Thumbnails[0].ThumbnailForSize(size));
            }

            return(null);
        }
        /// <summary>
        /// Returns a paged children collection for the item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static async Task <ODItemCollection> PagedChildrenCollectionAsync(this ODItem item, ODConnection connection, ChildrenRetrievalOptions options)
        {
            if (item.Children == null)
            {
                var firstPage = await connection.GetChildrenOfItemAsync(item.ItemReference(), options);

                item.Children = firstPage.Collection;
                item.ChildrenNextLinkAnnotation = firstPage.NextLink;
            }

            return(new ODItemCollection {
                Collection = item.Children, NextLink = item.ChildrenNextLinkAnnotation
            });
        }
 /// <summary>
 /// Gets the next page of items as an ODItemCollection
 /// </summary>
 /// <param name="itemCollection"></param>
 /// <param name="connection"></param>
 /// <returns></returns>
 public static async Task <ODItemCollection> GetNextPage(this ODItemCollection itemCollection, ODConnection connection)
 {
     if (null == connection)
     {
         throw new ArgumentNullException("connection");
     }
     if (itemCollection.MoreItemsAvailable())
     {
         return(await connection.DataModelForRequest <ODItemCollection>(new Uri(itemCollection.NextLink), ApiConstants.HttpGet));
     }
     else
     {
         return(new ODItemCollection());
     }
 }
示例#13
0
 public static async Task Refresh(this ODAsyncTask pendingTask, ODConnection connection)
 {
     await connection.RefreshAsyncTaskStatus(pendingTask);
 }
示例#14
0
 public OneDriveFile(ODConnection connect)
 {
     this.connect = connect;
 }
示例#15
0
 public OneDriveFolder(ODConnection connect)
 {
     this.connect = connect;
 }
        public async static Task <ODItemCollection> GetNextResponseCollection(ODItemCollection previousCollection, ODConnection connection)
        {
            if (null == connection)
            {
                throw new ArgumentNullException("connection");
            }
            if (null == previousCollection)
            {
                throw new ArgumentNullException("previousCollection");
            }

            if (previousCollection.MoreItemsAvailable())
            {
                return(await connection.DataModelForRequest <ODItemCollection>(new Uri(previousCollection.NextLink), ApiConstants.HttpGet));
            }
            else
            {
                return(null);
            }
        }
示例#17
0
 private async void Sign()
 {
     connection = await OneDriveLogin.SignInToMicrosoftAccount(this, "baba", @"C:\Save");
     if (null != connection)
     {
         item = new OneDriveFile(connection);
         await LoadFolderFromId("root");
     }
     //UpdateConnectedStateUx();
 }
 /// <summary>
 /// Returns a stream for the contents of an item.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="connection"></param>
 /// <returns></returns>
 public static async Task <System.IO.Stream> GetContentStreamAsync(this ODItem item, ODConnection connection, StreamDownloadOptions downloadOptions)
 {
     return(await connection.DownloadStreamForItemAsync(item.ItemReference(), downloadOptions));
 }