Spaces:
Runtime error
Runtime error
File size: 2,541 Bytes
77ebc6a ec947b6 77ebc6a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
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;
}
} |