Created
July 23, 2012 06:20
-
-
Save sandrinodimattia/3162256 to your computer and use it in GitHub Desktop.
GoogleService
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 abstract class GoogleService : IDisposable | |
{ | |
/// <summary> | |
/// Current google session. | |
/// </summary> | |
protected GoogleSession session; | |
/// <summary> | |
/// Creating this class will automatically try to log in and create a session. | |
/// That way for each service we create we don't need to worry about the implementation of authentication and session. | |
/// </summary> | |
/// <param name="service"></param> | |
/// <param name="username"></param> | |
/// <param name="password"></param> | |
/// <param name="source"></param> | |
protected GoogleService(string service, string username, | |
string password, string source) | |
{ | |
// Get the Auth token. | |
string auth = ClientLogin.GetAuthToken(service, username, password, source); | |
// Create a new session using this token. | |
this.session = new GoogleSession(auth); | |
} | |
/// <summary> | |
/// Clean up the session. | |
/// </summary> | |
public void Dispose() | |
{ | |
if (session != null) | |
session.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment