/// <summary>
 /// Initialize <see cref="GraphSession"/>.
 /// </summary>
 /// <param name="instanceCreator">A func to create an instance.</param>
 /// <param name="overwrite">If true, overwrite the current instance. Otherwise do not initialize.</param>
 public static void Initialize(Func <GraphSession> instanceCreator, bool overwrite)
 {
     try
     {
         sessionLock.EnterWriteLock();
         try
         {
             if (overwrite || !_initialized)
             {
                 _instance    = instanceCreator();
                 _initialized = true;
             }
         }
         finally
         {
             sessionLock.ExitWriteLock();
         }
     }
     catch (LockRecursionException lockException)
     {
         throw new InvalidOperationException(ErrorConstants.Codes.SessionLockWriteRecursion, lockException);
     }
     catch (ObjectDisposedException disposedException)
     {
         throw new InvalidOperationException(ErrorConstants.Codes.SessionLockWriteDisposed, disposedException);
     }
 }
 /// <summary>
 /// Resets the current instance of <see cref="GraphSession"/> to initial state.
 /// </summary>
 internal static void Reset()
 {
     try
     {
         sessionLock.EnterWriteLock();
         try
         {
             _instance    = null;
             _initialized = false;
         }
         finally
         {
             sessionLock.ExitWriteLock();
         }
     }
     catch (LockRecursionException lockException)
     {
         throw new InvalidOperationException(ErrorConstants.Codes.SessionLockWriteRecursion, lockException);
     }
     catch (ObjectDisposedException disposedException)
     {
         throw new InvalidOperationException(ErrorConstants.Codes.SessionLockWriteDisposed, disposedException);
     }
 }