Пример #1
0
 public void SetScopeContext(ScopeContext scopeContext)
 {
     if (scopeContext == null)
     {
         throw new ArgumentNullException(nameof(scopeContext));
     }
     Contexts[scopeContext.ScopeId] = scopeContext;
 }
Пример #2
0
        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]);
        }
Пример #3
0
        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)));
        }