Suggestion: Get All X

Apr 19, 2010 at 6:43 AM

I have a need to get all elements from a specific type without taking care on paging.

I wrote myself helper methods and I think you should add it to your framework as a standard.

For example:

Get all members in a group (not only a specific page):

public static List<Member> GroupsAllMemberGetList(string groupId)

{

              return GroupsAllMemberGetList(groupId, 1, null);

}

 

private static List<Member> GroupsAllMemberGetList(string groupId, int pageIndex, List<Member> allMembers)

{

           MemberCollection tempMembers = ExternalAPIHelper.flickr.GroupsMembersGetList(groupId, flickrPhotosPageSize, pageIndex, MemberTypes.None); 

           if (allMembers == null)

            {

               allMembers = new List<Member>(tempMembers);

           }

           else

           {

               foreach (Member photo in tempMembers)

               {

                   allMembers.Add(photo);

               }

           }

 

           if (tempMembers.Pages <= flickrPhotosPageSize * pageIndex)

           {

               return allMembers;

           }

           else

           {

               pageIndex++;

               return GroupsAllMemberGetList(groupId, pageIndex, allMembers);

           }

       }

 

(The flickrPhotosPageSize is a global var).

 

Omri

 

Apr 19, 2010 at 6:51 AM

Sorry, this is an migrated from an old code, you don't need the flickrPhotosPageSize (if (tempMembers.Pages <=  pageIndex))

 

Omri

Coordinator
Apr 23, 2010 at 4:08 PM

While in some scenarioes this might be nice to have I think it extracts a bit away from the Flickr API a bit too much - people still need to understand what is happening in terms of calls to the web etc so they don't end up doing things that are too bandwidth intensive.

 

Apr 25, 2010 at 6:51 AM

Ok, its up to you :)

I must say that for myself I already implemented it to all types of information...