/// <summary>
 /// Closes the reference handling null.
 /// </summary>
 /// <param name="reference">The reference to close.</param>
 public static void CloseSafely(CloseableReference <T> reference)
 {
     if (reference != null)
     {
         reference.Dispose();
     }
 }
 /// <summary>
 /// Returns the cloned reference if valid, null otherwise.
 /// </summary>
 /// <param name="reference">The reference to clone.</param>
 public static CloseableReference <T> CloneOrNull(CloseableReference <T> reference)
 {
     return((reference != null) ? reference.CloneOrNull() : null);
 }
 /// <summary>
 /// Checks if the closable-reference is valid i.e. is not null,
 /// and is not closed.
 /// </summary>
 /// <returns>true if the closeable reference is valid.</returns>
 public static bool IsValid(CloseableReference <T> reference)
 {
     return(reference != null && reference.Valid);
 }