Search Results for

    Show / Hide Table of Contents

    Class HttpConnector

    This class implements the IHttpConnectable interface and uses the standard microsoft http client.

    Inheritance
    System.Object
    HttpConnector
    Implements
    IHttpConnectable
    IConnectable
    IDisposable
    Namespace: TeleScope.Connectors.Http
    Assembly: TeleScope.Connectors.Http.dll
    Syntax
    public class HttpConnector : object, IHttpConnectable, IConnectable, IDisposable

    Constructors

    | Improve this Doc View Source

    HttpConnector()

    The default empty constructor binds a logger for internal usage.

    Declaration
    public HttpConnector()
    | Improve this Doc View Source

    HttpConnector(HttpClient)

    Saves the property and calls the empty default constructor.

    Declaration
    public HttpConnector(HttpClient client)
    Parameters
    Type Name Description
    HttpClient client

    The http client to perform requests.

    | Improve this Doc View Source

    HttpConnector(HttpClient, HttpEndpoint)

    Saves the properties and calls the empty default constructor.

    Declaration
    public HttpConnector(HttpClient client, HttpEndpoint endpoint)
    Parameters
    Type Name Description
    HttpClient client

    The http client to perform requests.

    HttpEndpoint endpoint

    The endpoint configuration executed by the client.

    Properties

    | Improve this Doc View Source

    IsConnected

    Gets the state, if the connection is established or not.

    Declaration
    public bool IsConnected { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    AddCancelToken(CancellationToken)

    Adds the to the internal connector in order to enable an cancellation of the pending http requests.

    Declaration
    public IHttpConnectable AddCancelToken(CancellationToken token)
    Parameters
    Type Name Description
    CancellationToken token

    The token that is provided by the host system.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    AddHeader(String, String)

    Adds an http header to the next request as simple pair of name and value.

    Declaration
    public IHttpConnectable AddHeader(string name, string value)
    Parameters
    Type Name Description
    System.String name

    The name of the header information.

    System.String value

    The value of the header information.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    CallAsync()

    Performs the http request asynchronously that is defined by the http endpoint and optional parameters.

    Declaration
    public Task<string> CallAsync()
    Returns
    Type Description
    Task<System.String>

    The executing task whereby the result is the raw string of the response body.

    | Improve this Doc View Source

    CallAsync<T>(Func<String, T>)

    Performs the http request asynchronously that is defined by the http endpoint and optional parameters.

    Declaration
    public Task<T> CallAsync<T>(Func<string, T> convert)
    Parameters
    Type Name Description
    Func<System.String, T> convert

    The function converts the response body into the generic type T.

    Returns
    Type Description
    Task<T>

    The executing task whereby the result of the task is of type T.

    Type Parameters
    Name Description
    T

    The generic returned type T.

    | Improve this Doc View Source

    Connect()

    Tests the connection with the internal http client and endpoint.

    Declaration
    public IHttpConnectable Connect()
    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    Connect(HttpClient, HttpEndpoint)

    Tests the connection with the given http client and endpoint and stores both parameters internally.

    Declaration
    public IHttpConnectable Connect(HttpClient client, HttpEndpoint endpoint)
    Parameters
    Type Name Description
    HttpClient client

    The http client that will be used by the connector.

    HttpEndpoint endpoint

    The endpoint configuration.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    Connect(HttpEndpoint)

    Tests the connection to the given endpoint and stores the parameter internally. The http client must be ready-to-use before calling this method.

    Declaration
    public IHttpConnectable Connect(HttpEndpoint endpoint)
    Parameters
    Type Name Description
    HttpEndpoint endpoint

    The endpoint configuration.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    DisableCaching()

    Disables the caching mechanism and frees the allocated memory.

    Declaration
    public IHttpConnectable DisableCaching()
    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    Disconnect()

    Disposes the http client and deletes the internal fields.

    Declaration
    public IConnectable Disconnect()
    Returns
    Type Description
    IConnectable

    The calling instance.

    | Improve this Doc View Source

    Dispose()

    Disposes all managed resources and supresses the to call the finalizer.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    Implements the Dispose function.

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

    If True, the internal managed resouces will be disposed.

    | Improve this Doc View Source

    Finalize()

    The finalizer disposes the unmanged resources.

    Declaration
    protected void Finalize()
    | Improve this Doc View Source

    SetContent(String)

    Sets the payload of the http request which must be represented as json compliant string.

    Declaration
    public IHttpConnectable SetContent(string jsonContent)
    Parameters
    Type Name Description
    System.String jsonContent

    The payload for the next http request.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    SetContent(String, Encoding, String)

    Sets the payload of the next http request.

    Declaration
    public IHttpConnectable SetContent(string content, Encoding encoding, string mediatype)
    Parameters
    Type Name Description
    System.String content

    The payload as string.

    Encoding encoding

    The encoding to format the string before serialization.

    System.String mediatype

    The media type of the payload.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    SetRequest(String, HttpMethod)

    Updates the request part of the http endpoint configuration.

    Declaration
    public IHttpConnectable SetRequest(string request, HttpMethod method)
    Parameters
    Type Name Description
    System.String request

    The request part of the url.

    HttpMethod method

    Optional: The method type of the call.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    SetRequest(HttpEndpoint)

    Updates the complete http endpoint configuration.

    Declaration
    public IHttpConnectable SetRequest(HttpEndpoint newEndpoint)
    Parameters
    Type Name Description
    HttpEndpoint newEndpoint

    The new endpoint configuration.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    WithCaching(UInt32, UInt32)

    Adds a caching mechanism for all upcoming http requests.

    Declaration
    public IHttpConnectable WithCaching(uint refreshSeconds = null, uint expirationSeconds = null)
    Parameters
    Type Name Description
    System.UInt32 refreshSeconds

    The timeout in seconds where the cache will return (refresh) the cached data.

    System.UInt32 expirationSeconds

    The timeout in seconds where the cache will expire the cached data.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    | Improve this Doc View Source

    WithCaching(TimeSpan, TimeSpan)

    Adds a caching mechanism for all upcoming http requests.

    Declaration
    public IHttpConnectable WithCaching(TimeSpan refreshExpiration, TimeSpan resetExpiration)
    Parameters
    Type Name Description
    TimeSpan refreshExpiration

    The timeout where the cache will return (refresh) the cached data.

    TimeSpan resetExpiration

    The timeout where the cache will expire the cached data.

    Returns
    Type Description
    IHttpConnectable

    The calling instance.

    Events

    | Improve this Doc View Source

    Completed

    The event is invoked when a type specific method or action has finished successfully.

    Declaration
    public event ConnectorCompletedEventHandler Completed
    Event Type
    Type Description
    ConnectorCompletedEventHandler
    | Improve this Doc View Source

    Connected

    The event is invoked when the Connect method has finished successfully.

    Declaration
    public event ConnectorEventHandler Connected
    Event Type
    Type Description
    ConnectorEventHandler
    | Improve this Doc View Source

    Disconnected

    The event is invoked when the Disconnect method has finished successfully.

    Declaration
    public event ConnectorEventHandler Disconnected
    Event Type
    Type Description
    ConnectorEventHandler
    | Improve this Doc View Source

    Failed

    The event is invoked when any method or action has finished with a failure.

    Declaration
    public event ConnectorFailedEventHandler Failed
    Event Type
    Type Description
    ConnectorFailedEventHandler

    Implements

    IHttpConnectable
    IConnectable
    IDisposable
    • GITHUB
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top
    Copyright 2020-2022 TeleScope-dotnet. Generated by DocFX.
    ☀
    ☾