using System; using EmbedIO.Utilities; namespace EmbedIO { /// /// Contains extension methods for types implementing . /// public static partial class WebModuleContainerExtensions { /// /// Adds the specified to a module container, without giving it a name. /// /// The type of the module container. /// The on which this method is called. /// The module. /// with added. /// is . /// /// public static TContainer WithModule(this TContainer @this, IWebModule module) where TContainer : class, IWebModuleContainer => WithModule(@this, null, module); /// /// Adds the specified to a module container, /// giving it the specified if not . /// /// The type of the module container. /// The on which this method is called. /// The name. /// The module. /// with added. /// is . /// /// public static TContainer WithModule(this TContainer @this, string? name, IWebModule module) where TContainer : class, IWebModuleContainer { @this.Modules.Add(name, module); return @this; } /// /// Adds the specified to a module container, without giving it a name. /// /// The type of the module container. /// The type of the . /// The on which this method is called. /// The module. /// A callback used to configure the . /// with added. /// is . /// /// public static TContainer WithModule(this TContainer @this, TWebModule module, Action? configure) where TContainer : class, IWebModuleContainer where TWebModule : IWebModule => WithModule(@this, null, module, configure); /// /// Adds the specified to a module container, /// giving it the specified if not . /// /// The type of the module container. /// The type of the . /// The on which this method is called. /// The name. /// The module. /// A callback used to configure the . /// with added. /// is . /// /// public static TContainer WithModule(this TContainer @this, string? name, TWebModule module, Action? configure) where TContainer : class, IWebModuleContainer where TWebModule : IWebModule { configure?.Invoke(module); @this.Modules.Add(name, module); return @this; } } }