Пример #1
0
        public CacheAccountItem GetPersistentCache(MailSyncIdentifier identifier)
        {
            //If cache does not exists, create it
            if (!File.Exists(filename))
            {
                return(new CacheAccountItem()
                {
                    Mailbox = identifier.Mailbox,
                    MailAccount = identifier.Username,
                    CachedMails = new List <CacheMailItem>()
                });
            }

            //If exists, load it
            var jsonText        = File.ReadAllText(filename);
            var cacheAccountDto = JsonConvert.DeserializeObject <CacheAccountItemDto>(jsonText);

            var cacheAccount = new CacheAccountItem()
            {
                Mailbox     = cacheAccountDto.Mailbox,
                MailAccount = cacheAccountDto.MailAccount,
                LastUid     = cacheAccountDto.LastUid,
                CachedMails = (from m in cacheAccountDto.CachedMails
                               select new CacheMailItem()
                {
                    MailId = m.MailId,
                    BodyText = m.BodyText
                }).ToList()
            };

            return(cacheAccount);
        }
Пример #2
0
 internal MailCacheService(MailSyncIdentifier identifier)
 {
     this.identifier = identifier;
     cachedAccount   = new CacheAccountItem()
     {
         MailAccount = identifier.Username,
         Mailbox     = identifier.Mailbox,
         CachedMails = new List <CacheMailItem>()
     };
 }