示例#1
0
        public static void ListAlbums(PhotosLibraryService service)
        {
            Console.WriteLine();
            Console.WriteLine("Fetching albums...");

            Google.Apis.PhotosLibrary.v1.AlbumsResource.ListRequest request = service.Albums.List();

            // List events.
            Google.Apis.PhotosLibrary.v1.Data.ListAlbumsResponse response = request.Execute();
            Console.WriteLine("Albums:");
            if (response.Albums != null && response.Albums.Count > 0)
            {
                bool morePages = true;

                while (response.Albums != null && response.Albums.Count > 0 && morePages)
                {
                    foreach (var album in response.Albums)
                    {
                        string title = album.Title;
                        Console.WriteLine($"> {title}");
                    }

                    if (response.NextPageToken != null)
                    {
                        request.PageToken = response.NextPageToken;
                        response          = request.Execute();
                    }
                    else
                    {
                        morePages = false;
                    }
                }
            }
            else
            {
                Console.WriteLine("No albums found.");
            }
        }
示例#2
0
        public static void ListAlbums(PhotosLibraryService service, ILogger logger)
        {
            logger.LogInformation("");
            logger.LogInformation("Fetching albums...");

            Google.Apis.PhotosLibrary.v1.AlbumsResource.ListRequest request = service.Albums.List();

            // List events.
            Google.Apis.PhotosLibrary.v1.Data.ListAlbumsResponse response = request.Execute();
            logger.LogInformation("Albums:");
            if (response.Albums != null && response.Albums.Count > 0)
            {
                while (response.Albums != null && response.Albums.Count > 0)
                {
                    foreach (var albumresponse in response.Albums)
                    {
                        string title = albumresponse.Title;
                        logger.LogInformation($"> {title}");
                    }

                    if (response.NextPageToken != null)
                    {
                        request.PageToken = response.NextPageToken;
                        response          = request.Execute();
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                logger.LogInformation("No albums found.");
            }
        }