using System; using System.Threading.Tasks; using EmbedIO.Routing; using EmbedIO.Utilities; using EmbedIO.WebApi; namespace EmbedIO { partial class WebModuleContainerExtensions { /// /// Creates an instance of using the default response serializer /// and adds it to a module container without giving it a name. /// /// The type of the module container. /// The on which this method is called. /// The base route of the module. /// A callback used to configure the newly-created . /// with a added. /// is . /// is . /// /// /// /// public static TContainer WithWebApi(this TContainer @this, string baseRoute, Action configure) where TContainer : class, IWebModuleContainer => WithWebApi(@this, null, baseRoute, configure); /// /// Creates an instance of using the specified response serializer /// and adds it to a module container without giving it a name. /// /// The type of the module container. /// The on which this method is called. /// The base route of the module. /// A used to serialize /// the result of controller methods returning /// or Task<object>. /// A callback used to configure the newly-created . /// with a added. /// is . /// /// is . /// - or - /// is . /// /// /// /// /// public static TContainer WithWebApi( this TContainer @this, string baseRoute, ResponseSerializerCallback serializer, Action configure) where TContainer : class, IWebModuleContainer => WithWebApi(@this, null, baseRoute, serializer, configure); /// /// Creates an instance of using the default response serializer /// and adds it 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 base route of the module. /// A callback used to configure the newly-created . /// with a added. /// is . /// is . /// /// /// /// public static TContainer WithWebApi( this TContainer @this, string? name, string baseRoute, Action configure) where TContainer : class, IWebModuleContainer { configure = Validate.NotNull(nameof(configure), configure); var module = new WebApiModule(baseRoute); return WithModule(@this, name, module, configure); } /// /// Creates an instance of , using the specified response serializer /// and adds it 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 base route of the module. /// A used to serialize /// the result of controller methods returning /// or Task<object>. /// A callback used to configure the newly-created . /// with a added. /// is . /// /// is . /// - or - /// is . /// /// /// /// /// public static TContainer WithWebApi( this TContainer @this, string? name, string baseRoute, ResponseSerializerCallback serializer, Action configure) where TContainer : class, IWebModuleContainer { configure = Validate.NotNull(nameof(configure), configure); var module = new WebApiModule(baseRoute, serializer); return WithModule(@this, name, module, configure); } } }