Spaces:
Runtime error
Runtime error
public static class GlobalData | |
{ | |
public static List<Quote> Quotes { get; set; } | |
} | |
public static class Extensions { | |
public static string CleanString(this string str) { | |
if (str == null) return ""; | |
var result = str.Trim().Trim('"'); | |
result = String.Join(' ', result.Split(' ', StringSplitOptions.RemoveEmptyEntries)); | |
return result; | |
} | |
public static Quote GetQuote1(this MittalInput json) { | |
var quote = new Quote(); | |
quote.QuoteText = json.Content.CleanString(); | |
if (json.Author != null) { | |
var authorData = json.Author.Split(','); | |
quote.Author = authorData[0].CleanString(); | |
if (authorData.Length > 1){ | |
quote.Book = authorData[1].CleanString(); | |
quote.Source = "Book"; | |
} | |
} | |
else quote.Author = "Unknown"; | |
quote.Language = "english"; | |
quote.Categories = String.Join(",", json.Tags.Select(x => x.ToLower().CleanString()).Distinct()); | |
quote.DataSet = "mittal"; | |
return quote; | |
} | |
public static Quote GetQuote2(this QuotableInput json) { | |
var quote = new Quote(); | |
quote.QuoteText = json.Content.CleanString(); | |
if (json.Author != null) { | |
var authorData = json.Author.Split(','); | |
quote.Author = authorData[0].CleanString(); | |
if (authorData.Length > 1){ | |
quote.Book = authorData[1].CleanString(); | |
quote.Source = "Book"; | |
} | |
} | |
else quote.Author = "Unknown"; | |
quote.Language = "english"; | |
quote.Categories = String.Join(",", json.Tags.Select(x => x.ToLower().CleanString()).Distinct()); | |
quote.DataSet = "quotable"; | |
return quote; | |
} | |
public static Quote GetQuote3(this ManannInput data) { | |
var quote = new Quote(); | |
quote.QuoteText = data.quote.CleanString(); | |
if (data.author != null) { | |
var authorData = data.author.Split(','); | |
quote.Author = authorData[0].CleanString(); | |
if (authorData.Length > 1){ | |
quote.Book = authorData[1].CleanString(); | |
quote.Source = "Book"; | |
} | |
} | |
else quote.Author = "Unknown"; | |
quote.Language = "english"; | |
quote.Categories = String.Join(",", data.category.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => x.ToLower().CleanString()).Distinct()); | |
quote.DataSet = "manann"; | |
return quote; | |
} | |
} |