public override bool Contains(string id) { if (String.IsNullOrEmpty(id)) { return(false); } return(_plusTree.ContainsKey(id)); }
private void Initialize(string workingDir, bool createNotFound) { if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } _quickStorage = new MemoryTargetStorage(); if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } if (_isSystem) { _treeFileName = Path.Combine(workingDir, "LinkT2.6.10621.1.dat"); _blockFileName = Path.Combine(workingDir, "LinkB2.6.10621.1.dat"); } else { string tempFile = Path.GetFileNameWithoutExtension( Path.GetTempFileName()); _treeFileName = Path.Combine(workingDir, tempFile + "Tree.dat"); _blockFileName = Path.Combine(workingDir, tempFile + "Block.dat"); } if (File.Exists(_treeFileName) && File.Exists(_blockFileName)) { _isExisted = true; _plusTree = hBplusTree.ReOpen(_treeFileName, _blockFileName); if (_plusTree.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_plusTree["$DataCount$"]); } this.AddQuickTargets(); //if (_count > 0) //{ //} } else { _count = 0; if (createNotFound) { _plusTree = hBplusTree.Initialize(_treeFileName, _blockFileName, 64); } } if (_plusTree != null) { _targetCache = new DatabaseTargetCache(100); } }
private void Initialize(string workingDir, bool createNotFound) { _count = 0; _cachedMsdnUrls = new Dictionary <string, string>(); if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } //string localPart = _locale.ToUpper(); if (_isSystem) { _treeFileName = Path.Combine(workingDir, "MsdnT2.6.10621.1.dat"); _blockFileName = Path.Combine(workingDir, "MsdnB2.6.10621.1.dat"); //_treeFileName = Path.Combine(workingDir, "MsdnT" + localPart + "2.6.10621.1.dat"); //_blockFileName = Path.Combine(workingDir, "MsdnB" + localPart + "2.6.10621.1.dat"); } else { string tempFile = Path.GetFileNameWithoutExtension( Path.GetTempFileName()); _treeFileName = Path.Combine(workingDir, tempFile + "Tree.dat"); _blockFileName = Path.Combine(workingDir, tempFile + "Block.dat"); //_treeFileName = Path.Combine(workingDir, tempFile + localPart + "Tree.dat"); //_blockFileName = Path.Combine(workingDir, tempFile + localPart + "Block.dat"); } if (File.Exists(_treeFileName) && File.Exists(_blockFileName)) { _isExisted = true; _plusTree = hBplusTree.ReOpen(_treeFileName, _blockFileName); if (_plusTree.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_plusTree["$DataCount$"]); } } else { if (createNotFound) { _plusTree = hBplusTree.Initialize(_treeFileName, _blockFileName, 64); } } }
public override Target this[string id] { get { Target target = null; if (_plusTree == null) { return(target); } if (_quickStorage != null) { target = _quickStorage[id]; if (target != null) { return(target); } } if (_targetCache != null) { target = _targetCache[id]; if (target != null) { return(target); } } if (_plusTree.ContainsKey(id)) { target = TargetsReader.Read(_plusTree[id]); if (target != null && _targetCache != null) { _targetCache.Add(target); } } return(target); } }
private string GetCurrentServicesHTML() { List <Service> services = new List <Service>(); string currentkey = _tree.FirstKey(); while (currentkey != null) { if (_tree.ContainsKey(currentkey)) { Service tempService = new Service(); tempService.ParseXMLString(_tree[currentkey]); services.Add(tempService); } currentkey = _tree.NextKey(currentkey); } return(RenderTemplate(services)); }
public override string this[string id] { get { if (String.IsNullOrEmpty(id)) { return(String.Empty); } if (_cachedMsdnUrls.ContainsKey(id)) { return(_cachedMsdnUrls[id]); } if (_plusTree != null && _plusTree.ContainsKey(id)) { string url = _plusTree[id]; _cachedMsdnUrls[id] = url; } return(String.Empty); } }
private static void ProcessReceivedService(string serviceXML) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(serviceXML); XmlNodeList guids = xmlDoc.GetElementsByTagName("GUID"); string serviceGUID = guids[0].InnerText; if (_tree.ContainsKey(serviceGUID)) { string currentService = _tree[serviceGUID]; if (currentService != serviceXML) { _tree[serviceGUID] = serviceXML; _changedServices[serviceGUID] = serviceXML; } } else { _tree[serviceGUID] = serviceXML; _changedServices[serviceGUID] = serviceXML; } _tree.Commit(); }