示例#1
0
        private static void SetCurrentScope(CallContextLifetimeScope lifetimeScope)
        {
#if FEATURE_REMOTING
            CallContext.LogicalSetData(callContextKey, lifetimeScope.contextId);
#else
            asyncLocal.Value = lifetimeScope.contextId;
#endif
        }
		public CallContextLifetimeScope(IKernel container)
		{
			var parent = ObtainCurrentScope();
			if (parent != null)
			{
				parentScope = parent;
			}
			SetCurrentScope(this);
		}
示例#3
0
        public void Dispose()
        {
            var scope = Scope.ObtainCurrentScope();

            if (scope != null)
            {
                scope.Dispose();
            }
        }
示例#4
0
        public CallContextLifetimeScope()
        {
            contextId   = Guid.NewGuid();
            parentScope = ObtainCurrentScope();

            var added = allScopes.TryAdd(contextId, this);

            Debug.Assert(added);
            SetCurrentScope(this);
        }
示例#5
0
        public CallContextLifetimeScope(IKernel container)
        {
            var parent = ObtainCurrentScope();

            if (parent != null)
            {
                parentScope = parent;
            }
            SetCurrentScope(this);
        }
示例#6
0
        public ILifetimeScope GetScope(CreationContext context)
        {
            var scope = Scope.ObtainCurrentScope();

            if (scope == null)
            {
                throw new InvalidOperationException("Scope was not available. Did you forget to call container.BeginScope()?");
            }
            return(scope);
        }
        public CallContextLifetimeScope()
        {
            var parent = ObtainCurrentScope();

            if (parent != null)
            {
                parentScope = parent;
            }
            contextId = Guid.NewGuid();
            var added = appDomainLocalInstanceCache.TryAdd(contextId, this);

            Debug.Assert(added);
            SetCurrentScope(this);
        }
        public CallContextLifetimeScope()
        {
            var parent = ObtainCurrentScope();

            if (parent != null)
            {
                parentScope = parent;
            }
            contextId = Guid.NewGuid();
#if DOTNET35
            lock (cacheLocker)
            {
                appDomainLocalInstanceCache.Add(contextId, this);
            }
#else
            var added = appDomainLocalInstanceCache.TryAdd(contextId, this);
            Debug.Assert(added);
#endif
            SetCurrentScope(this);
        }
示例#9
0
		private void SetCurrentScope(CallContextLifetimeScope lifetimeScope)
		{
			CallContext.LogicalSetData(contextKey, lifetimeScope);
		}
示例#10
0
 private void SetCurrentScope(CallContextLifetimeScope lifetimeScope)
 {
     CallContext.LogicalSetData(contextKey, lifetimeScope);
 }
 private void SetCurrentScope(CallContextLifetimeScope lifetimeScope)
 {
     CallContext.LogicalSetData(keyInCallContext, lifetimeScope.contextId);
 }