src/packages/EmbedIO/WebModuleContainerExtensions-Files.cs
/// <summary>
/// Creates an instance of <see cref="FileSystemProvider"/>, uses it to initialize
/// a <seealso cref="FileModule"/>, and adds the latter to a module container,
/// giving it the specified <paramref name="name"/> if not <see langword="null"/>.
/// </summary>
/// <remarks>
/// OSX doesn't support <see cref="FileSystemWatcher" />, the parameter <paramref name="isImmutable" /> will be always <see langword="true"/>.
/// </remarks>
/// <typeparam name="TContainer">The type of the module container.</typeparam>
/// <param name="this">The <typeparamref name="TContainer"/> on which this method is called.</param>
/// <param name="name">The name.</param>
/// <param name="baseRoute">The base route of the module.</param>
/// <param name="fileSystemPath">The path of the directory to serve.</param>
/// <param name="isImmutable"><see langword="true"/> if files and directories in
/// <paramref name="fileSystemPath"/> are not expected to change during a web server's
/// lifetime; <see langword="false"/> otherwise.</param>
/// <param name="configure">A callback used to configure the module.</param>
/// <returns><paramref name="this"/> with a <see cref="FileModule"/> added.</returns>
/// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException"><paramref name="fileSystemPath"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="fileSystemPath"/> is not a valid local path.</exception>
/// <seealso cref="FileModule"/>
/// <seealso cref="FileSystemProvider"/>
/// <seealso cref="IWebModuleContainer.Modules"/>
/// <seealso cref="IComponentCollection{T}.Add"/>
Creates an instance of , uses it to initialize
a , and adds the latter to a module container,
giving it the specified  if not .
Creates an instance of uses it to initialize a and adds the latter to a module container giving it the specified if not .
public static TContainer WithStaticFolder<TContainer>(
            this TContainer @this,
            string? name,
            string baseRoute,
            string fileSystemPath,
            bool isImmutable,
            Action<FileModule>? configure = null)
            where TContainer : class, IWebModuleContainer
        {
#pragma warning disable CA2000 
            var provider = new FileSystemProvider(fileSystemPath, isImmutable);
#pragma warning restore CA2000
            try
            {
                var module = new FileModule(baseRoute, provider);
                return WithModule(@this, name, module, configure);
            }
            catch
            {
                provider.Dispose();
                throw;
            }
        }
public static TContainer WithStaticFolder < TContainer > ( this TContainer @this , string ? name , string baseRoute , string fileSystemPath , bool isImmutable , Action < FileModule > ? configure = null ) where TContainer : class , IWebModuleContainer { pragma warning disable CA2000 var provider = new FileSystemProvider ( fileSystemPath , isImmutable ) ; pragma warning restore CA2000 try { var module = new FileModule ( baseRoute , provider ) ; return WithModule ( @this , name , module , configure ) ; } catch { provider . Dispose ( ) ; throw ; } }
Creates an instance of , uses it to initialize
a , and adds the latter to a module container,
giving it the specified  if not .
Creates an instance of uses it to initialize a and adds the latter to a module container giving it the specified if not .
// Call Dispose on disposable - Ownership of provider is transferred to module
with a  added.
with a added .
None
None
None
TContainer
this
<not_specific>
name
string?
None
baseRoute
string
The base route of the module.
The base route of the module .
fileSystemPath
string
The path of the directory to serve.
The path of the directory to serve .
isImmutable
bool
if files and directories in
are not expected to change during a web server's
lifetime;  otherwise.
if files and directories in are not expected to change during a web server ' s lifetime ; otherwise .
configure
Action<FileModule>?
A callback used to configure the module.
A callback used to configure the module .
this
<not_specific>
The  on which this method is called.
The on which this method is called .
remarks
OSX doesn't support , the parameter  will be always .
OSX doesn ' t support the parameter will be always .
typeparam
The type of the module container.
The type of the module container .
seealso
None
seealso
None
seealso
None
seealso
None