private static IChoProfileBackingStore ConstructProfiler(string name) { if (_pbsStore.ContainsKey(name)) { return(_pbsStore[name]); } string xpath = @"//configuration/loggers/logger[contains(@name,'{0}')]".FormatString(name); XmlNode node = null; if (_rootNode != null) { node = _rootNode.SelectSingleNode(xpath); } lock (_pbsStoreLock) { if (_pbsStore.ContainsKey(name)) { return(_pbsStore[name]); } if (node != null) { ChoProfiler profiler = node.ToObject(typeof(ChoProfiler)) as ChoProfiler; if (!profiler.ProfileBackingStoreName.IsNullOrWhiteSpace()) { if (!_pbsStoreDef.ContainsKey(name)) { return(null); } ChoProfileBackingStoreDef pbsStoreDef = _pbsStoreDef[name]; string startActions; string stopActions; IChoProfileBackingStore pbsObject; pbsObject = ConstructProfileBackingStore(pbsStoreDef, out startActions, out stopActions); pbsObject.Start(startActions); if (!_profileBackingStopActionsCache.ContainsKey(name)) { _profileBackingStopActionsCache.Add(name, stopActions); } if (!_pbsStore.ContainsKey(name)) { _pbsStore.Add(name, pbsObject); } return(pbsObject); } } } return(null); }
private static IChoProfileBackingStore ConstructProfileBackingStore(ChoProfileBackingStoreDef profileBackingStoreDef, out string startActions, out string stopActions) { if (profileBackingStoreDef.Name.IsNullOrWhiteSpace()) { throw new ApplicationException("{0}: Node does not contain profile backing store object.".FormatString(profileBackingStoreDef.Name)); } startActions = null; stopActions = null; IChoProfileBackingStore pbsObject = profileBackingStoreDef.Construct(ref startActions, ref stopActions) as IChoProfileBackingStore; if (pbsObject == null) { throw new ApplicationException("{0}: Node does not contain profile backing store object.".FormatString(profileBackingStoreDef.Name)); } return(pbsObject); }