コード例 #1
0
        /// <summary>
        /// Synchronously load program settings from file
        /// </summary>
        /// <returns>Returns program settings loaded from file</returns>
        public T LoadSettings()
        {
            var loadedModel = fileSerializer.Deserialize <T>(SettingsFilePath);

            // Should automatically notify all observers that cached settings were changed
            Settings = loadedModel ?? new T();

            return(Settings);
        }
コード例 #2
0
        /// <summary>
        /// This function serves to centralize file reads within this class.
        /// </summary>
        private FileCacheItem ReadFile(string filePath)
        {
            FileCacheItem item = null;

            if (File.Exists(filePath))
            {
                using (FileStream stream = GetStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    item = _serializer.Deserialize(stream);
                }
            }

            return(item);
        }
コード例 #3
0
        private void Run()
        {
            while (_status)
            {
                string[] files = Directory.GetFiles(_options.Folder, "*." + _options.FileType);

                foreach (string file in files)
                {
                    T message = _serializer.Deserialize(file);

                    _callback(message);

                    CleanupFile(file);
                }

                _resetEvent.WaitOne(TimeSpan.FromSeconds(_options.Interval));
            }
        }
コード例 #4
0
 /// <summary>
 /// Load element values into the ProteinDictionary and return an <see cref="T:System.Collections.Generic.IEnumerable`1"/> containing ProteinLoadInfo which details how the ProteinDictionary was changed.
 /// </summary>
 /// <param name="fileName">File name to load into the dictionary.</param>
 /// <param name="serializer">Serializer used to load the file.</param>
 /// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1"/> containing ProteinLoadInfo which details how the ProteinDictionary was changed.</returns>
 public IEnumerable <ProteinLoadInfo> Load(string fileName, IFileSerializer <List <Protein> > serializer)
 {
     return(Load(serializer.Deserialize(fileName)));
 }