Skip to content

Instantly share code, notes, and snippets.

@FelicePollano
Created December 12, 2011 16:51
Show Gist options
  • Select an option

  • Save FelicePollano/1468161 to your computer and use it in GitHub Desktop.

Select an option

Save FelicePollano/1468161 to your computer and use it in GitHub Desktop.
GSync
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