Unosquare
    Show / Hide Table of Contents

    Class SessionProxy

    Provides the same interface as a session object, plus a basic interface to a session manager.

    Inheritance
    Object
    SessionProxy
    Implements
    ISessionProxy
    ISession
    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 sealed class SessionProxy : ISessionProxy, ISession
    Remarks

    A session proxy can be used just as if it were a session object. A session is automatically created wherever its data are accessed.

    Fields

    None

    A "dummy" ISessionProxy interface that will always behave as if no session manager has been defined.

    Useful to initialize non-nullable fields or properties of type ISessionProxy.

    Declaration
    public static readonly ISessionProxy None
    Field Value
    Type Description
    ISessionProxy

    Properties

    Count

    Gets the number of key/value pairs contained in a session.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    The number of key/value pairs contained in the object that implements ISession.

    Duration

    Gets the time interval, starting from LastActivity, after which the session expires.

    Declaration
    public TimeSpan Duration { get; }
    Property Value
    Type Description
    TimeSpan

    The expiration time.

    Exists

    Gets a value indicating whether a session exists for the current context.

    Declaration
    public bool Exists { get; }
    Property Value
    Type Description
    Boolean

    true if a session exists; otherwise, false.

    Id

    A unique identifier for the session.

    Declaration
    public string Id { get; }
    Property Value
    Type Description
    String

    The unique identifier for this session.

    See Also
    IdComparison
    IdComparer

    IsEmpty

    Gets a value that indicates whether a session is empty.

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    Boolean

    true if the object that implements ISession is empty, i.e. contains no key / value pairs; otherwise, false.

    Item[String]

    Gets or sets the value associated with the specified key.

    Note that a session does not store null values; therefore, setting this property to null has the same effect as removing key from the dictionary.

    Declaration
    public object this[string key] { get; set; }
    Parameters
    Type Name Description
    String key

    The key of the value to get or set.

    Property Value
    Type Description
    Object

    The value associated with the specified key, if key is found in the dictionary; otherwise, null.

    LastActivity

    Gets the UTC date and time of last activity on the session.

    Declaration
    public DateTime LastActivity { get; }
    Property Value
    Type Description
    DateTime

    The UTC date and time of last activity on the session.

    Methods

    Clear()

    Removes all keys and values from a session.

    Declaration
    public void Clear()

    ContainsKey(String)

    Determines whether a session contains an element with the specified key.

    Declaration
    public bool ContainsKey(string key)
    Parameters
    Type Name Description
    String key

    The key to locate in the object that implements ISession.

    Returns
    Type Description
    Boolean

    true if the object that implements ISession contains an element with the key; otherwise, false .

    Delete()

    Deletes the session for the current context.

    Declaration
    public void Delete()

    Regenerate()

    Deletes the session for the current context and creates a new one.

    Declaration
    public void Regenerate()

    TakeSnapshot()

    Takes and returns a snapshot of the contents of a session at the time of calling.

    Declaration
    public IReadOnlyList<KeyValuePair<string, object>> TakeSnapshot()
    Returns
    Type Description
    IReadOnlyList<KeyValuePair<String, Object>>

    An IReadOnlyList<KeyValuePair<string,object>> interface containing an immutable copy of the session data as it was at the time of calling this method.

    Remarks

    The objects contained in the session data are copied by reference, not cloned; therefore you should be aware that their state may change even after the snapshot is taken.

    TryGetValue(String, out Object)

    Gets the value associated with the specified key.

    Declaration
    public bool TryGetValue(string key, out object value)
    Parameters
    Type Name Description
    String key

    The key whose value to get.

    Object value

    When this method returns, the value associated with the specified key, if the key is found; otherwise, null. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the object that implements ISession contains an element with the specified key; otherwise, false.

    TryRemove(String, out Object)

    Attempts to remove and return the value that has the specified key from a session.

    Declaration
    public bool TryRemove(string key, out object value)
    Parameters
    Type Name Description
    String key

    The key of the element to remove and return.

    Object value

    When this method returns, the value removed from the object that implements ISession, if the key is found; otherwise, null. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the value was removed successfully; otherwise, false.

    Implements

    ISessionProxy
    ISession

    See Also

    ISessionProxy

    Comments

    Back to top Copyright © 2017-2019 Unosquare