/// <summary> /// Register named context /// </summary> /// <param name="name"></param> /// <returns></returns> public IContext CreateContext(string name) { this._contextsLock.EnterWriteLock(); try { IContext prevContext; if (this._contexts.Lookup(name, out prevContext)) { throw new ArgumentException(); } using (Context context = new Context(name)) { context.Subscribe(this); this._contexts.Register(name, context); return context; } } finally { this._contextsLock.ExitWriteLock(); } }
/// <summary> /// Register named context /// </summary> /// <param name="name"></param> /// <returns></returns> public IContext CreateSubContext(string name) { IContext prevContext; if (this._subcontexts.Lookup(name, out prevContext)) { throw new ArgumentException(); } using (Context context = new Context(name)) { context.Subscribe(this); this._subcontexts.Register(name, context); return context; } }