public static TwitterParser Factory(NakedTwitt nakedTwittToParse) { string regExpression = @"(?<TwitterKeyToken>\#\w+)\s+.+"; MatchCollection matches = Regex.Matches(nakedTwittToParse.Text, regExpression, RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase); string twiterKeyToken = string.Empty; if (matches.Count > 0 && matches[0].Groups["TwitterKeyToken"] != null && !string.IsNullOrEmpty(matches[0].Groups["TwitterKeyToken"].Value)) { twiterKeyToken = matches[0].Groups["TwitterKeyToken"].Value; switch (twiterKeyToken.ToUpper()) { case "#TEFOP": return new TEFOPParser(nakedTwittToParse); break; case "#TEFCL": return new TEFCLParser(nakedTwittToParse); break; case "#BTP": return new BTPParser(nakedTwittToParse); break; case "#BTPH": return new BTPHParser(nakedTwittToParse); break; case "#BTPC": return new BTPCParser(nakedTwittToParse); break; case "#BTPD": return new BTPDParser(nakedTwittToParse); break; case "#VBTPX": return new VBTPXParser(nakedTwittToParse); break; case "#VBTPE": return new VBTPEParser(nakedTwittToParse); break; case "#VBTPD": return new VBTPDParser(nakedTwittToParse); break; case "#VBTPC": return new VBTPCParser(nakedTwittToParse); break; default: log.Error(string.Format("TwitterParser cannot deal with {0}",twiterKeyToken)); return null; break; } } else { log.Error(string.Format("TwitterParser cannot deal with {0}", nakedTwittToParse.Text)); return null; } }
public IList<NakedTwitt> RetrieveTwitts(int count) { IList<NakedTwitt> result = new List<NakedTwitt>(); string startingTweetId = "2b8f9ff3-8d4f-4e03-9b45-2a67feafa8d9";//System.Guid.NewGuid().ToString(); NakedTwitt tefOpen = new NakedTwitt() { StringId = startingTweetId + "-001", CreatedDate = DateTime.Now, Text = @"#tefop ABC.AR 2012:12:01:22:55 (myID) blablablablablablablablalbalsfsdfsd" }; NakedTwitt tefClose = new NakedTwitt() { StringId = startingTweetId + "-002", CreatedDate = DateTime.Now.AddHours(1), Text = @"#TEFCL ABC.AR 2012:12:02:22:55 (myID) blablablablablablablablalbalsfsdfsd" }; NakedTwitt btp = new NakedTwitt() { StringId = startingTweetId + "-003", CreatedDate = DateTime.Now.AddHours(2), Text = @"#BTP ABC.* 2012:12:02:22:55 33 (theID) bl ab l a b l a (blablablablablalbalsfsdfsd)" }; NakedTwitt btph = new NakedTwitt() { StringId = startingTweetId + "-004", CreatedDate = DateTime.Now.AddHours(3), Text = @"#BTPH ABC.* 2012:12:02:22:55 44 (theID) bl ab l a b l a (blablablablablalbalsfsdfsd)" }; NakedTwitt btpc = new NakedTwitt() { StringId = startingTweetId + "-005", CreatedDate = DateTime.Now.AddHours(4), Text = @"#BTPC ABC.* (theID) bl ab l a b l a (blablablablablalbalsfsdfsd)" }; result.Add(tefOpen); result.Add(tefClose); result.Add(btp); result.Add(btph); result.Add(btpc); return result; }
protected TwitterParser(NakedTwitt nakedTwittToParse) { this.nakedTwittToParse = nakedTwittToParse; }
public BTPDParser(NakedTwitt nakedTwittToParse) : base(nakedTwittToParse) { }
public TEFCLParser(NakedTwitt nakedTwittToParse) : base(nakedTwittToParse) { }
private TwitterIssue AssembleTweetIssue(NakedTwitt nakedTwitt) { TwitterParser.TwitterParser parser = null; try { parser = TwitterParser.TwitterParser.Factory(nakedTwitt); return parser.Parse(); } catch (Exception ex) { if (parser != null && parser.RegExpression != null) log.Error(string.Format("Error parsing twitter: {0} with regex: {1}", nakedTwitt.Text, parser.RegExpression), ex); else log.Error(string.Format("Error parsing twitter: {0}", nakedTwitt.Text), ex); return null; } }
public VBTPEParser(NakedTwitt nakedTwittToParse) : base(nakedTwittToParse) { }