public IRuleSetFile GetOrCreateRuleSet(string ruleSetFileFullPath)
        {
            if (!_ruleSetFileMap.TryGetValue(ruleSetFileFullPath, out var ruleSetFile))
            {
                ruleSetFile = new RuleSetFile(ruleSetFileFullPath, _fileChangeService, this);
                _ruleSetFileMap.Add(ruleSetFileFullPath, ruleSetFile);
            }

            return ruleSetFile;
        }
示例#2
0
        public IRuleSetFile GetOrCreateRuleSet(string ruleSetFileFullPath)
        {
            if (!_ruleSetFileMap.TryGetValue(ruleSetFileFullPath, out var ruleSetFile))
            {
                ruleSetFile = new RuleSetFile(ruleSetFileFullPath, _fileChangeService, this);
                _ruleSetFileMap.Add(ruleSetFileFullPath, ruleSetFile);
            }

            return(ruleSetFile);
        }
 private void StopTrackingRuleSetFile(RuleSetFile ruleSetFile)
 {
     // We can arrive here in one of two situations:
     //
     // 1. The underlying RuleSetFile was disposed by all consumers, and we can try cleaning up our weak reference. This is purely an optimization
     //    to avoid the key/value pair being unnecessarily held.
     // 2. The RuleSetFile was modified, and we want to get rid of our cache now. Anybody still holding onto the values will dispose at their leaisure,
     //    but it won't really matter anyways since the Dispose() that cleans up file trackers is already done.
     //
     // In either case, we can just be lazy and remove the key/value pair. It's possible in the mean time that the rule set had already been removed
     // (perhaps by a file change), and we're removing a live instance. This is fine, as this doesn't affect correctness: we consider this to be a cache
     // and if two callers got different copies that's fine. We *could* fetch the item out of the dictionary, check if the item is strong and then compare,
     // but that seems overkill.
     _ruleSetFileMap.Evict(ruleSetFile.FilePath);
 }
 private void StopTrackingRuleSetFile(RuleSetFile ruleSetFile)
 {
     _ruleSetFileMap.Remove(ruleSetFile.FilePath);
 }
示例#5
0
 private void StopTrackingRuleSetFile(RuleSetFile ruleSetFile)
 {
     _ruleSetFileMap.Remove(ruleSetFile.FilePath);
 }