/// <summary> /// Constructor of Monitor class /// </summary> /// <param name="context">Specify a context to have different contexts in different domains</param> /// <param name="name">Name of the new Monitor</param> public Monitor(Context.Monitor context, string name) : base(context) { ContextMapper = ctx => ctx ?? _defaultContext; if (!ContextMapper.Invoke(context).ObjectDictionary.TryGetValue(name, out _currentObject)) { lock (ContextMapper.Invoke(context).LockerObject) { if (!ContextMapper.Invoke(context).ObjectDictionary.TryGetValue(name, out _currentObject)) { _currentObject = new object(); ContextMapper.Invoke(context).ObjectDictionary.TryAdd(name, _currentObject); } } } }
/// <summary> /// Specifies the context boundary for the new Monitor /// </summary> /// <param name="value">An instance of Monitor context</param> /// <returns></returns> public MonitorBuilder Context(Context.Monitor value) { this._context = value; return(this); }