コード例 #1
0
        public async Task <OneDriveDeltaView> GetDeltaView(string requestUri)
        {
            // A delta view from OneDrive can be larger than a single request, so loop until we have built the complete
            // view by following the NextLink properties.
            OneDriveDeltaView deltaView = new OneDriveDeltaView();

            while (true)
            {
                OneDriveResponse <Item[]> oneDriveResponse =
                    await this.GetOneDriveItemSet <Item[]>(requestUri).ConfigureAwait(false);

                deltaView.Items.AddRange(oneDriveResponse.Value);

                if (string.IsNullOrWhiteSpace(oneDriveResponse.NextLink))
                {
                    deltaView.Token     = oneDriveResponse.DeltaToken;
                    deltaView.DeltaLink = oneDriveResponse.DeltaLink;

                    break;
                }

                requestUri = oneDriveResponse.NextLink;
            }

            return(deltaView);
        }
コード例 #2
0
        public async Task <IEnumerable <Item> > GetChildItems(ItemContainer parent)
        {
            string requestUri;

            // Build the request specific to the parent
            if (parent.IsItem)
            {
                // If we know the item is NOT a folder, or if it is a folder and has no children, return an empty list since
                // we know that it will not have any child items.
                if (parent.Item.Folder == null || parent.Item.Folder.ChildCount == 0)
                {
                    return(new List <Item>());
                }

                requestUri = string.Format("/v1.0/drive/items/{0}/children", parent.Item.Id);
            }
            else
            {
                requestUri = string.Format("/v1.0/drives/{0}/root/children", parent.Drive.Id);
            }

            List <Item> items = new List <Item>();

            while (true)
            {
                OneDriveResponse <Item[]> oneDriveResponse =
                    await this.GetOneDriveItemSet <Item[]>(requestUri).ConfigureAwait(false);

                items.AddRange(oneDriveResponse.Value);

                if (string.IsNullOrWhiteSpace(oneDriveResponse.NextLink))
                {
                    break;
                }

                requestUri = oneDriveResponse.NextLink;
            }

            return(items);
        }
コード例 #3
0
        public async Task <Drive> GetDefaultDrive()
        {
            OneDriveResponse <Drive> response = await this.GetOneDriveItem <Drive>("/v1.0/drive").ConfigureAwait(false);

            return(response.Value);
        }