Skip to content

Instantly share code, notes, and snippets.

@rippinrobr
Created February 23, 2011 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rippinrobr/840627 to your computer and use it in GitHub Desktop.
Save rippinrobr/840627 to your computer and use it in GitHub Desktop.
The Service file created to retrieve the input data
//------------------------------------------------------------------------------
// Generated on 2011-02-23 10:57:10 -0500
// Generated by rob
// Using Generator 0.1.1
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace Standings
{
public interface IStandingsService
{
string ErrorMessage {get;set;}
IQueryable<ErrorModel> Get(string inputFilePath);
}
public class StandingsService
{
public string ErrorMessage {get;set;}
public IEnumerable<Standings> Get(string inputUri)
{
if (String.IsNullOrEmpty(inputUri)) throw new ArgumentNullException("inputUri");
var dataList = new List<Standings>();
var rawContent = LoadeSiteContent(inputUri);
var parsedContent = JsonConvert.DeserializeObject<Standings>(rawContent);
if (parsedContent != null ) dataList.Add(parsedContent);
return dataList;
}
private static string LoadeSiteContent(string url)
{
var client = new WebClient();
var html = client.DownloadData(url);
var utf = new UTF8Encoding();
return utf.GetString(html);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment