public void SetScopeContext(ScopeContext scopeContext) { if (scopeContext == null) { throw new ArgumentNullException(nameof(scopeContext)); } Contexts[scopeContext.ScopeId] = scopeContext; }
public ScopeContext GetScopeContext(string scopeId, bool createIfNotExist) { if (!Contexts.ContainsKey(scopeId)) { if (!createIfNotExist) { return(null); } var scopeContext = new ScopeContext { ScopeId = scopeId }; Contexts[scopeId] = scopeContext; } return(Contexts[scopeId]); }
public static T GetItemAs <T>(this ScopeContext ctx, string key, T defaultValue = default(T)) { var value = ctx.GetItem(key, defaultValue); return((T)Convert.ChangeType(value, typeof(T))); }