Skip to content

Instantly share code, notes, and snippets.

View sandrinodimattia's full-sized avatar
🏠
Working from home

Sandrino Di Mattia sandrinodimattia

🏠
Working from home
View GitHub Profile
@sandrinodimattia
sandrinodimattia / gist:3162134
Created July 23, 2012 05:46
ServerConfigurationSection app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="srvConfig" type="Sandrino.MyApplication.ServerConfigurationSection, Sandrino.MyApplication"/>
</configSections>
<srvConfig port="1986"/>
</configuration>
@sandrinodimattia
sandrinodimattia / gist:3162136
Created July 23, 2012 05:46
IServerConfigurationProvider Test
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void ServerMissing()
{
RegisterConfiguration("Configurations\\ServerMissing.config");
// Read the file.
var prov = krn.Get<IServerConfigurationProvider>();
var section = prov.Read();
@sandrinodimattia
sandrinodimattia / gist:3162225
Created July 23, 2012 06:16
Google ClientLogin
public static class ClientLogin
{
/// <summary>
/// Client login url where we'll post login data to.
/// </summary>
private static string clientLoginUrl =
@"https://www.google.com/accounts/ClientLogin";
/// <summary>
/// Data to be sent with the post request.
public class GoogleSession : IDisposable
{
/// <summary>
/// Auth token.
/// </summary>
private string auth;
/// <summary>
/// Initialize request.
/// </summary>
@sandrinodimattia
sandrinodimattia / gist:3162232
Created July 23, 2012 06:18
GoogleSession sample
class Program
{
static void Main(string[] args)
{
// Empty line.
Console.WriteLine("");
// Get username.
Console.Write(" Enter your Google username: ");
string username = Console.ReadLine();
@sandrinodimattia
sandrinodimattia / gist:3162254
Created July 23, 2012 06:19
Google POST Request
/// <summary>
/// Send a post request to Google.
/// </summary>
/// <param name="url"></param>
/// <param name="postFields"></param>
/// <returns></returns>
public void PostRequest(string url, params GoogleParameter[] postFields)
{
// Format the parameters.
string formattedParameters = string.Empty;
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.
@sandrinodimattia
sandrinodimattia / gist:3162258
Created July 23, 2012 06:20
GoogleSyndicationItem
public abstract class GoogleSyndicationItem
{
/// <summary>
/// Initialize the item.
/// </summary>
/// <param name="item"></param>
internal GoogleSyndicationItem(SyndicationItem item)
{
if (item != null)
{
@sandrinodimattia
sandrinodimattia / gist:3162260
Created July 23, 2012 06:21
GoogleReader subscription
public abstract class GoogleSyndicationItem
{
/// <summary>
/// Initialize the item.
/// </summary>
/// <param name="item"></param>
internal GoogleSyndicationItem(SyndicationItem item)
{
if (item != null)
{
@sandrinodimattia
sandrinodimattia / gist:3162264
Created July 23, 2012 06:21
GoogleReader Url
public static class ReaderUrl
{
/// <summary>
/// Base url for Atom services.
/// </summary>
public const string AtomUrl = "https://www.google.com/reader/atom/";
/// <summary>
/// Base url for API actions.
/// </summary>