using System; using System.Collections.Generic; namespace EmbedIO.Sessions { /// /// Represents a session. /// public interface ISession { /// /// A unique identifier for the session. /// /// The unique identifier for this session. /// /// string Id { get; } /// /// Gets the time interval, starting from , /// after which the session expires. /// /// The expiration time. TimeSpan Duration { get; } /// /// Gets the UTC date and time of last activity on the session. /// /// /// The UTC date and time of last activity on the session. /// DateTime LastActivity { get; } /// /// Gets the number of key/value pairs contained in a session. /// /// /// The number of key/value pairs contained in the object that implements . /// int Count { get; } /// /// Gets a value that indicates whether a session is empty. /// /// /// if the object that implements is empty, /// i.e. contains no key / value pairs; otherwise, . /// bool IsEmpty { get; } /// /// Gets or sets the value associated with the specified key. /// Note that a session does not store null values; therefore, setting this property to /// has the same effect as removing from the dictionary. /// /// /// The value associated with the specified key, if /// is found in the dictionary; otherwise, . /// /// The key of the value to get or set. /// is . object this[string key] { get; set; } /// /// Removes all keys and values from a session. /// void Clear(); /// /// Determines whether a session contains an element with the specified key. /// /// The key to locate in the object that implements . /// /// if the object that implements contains an element with the key; /// otherwise, . /// /// is . bool ContainsKey(string key); /// /// Gets the value associated with the specified key. /// /// The key whose value to get. /// When this method returns, the value associated with the specified , /// if the key is found; otherwise, . This parameter is passed uninitialized. /// if the object that implements /// contains an element with the specified key; otherwise, . /// is . bool TryGetValue(string key, out object value); /// /// Attempts to remove and return the value that has the specified key from a session. /// /// The key of the element to remove and return. /// When this method returns, the value removed from the object that implements , /// if the key is found; otherwise, . This parameter is passed uninitialized. /// if the value was removed successfully; otherwise, . /// is . bool TryRemove(string key, out object value); /// /// Takes and returns a snapshot of the contents of a session at the time of calling. /// /// An IReadOnlyList<KeyValuePair<string,object>> interface /// containing an immutable copy of the session data as it was at the time of calling this method. /// /// 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. /// IReadOnlyList> TakeSnapshot(); } }