public void RegisterCurrent(ContainerContext context) { lock (contexts) { var stack = getContextHistory(Thread.CurrentThread); stack.Push(context); } }
public void UnregisterCurrent(ContainerContext context) { lock (contexts) { var stack = getContextHistory(Thread.CurrentThread); var lastContext = stack.Pop(); if (lastContext != context) { throw new InvalidOperationException( "Something goes wrong. The current context is not the one initialized at last !?"); } } }