Click here to Skip to main content
14,663,954 members
Home » Discussions » C#
   

C#

 
AnswerRe: Cannot Create and Return an Instance of a Class Pin
Richard Deeming3-Sep-20 22:05
mveRichard Deeming3-Sep-20 22:05 
GeneralRe: Cannot Create and Return an Instance of a Class Pin
Richard MacCutchan3-Sep-20 22:29
mveRichard MacCutchan3-Sep-20 22:29 
GeneralRe: Cannot Create and Return an Instance of a Class Pin
Richard Deeming4-Sep-20 3:10
mveRichard Deeming4-Sep-20 3:10 
QuestionProper Error handling Pin
Exoskeletor3-Sep-20 12:11
MemberExoskeletor3-Sep-20 12:11 
AnswerRe: Proper Error handling Pin
Gerry Schmitz3-Sep-20 16:30
mveGerry Schmitz3-Sep-20 16:30 
GeneralRe: Proper Error handling Pin
Exoskeletor3-Sep-20 17:48
MemberExoskeletor3-Sep-20 17:48 
AnswerRe: Proper Error handling Pin
GuyThiebaut4-Sep-20 3:08
professionalGuyThiebaut4-Sep-20 3:08 
GeneralRe: Proper Error handling Pin
Exoskeletor4-Sep-20 3:23
MemberExoskeletor4-Sep-20 3:23 
Oh thank you. Any improvement is highly welcome, i have refactor it to:

public static string StoredDatesList
        {
            get => Preferences.Get(nameof(StoredDatesList), string.Empty);
            set => Preferences.Set(nameof(StoredDatesList), value);
        }
        public static async Task<string> GetDraws(Uri url, string date)
        {
            var StoredDates = JsonConvert.DeserializeObject<Dictionary<string, string>>(StoredDatesList);
            var contents = string.Empty;
            var current = Connectivity.NetworkAccess;
            var client = new HttpClient();

            if (StoredDates != null)
                if (StoredDates.ContainsKey(date))
                {
                    contents = StoredDates[date];
                }
                else
                {
                    if (current != NetworkAccess.Internet)
                        return Helpers.Settings.Common_Error_NoInternetConnection;

                    contents = await DownloadResults(url, date, StoredDates, contents, client);
                }
            else
            {
                if (current != NetworkAccess.Internet)
                    return Helpers.Settings.Common_Error_NoInternetConnection;

                StoredDates = new Dictionary<string, string>();
                contents = await DownloadResults(url, date, StoredDates, contents, client);
            }
            return contents;
        }

        private static async Task<string> DownloadResults(Uri url, string date, Dictionary<string, string> StoredDates, string contents, HttpClient client)
        {
            contents = await client.GetStringAsync(url);
            var res2 = JsonConvert.DeserializeObject<RootObject>(contents.ToString());
            if (180 == res2.content.Count)
            {
                StoredDates.Add(date, contents);
                StoredDatesList = JsonConvert.SerializeObject(StoredDates, Formatting.Indented);
            }

            return contents;
        }

...
public const string Common_Error_NoInternetConnection = "Error_NoInternetConnection";


So i would check every time if the return sting is equal to Common_Error_NoInternetConnection, Does this sounds like a solid idea?

modified 4-Sep-20 16:37pm.

QuestionCsvHelper, converting $0.00 to 0.00 Pin
jkirkerx3-Sep-20 12:08
professionaljkirkerx3-Sep-20 12:08 
AnswerRe: CsvHelper, converting $0.00 to 0.00 Pin
Gerry Schmitz3-Sep-20 12:55
mveGerry Schmitz3-Sep-20 12:55 
GeneralRe: CsvHelper, converting $0.00 to 0.00 Pin
jkirkerx3-Sep-20 13:20
professionaljkirkerx3-Sep-20 13:20 
AnswerGot It Pin
jkirkerx4-Sep-20 6:34
professionaljkirkerx4-Sep-20 6:34 
GeneralRe: Got It Pin
Mycroft Holmes4-Sep-20 12:15
professionalMycroft Holmes4-Sep-20 12:15 
GeneralRe: Got It Pin
jkirkerx4-Sep-20 13:54
professionaljkirkerx4-Sep-20 13:54 
AnswerI have 3 or 5 of them now, yes they need more work Pin
jkirkerx4-Sep-20 14:08
professionaljkirkerx4-Sep-20 14:08 
GeneralRe: I have 3 or 5 of them now, yes they need more work Pin
Gerry Schmitz5-Sep-20 3:58
mveGerry Schmitz5-Sep-20 3:58 
GeneralRe: I have 3 or 5 of them now, yes they need more work Pin
jkirkerx5-Sep-20 7:24
professionaljkirkerx5-Sep-20 7:24 
QuestionCsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx2-Sep-20 13:55
professionaljkirkerx2-Sep-20 13:55 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
OriginalGriff2-Sep-20 22:42
mveOriginalGriff2-Sep-20 22:42 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 6:11
professionaljkirkerx3-Sep-20 6:11 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
Dave Kreskowiak3-Sep-20 8:51
mveDave Kreskowiak3-Sep-20 8:51 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas PinPopular
Richard Deeming2-Sep-20 22:50
mveRichard Deeming2-Sep-20 22:50 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 6:13
professionaljkirkerx3-Sep-20 6:13 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
Luc Pattyn3-Sep-20 1:36
sitebuilderLuc Pattyn3-Sep-20 1:36 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 6:12
professionaljkirkerx3-Sep-20 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.