public override void Initialize(string workingDir, bool createNotFound) { if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } if (_isSystem) { _dataSourceDir = workingDir; } else { string tempFile = Path.GetFileNameWithoutExtension( Path.GetTempFileName()); _dataSourceDir = Path.Combine(workingDir, tempFile); } _isExisted = PersistentDictionaryFile.Exists(_dataSourceDir); if (_isExisted) { this.CheckDataIndex(_dataSourceDir); _targetStorage = new PersistentDictionary <string, string>(_dataSourceDir); if (_targetStorage.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_targetStorage["$DataCount$"]); if (_count <= 0) { _count = _targetStorage.Count; } } else { _count = _targetStorage.Count; } } else { _count = 0; if (createNotFound) { _targetStorage = new PersistentDictionary <string, string>(_dataSourceDir); } } if (_targetStorage != null) { _targetCache = new DatabaseTargetCache(100); } _isInitialized = true; }
public override void Initialize(string workingDir, bool createNotFound) { if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } _quickStorage = new MemoryTargetStorage(); if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } // For non-system, we will delete the directory after use... _targetDataDir = workingDir; _isExisted = PersistentDictionaryFile.Exists(_targetDataDir); if (_isExisted) { this.CheckDataIndex(_targetDataDir); _targetStorage = new PersistentDictionary <string, string>(_targetDataDir); if (_targetStorage.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_targetStorage["$DataCount$"]); if (_count <= 0) { _count = _targetStorage.Count; } } else { _count = _targetStorage.Count; } if (_useQuickTargets) { this.AddQuickTargets(); } } else { _count = 0; if (createNotFound) { _targetStorage = new PersistentDictionary <string, string>(_targetDataDir); } } if (_targetStorage != null) { _targetCache = new DatabaseTargetCache(100); } _isInitialized = true; }