Unosquare
    Show / Hide Table of Contents

    Class ModuleGroup

    Groups modules under a common base URL path.

    The BaseRoute property of modules contained in a ModuleGroup is relative to the ModuleGroup's BaseRoute property. For example, given the following code:

    new ModuleGroup("/download")
        .WithStaticFilesAt("/docs", "/var/my/documents");

    files contained in the /var/my/documents folder will be available to clients under the /download/docs/ URL.

    Inheritance
    Object
    WebModuleBase
    ModuleGroup
    Implements
    IWebModuleImpl
    IWebModule
    IDisposable
    IWebModuleContainer
    IMimeTypeCustomizer
    IMimeTypeProvider
    Inherited Members
    WebModuleBase.Container
    WebModuleBase.IWebModuleImpl.SetContainer(IWebModuleContainer)
    WebModuleBase.BaseRoute
    WebModuleBase.OnUnhandledException
    WebModuleBase.OnHttpException
    WebModuleBase.LogSource
    WebModuleBase.Start(CancellationToken)
    WebModuleBase.MatchUrlPath(String)
    WebModuleBase.HandleRequestAsync(IHttpContext)
    WebModuleBase.SetContainer(IWebModuleContainer)
    Namespace: EmbedIO
    Syntax
    public class ModuleGroup : WebModuleBase, IWebModuleImpl, IWebModule, IDisposable, IWebModuleContainer, IMimeTypeCustomizer, IMimeTypeProvider

    Constructors

    ModuleGroup(String, Boolean)

    Initializes a new instance of the ModuleGroup class.

    Declaration
    public ModuleGroup(string baseRoute, bool isFinalHandler)
    Parameters
    Type Name Description
    String baseRoute

    The base route served by this module.

    Boolean isFinalHandler

    The value to set the IsFinalHandler property to. See the help for the property for more information.

    See Also
    BaseRoute
    IsFinalHandler

    Properties

    IsFinalHandler

    Gets a value indicating whether processing of a request should stop after a module has handled it.

    Declaration
    public override sealed bool IsFinalHandler { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    WebModuleBase.IsFinalHandler
    Remarks

    If this property is true, a HTTP context's SetHandled() method will be automatically called immediately after after the returned by HandleRequestAsync(IHttpContext) is completed. This will prevent the context from being passed further along to other modules.

    See Also
    IsHandled
    SetHandled()

    Modules

    Gets the modules.

    Declaration
    public IComponentCollection<IWebModule> Modules { get; }
    Property Value
    Type Description
    IComponentCollection<IWebModule>

    The modules.

    SharedItems

    Gets a dictionary of data shared among the modules in a container.

    This API mainly supports the EmbedIO infrastructure; it is not intended to be used directly from your code, unless to address specific needs in module development.

    Declaration
    public ConcurrentDictionary<object, object> SharedItems { get; }
    Property Value
    Type Description
    ConcurrentDictionary<Object, Object>

    Methods

    AddCustomMimeType(String, String)

    Adds a custom association between a file extension and a MIME type.

    Declaration
    public void AddCustomMimeType(string extension, string mimeType)
    Parameters
    Type Name Description
    String extension

    The file extension to associate to mimeType.

    String mimeType

    The MIME type to associate to extension.

    Dispose()

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Releases unmanaged and - optionally - managed resources.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Finalize()

    Finalizes an instance of the ModuleGroup class.

    Declaration
    protected void Finalize()

    GetMimeType(String)

    Gets the MIME type associated to a file extension.

    Declaration
    public string GetMimeType(string extension)
    Parameters
    Type Name Description
    String extension

    The file extension for which a corresponding MIME type is wanted.

    Returns
    Type Description
    String

    The MIME type corresponding to extension, if one is found; otherwise, null.

    OnBeforeLockConfiguration()

    Declaration
    protected override void OnBeforeLockConfiguration()

    OnRequestAsync(IHttpContext)

    Called to handle a request from a client.

    Declaration
    protected override Task OnRequestAsync(IHttpContext context)
    Parameters
    Type Name Description
    IHttpContext context

    The context of the request being handled.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    Overrides
    WebModuleBase.OnRequestAsync(IHttpContext)

    OnStart(CancellationToken)

    Called when a module is started, immediately before locking the module's configuration.

    Declaration
    protected override void OnStart(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A used to stop the web server.

    Overrides
    WebModuleBase.OnStart(CancellationToken)

    PreferCompression(String, Boolean)

    Indicates whether to prefer compression when negotiating content encoding for a response with the specified content type, or whose content type is in the specified media range.

    Declaration
    public void PreferCompression(string mimeType, bool preferCompression)
    Parameters
    Type Name Description
    String mimeType

    The MIME type or media range.

    Boolean preferCompression

    true to prefer compression; otherwise, false.

    TryDetermineCompression(String, out Boolean)

    Attempts to determine whether compression should be preferred when negotiating content encoding for a response with the specified content type.

    Declaration
    public bool TryDetermineCompression(string mimeType, out bool preferCompression)
    Parameters
    Type Name Description
    String mimeType

    The MIME type to check.

    Boolean preferCompression

    When this method returns true, a value indicating whether compression should be preferred. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if a value is found for mimeType; otherwise, false.

    Implements

    IWebModuleImpl
    IWebModule
    IDisposable
    IWebModuleContainer
    IMimeTypeCustomizer
    IMimeTypeProvider

    See Also

    WebModuleBase
    IWebModuleContainer

    Comments

    Back to top Copyright © 2017-2019 Unosquare