Пример #1
0
        public ObservableCollection<Content> CollectMedia()
        {
            InitDB();
            ObservableCollection<Content> _cntc = new ObservableCollection<Content>();
            ContentCollection c = new ContentCollection();
            c.LoadAll();
            foreach (Content item in c)
            {
                _cntc.Add(item);
            }

            return _cntc;
        }
Пример #2
0
        private void SerializeContentCollection()
        {
            try
            {
                ObservableCollection<Content> _cntc = new ObservableCollection<Content>();
                ContentCollection c = new ContentCollection();
                c.LoadAll();
                foreach (Content item in c)
                {
                    item.Snapshot = null;
                    _cntc.Add(item);
                }

                //ContentCollection contentCollection = new ContentCollection();
                //contentCollection.LoadAll();
                string FileName = @"c:\content\media\xml\content.xml";
                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(ObservableCollection<Content>));
                    ser.Serialize(fs, _cntc);
                    fs.Flush();
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
            }
        }