/// <summary> /// Returns the scope for the given key. /// </summary> /// <param name="key">The key to lookup the scope object.</param> /// <returns>Instance of INorthwindScope.</returns> public static INorthwindScope GetScope(INorthwindScopeKey key) { RunHouseKeeping(); if (key == null || key.Key == Guid.Empty) { return null; } INorthwindScope identity; lock (_scopes) { identity = _scopes.ContainsKey(key) ? _scopes[key] : null; } if (identity == null) { throw new UserFriendlyException("Cannot find Identity with the given key. Please refresh page."); } identity.KeepAlive(); return identity; }
/// <summary> /// Constructor that loads the given instances by their interfaces. /// </summary> /// <param name="scopeKey">The key to get the user's scope.</param> public ScopeService(INorthwindScopeKey scopeKey) : base(scopeKey, null) { }