Created
February 23, 2011 16:16
-
-
Save rippinrobr/840627 to your computer and use it in GitHub Desktop.
The Service file created to retrieve the input data
This file contains 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
//------------------------------------------------------------------------------ | |
// 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