Ejemplo n.º 1
0
 /// <summary>
 /// Enables Debug logging if a debugger is attached.
 /// </summary>
 public static void EnableDebugger()
 {
     __isDebugEnabled = true;
     if ((Debugger.IsAttached) && (__container != null))
     {
         __debugger = new IoCDebugger(__container);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Resets the container instance to null to support testing with multiple configurations in the same unit test batch.
 /// </summary>
 public static void ResetContainer()
 {
     if (__debugger != null)
     {
         __debugger.Close();
     }
     __debugger  = null;
     __container = null;
 }
Ejemplo n.º 3
0
        internal static bool TryGetOrCreateContainer(Func <CompositionContainer> createContainer, out CompositionContainer globalContainer)
        {
            bool alreadyCreated = true;

            if (__container == null)
            {
                CompositionContainer container = createContainer();
                using (__lock.ForWrite())
                {
                    if (__container == null)
                    {
                        Thread.MemoryBarrier();
                        __container    = container;
                        alreadyCreated = false;
                        if ((Debugger.IsAttached) && (__isDebugEnabled))
                        {
                            __debugger = new IoCDebugger(__container);
                        }
                    }
                }
            }
            globalContainer = __container;
            return(alreadyCreated);
        }