public static IEnumerable <TwitterStatus> GetFromCache(TwitterResource resource) { string fileName = GetCacheName(resource); var serializer = new SharpSerializer(SerializerSettings); IEnumerable <TwitterStatus> statuses = null; MutexUtil.DoWork("OCELL_FILE_MUTEX" + fileName, () => { try { using (var stream = FileAbstractor.GetFileStream(fileName)) { if (stream.Length != 0) { statuses = serializer.Deserialize(stream) as IEnumerable <TwitterStatus>; } } } catch (Exception ex) { Debug.WriteLine(ex); } }); return(statuses ?? new List <TwitterStatus>()); }
public TweetLoader(TwitterResource resource, bool cached) : this() { Resource = resource; service = ServiceDispatcher.GetService(resource.User); conversationService = new ConversationService(resource.User); Cached = cached; }
public override bool Equals(Object obj) { // Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } TwitterResource p = (TwitterResource)obj; return(p.Data == Data && p.Type == Type && p.User == User); }
public static void SaveToCache(TwitterResource resource, IEnumerable <TwitterStatus> list) { string fileName = GetCacheName(resource); var serializer = new SharpSerializer(SerializerSettings); MutexUtil.DoWork("OCELL_FILE_MUTEX" + fileName, () => { try { using (var stream = FileAbstractor.GetFileStream(fileName)) { serializer.Serialize(list.Distinct().OfType <TwitterStatus>().ToList(), stream); } } catch (Exception ex) { Debug.WriteLine(ex); } }); }
private static string GetCacheName(TwitterResource resource) { string Key = "Cache" + RemoveSymbols(resource.String); return(Key); }
public TweetLoader(TwitterResource resource) : this(resource, true) { LoadCacheAsync(); }