예제 #1
0
 ObservableCollection <TEntity> GetNewDataSource()
 {
     using (ReusableStream data = GetDataStream()) {
         XmlSerializer s = new XmlSerializer(ObservableCollectionType);
         return((ObservableCollection <TEntity>)s.Deserialize(data.Data));
     }
 }
예제 #2
0
 protected override HomeLayout FindCore(int id)
 {
     lock (layoutLocks[id]) {
         if (layouts[id] != null)
         {
             return(layouts[id]);
         }
         using (ReusableStream s = DataHelper.GetDataFile(string.Format("Images\\HomePlan{0}.jpg", id + 1))) {
             byte[] data = new byte[(int)s.Data.Length];
             s.Data.Read(data, 0, data.Length);
             layouts[id] = new HomeLayout()
             {
                 ID = id, Image = data
             };
         }
         return(layouts[id]);
     }
 }
예제 #3
0
        public static ReusableStream GetDataFile(string name)
        {
            ReusableStream stream;
            bool           loadData = false;

            lock (dataFilesLock) {
                if (!dataFiles.TryGetValue(name, out stream))
                {
                    stream   = new ReusableStream();
                    loadData = true;
                    dataFiles.Add(name, stream);
                }
            }
            stream.Reset();
            if (loadData)
            {
                stream.Data = GetDataFileCore(name);
            }
            return(stream);
        }