Created
December 12, 2011 16:51
-
-
Save FelicePollano/1468161 to your computer and use it in GitHub Desktop.
GSync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ContactFetcher | |
| { | |
| public event EventHandler<ContactFetchEventArgs> ContactFetch = delegate { }; | |
| public void BeginFetchAll(string user, string password) | |
| { | |
| ContactsService svc = new ContactsService("MyApp"); | |
| svc.setUserCredentials(user, password); | |
| List<ContactEntry> contacts = new List<ContactEntry>(); | |
| int i = 0; | |
| svc.AsyncOperationCompleted += (s, e) => | |
| { | |
| foreach (ContactEntry entry in (e.Feed as ContactsFeed).Entries) | |
| { | |
| ContactFetch(this, new ContactFetchEventArgs { Contact=entry, Current=++i,Of=e.Feed.TotalResults }); | |
| } | |
| if (e.Feed.NextChunk != null) | |
| { | |
| svc.QueryFeedAync(new Uri(e.Feed.NextChunk), DateTime.MinValue, this); | |
| } | |
| }; | |
| svc.QueryFeedAync(new Uri(ContactsQuery.CreateContactsUri(user)), DateTime.MinValue, this); | |
| } | |
| } | |
| public class ContactFetchEventArgs:EventArgs | |
| { | |
| public ContactEntry Contact { get; set; } | |
| public int Current { get; set; } | |
| public int Of { get; set; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment