@@ -55,6 +55,23 @@ public static IDisposable CreateDisposableDirectory(this IFileSystem fileSystem,
5555 return fileSystem . CreateDisposableDirectory ( path , dir => new DisposableDirectory ( dir ) , out directoryInfo ) ;
5656 }
5757
58+ /// <inheritdoc cref="CreateDisposableDirectory(IFileSystem, out IDirectoryInfo)"/>
59+ /// <summary>
60+ /// Creates a new <see cref="IDirectoryInfo"/> using a random name from the temp path and returns an
61+ /// <see cref="IDisposable"/> created by <paramref name="disposableFactory"/>, that should delete the directory when disposed.
62+ /// </summary>
63+ /// <param name="disposableFactory">
64+ /// A <see cref="Func{T, TResult}"/> that acts as a factory method. Given the <see cref="IDirectoryInfo"/>, create the
65+ /// <see cref="IDisposable"/> that will manage the its lifetime.
66+ /// </param>
67+ public static T CreateDisposableDirectory < T > (
68+ this IFileSystem fileSystem ,
69+ Func < IDirectoryInfo , T > disposableFactory ,
70+ out IDirectoryInfo directoryInfo ) where T : IDisposable
71+ {
72+ return fileSystem . CreateDisposableDirectory ( fileSystem . Path . GetRandomTempPath ( ) , disposableFactory , out directoryInfo ) ;
73+ }
74+
5875 /// <inheritdoc cref="CreateDisposableDirectory(IFileSystem, string, out IDirectoryInfo)"/>
5976 /// <summary>
6077 /// Creates a new <see cref="IDirectoryInfo"/> using a path provided by <paramref name="path"/>, and returns an
@@ -116,6 +133,23 @@ public static IDisposable CreateDisposableFile(this IFileSystem fileSystem, stri
116133 return fileSystem . CreateDisposableFile ( path , file => new DisposableFile ( file ) , out fileInfo ) ;
117134 }
118135
136+ /// <inheritdoc cref="CreateDisposableFile(IFileSystem, out IFileInfo)"/>
137+ /// <summary>
138+ /// Creates a new <see cref="IFileInfo"/> using a random name from the temp path and returns an
139+ /// <see cref="IDisposable"/> created by <paramref name="disposableFactory"/>, that should delete the file when disposed.
140+ /// </summary>
141+ /// <param name="disposableFactory">
142+ /// A <see cref="Func{T, TResult}"/> that acts as a factory method. Given the <see cref="IFileInfo"/>, create the
143+ /// <see cref="IDisposable"/> that will manage the its lifetime.
144+ /// </param>
145+ public static T CreateDisposableFile < T > (
146+ this IFileSystem fileSystem ,
147+ Func < IFileInfo , T > disposableFactory ,
148+ out IFileInfo fileInfo ) where T : IDisposable
149+ {
150+ return fileSystem . CreateDisposableFile ( fileSystem . Path . GetRandomTempPath ( ) , disposableFactory , out fileInfo ) ;
151+ }
152+
119153 /// <inheritdoc cref="CreateDisposableFile(IFileSystem, string, out IFileInfo)"/>
120154 /// <summary>
121155 /// Creates a new <see cref="IFileInfo"/> using a path provided by <paramref name="path"/>, and returns an
0 commit comments