Unosquare
    Show / Hide Table of Contents

    Class SessionExtensions

    Provides extension methods for types implementing ISession.

    Inheritance
    Object
    SessionExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: EmbedIO.Sessions
    Syntax
    public static class SessionExtensions

    Methods

    GetOrDefault<T>(ISession, String)

    Gets the value associated with the specified key.

    Declaration
    public static T GetOrDefault<T>(this ISession this, string key)
    Parameters
    Type Name Description
    ISession this

    The ISession on which this method is called.

    String key

    The key whose value to get from the session.

    Returns
    Type Description
    T

    The value associated with the specified key, if the key is found and the associated value is of type T; otherwise, the default value for T.

    Type Parameters
    Name Description
    T

    The desired type of the value.

    GetOrDefault<T>(ISession, String, T)

    Gets the value associated with the specified key.

    Declaration
    public static T GetOrDefault<T>(this ISession this, string key, T defaultValue)
    Parameters
    Type Name Description
    ISession this

    The ISession on which this method is called.

    String key

    The key whose value to get from the session.

    T defaultValue

    The default value to return if the key is not found or its associated value is not of type T.

    Returns
    Type Description
    T

    The value associated with the specified key, if the key is found and the associated value is of type T; otherwise, defaultValue.

    Type Parameters
    Name Description
    T

    The desired type of the value.

    TryGet<T>(ISession, String, out T)

    Gets the value associated with the specified key.

    Declaration
    public static bool TryGet<T>(this ISession this, string key, out T value)
    Parameters
    Type Name Description
    ISession this

    The ISession on which this method is called.

    String key

    The key whose value to get from the session.

    T value

    When this method returns, the value associated with the specified key, if the key is found and the associated value is of type T; otherwise, the default value for T.

    This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the key is found and the associated value is of type T; otherwise, false.

    Type Parameters
    Name Description
    T

    The desired type of the value.

    Comments

    Back to top Copyright © 2017-2019 Unosquare