コード例 #1
0
ファイル: Program.cs プロジェクト: keyanmca/_Signage
        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
ファイル: Program.cs プロジェクト: keyanmca/_Signage
        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)
            {
            }
        }