public RetVal LoadFromString(string line) { RetVal retVal = new RetVal(); try { if (line != null && line.Trim() != "") { string[] tokens = line.Split(new char[] { ',' }); if (tokens.Length >= MinNumTokens) { Application = tokens[0]; ApiKey = tokens[1]; ApiSecretKey = tokens[2]; AccessToken = tokens[3]; AccessTokenSecret = tokens[4]; if (retVal.MoreInfo == "") { retVal.Succeeded = true; } } } else { retVal.MoreInfo += "Empty string"; } } catch (Exception ex) { retVal.MoreInfo += "Exception in LoadFromString(): " + ex.ToString(); } return(retVal); }
private static List <TwitCreds> LoadTwitterCreds(string credsFileName) { List <TwitCreds> credsList = new List <TwitCreds>(); try { using (StreamReader sr = new StreamReader(credsFileName)) { string line = sr.ReadLine(); while (line != null) { line = line.Trim(); if (line != "" && line[0] != '#') { TwitCreds creds = new TwitCreds(); RetVal rv = creds.LoadFromString(line); if (!rv.Succeeded) { ShowMessage($"Error loading Twitter credentials {rv.MoreInfo}"); } else { credsList.Add(creds); } } line = sr.ReadLine(); } } } catch (Exception ex) { ShowMessage("Exception in LoadTwitterCreds(): " + ex.ToString()); } return(credsList); }
public RetVal LoadFromString(string line) { RetVal retVal = new RetVal(); try { if (line != null && line.Trim() != "") { string[] tokens = line.Split(new char[] { ',' }); if (tokens.Length >= MinNumTokens) { WordsInputFile = tokens[0]; ParsedJsonFile = tokens[1]; RawJsonFiles = tokens[2]; int val = 0; if (!int.TryParse(tokens[3], out val)) { retVal.MoreInfo += "Bad MaxTweets value"; } else { MaxTweets = val; } if (!int.TryParse(tokens[4], out val)) { retVal.MoreInfo += "Bad MaxSeconds value"; } else { MaxSeconds = val; } Verbose = false; string verboseStr = tokens[5].Trim().ToUpper(); if (verboseStr == "Y" || verboseStr == "YES" || verboseStr == "TRUE") { Verbose = true; } if (retVal.MoreInfo == "") { retVal.Succeeded = true; } } } else { retVal.MoreInfo += "Empty string"; } } catch (Exception ex) { retVal.MoreInfo += "Exception in LoadFromString(): " + ex.ToString(); } return(retVal); }
private static List <WorkItem> LoadWorkItems(string workItemsFileName) { List <WorkItem> workItemsList = new List <WorkItem>(); try { using (StreamReader sr = new StreamReader(workItemsFileName)) { int lineNum = 0; string line = sr.ReadLine(); while (line != null) { lineNum++; line = line.Trim(); if (line != "" && line[0] != '#') { WorkItem wi = new WorkItem(); RetVal rv = wi.LoadFromString(line); if (rv.Succeeded) { workItemsList.Add(wi); } else { ShowMessage($"Error on {lineNum} {rv.MoreInfo}"); } } line = sr.ReadLine(); } } } catch (Exception ex) { ShowMessage("Exception in LoadWorkItems(): " + ex.ToString()); } return(workItemsList); }