Exemplo n.º 1
0
        public void Load()
        {
            if (comments.Count > 0)
            {
                loaded = true;
            }
            if (loaded)
            {
                return;
            }

            if (BlogXData.Resolver != null)
            {
                string fullPath = BlogXData.ResolvePath(FileName);
                if (File.Exists(fullPath))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(DayExtra));
                    using (StreamReader reader = new StreamReader(fullPath))
                    {
                        DayExtra e = (DayExtra)ser.Deserialize(reader);
                        this.comments = e.comments;
                    }
                }
            }
            loaded = true;
        }
Exemplo n.º 2
0
        public void Build(BlogXData data)
        {
            changeNumber = data.CurrentEntryChangeCount;
            Hashtable build = new Hashtable();

            foreach (DayEntry day in data.Days)
            {
                day.Load();

                foreach (Entry entry in day.Entries)
                {
                    foreach (string cat in entry.GetSplitCategories())
                    {
                        if (!build.Contains(cat))
                        {
                            build[cat] = new CategoryCacheEntryDetailCollection();
                        }
                        CategoryCacheEntryDetail entryDetail = new CategoryCacheEntryDetail();
                        entryDetail.DayDate = day.Date;
                        entryDetail.EntryId = entry.EntryId;

                        ((CategoryCacheEntryDetailCollection)(build[cat])).Add(entryDetail);
                    }
                }
            }

            entries.Clear();
            foreach (DictionaryEntry de in build)
            {
                CategoryCacheEntry entry = new CategoryCacheEntry();
                entry.Name         = (string)de.Key;
                entry.EntryDetails = (CategoryCacheEntryDetailCollection)de.Value;
                entries.Add(entry);
            }
        }
Exemplo n.º 3
0
 void SaveBlogCore()
 {
     using (StreamWriter writer = new StreamWriter(BlogXData.ResolvePath("blogdata.xml")))
     {
         XmlSerializer ser = new XmlSerializer(typeof(BlogCoreData));
         ser.Serialize(writer, data);
     }
 }
Exemplo n.º 4
0
        public void Save()
        {
            XmlSerializer ser = new XmlSerializer(typeof(EntryIdCache));

            using (StreamWriter writer = new StreamWriter(BlogXData.ResolvePath(FileName)))
            {
                ser.Serialize(writer, this);
            }
        }
Exemplo n.º 5
0
 public void Ensure(BlogXData data)
 {
     Load();
     if (changeNumber != data.CurrentEntryChangeCount)
     {
         Build(data);
         Save();
     }
 }
Exemplo n.º 6
0
        public void Load()
        {
            string fullPath = BlogXData.ResolvePath(FileName);

            if (File.Exists(fullPath))
            {
                XmlSerializer ser = new XmlSerializer(typeof(EntryIdCache));
                using (StreamReader reader = new StreamReader(fullPath))
                {
                    EntryIdCache e = (EntryIdCache)ser.Deserialize(reader);
                    this.entries      = e.entries;
                    this.changeNumber = e.ChangeNumber;
                }
            }
        }
Exemplo n.º 7
0
        void LoadBlogCore()
        {
            string fullPath = BlogXData.ResolvePath("blogdata.xml");

            if (File.Exists(fullPath))
            {
                using (StreamReader reader = new StreamReader(fullPath))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(BlogCoreData));
                    data = (BlogCoreData)ser.Deserialize(reader);
                }
            }
            else
            {
                data = new BlogCoreData();
                SaveBlogCore();
            }
        }
Exemplo n.º 8
0
        public void Build(BlogXData data)
        {
            changeNumber = data.CurrentEntryChangeCount;
            Hashtable build = new Hashtable();

            entries.Clear();

            foreach (DayEntry day in data.Days)
            {
                day.Load();

                foreach (Entry entry in day.Entries)
                {
                    EntryIdCacheEntry ec = new EntryIdCacheEntry();
                    ec.Date    = day.Date;
                    ec.EntryId = entry.EntryId;
                    entries.Add(ec);
                }
            }
        }
Exemplo n.º 9
0
        public void Load()
        {
            if (entries.Count > 0)
            {
                loaded = true;
            }
            if (loaded)
            {
                return;
            }

            if (BlogXData.Resolver != null)
            {
                XmlSerializer ser = new XmlSerializer(typeof(DayEntry));
                using (StreamReader reader = new StreamReader(BlogXData.ResolvePath(FileName)))
                {
                    DayEntry e = (DayEntry)ser.Deserialize(reader);
                    this.entries = e.entries;
                }
            }
            loaded = true;
        }