Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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