Esempio n. 1
0
		public void Intercept(ResolveInvocation invocation)
		{
			using (new CustomLifestyle_InstanceScope())
			{
				invocation.Proceed();
			}
		}
        public void Intercept(ResolveInvocation invocation)
        {
            Releasing releasing = null;

            if (resolvers.Count > 0)
            {
                foreach (var resolver in resolvers)
                {
                    var releaser = resolver(kernel, invocation.Context);
                    if (releaser != null)
                    {
                        if (releasing == null)
                        {
                            releasing = new Releasing(resolvers.Count, kernel);
                            invocation.RequireDecommission();
                        }
                        releasing.Add(releaser);
                    }
                }
            }

            invocation.Proceed();

            if (releasing == null)
            {
                return;
            }
            var burden = invocation.Burden;

            if (burden == null)
            {
                return;
            }
            burden.Releasing += releasing.Invoked;
        }
Esempio n. 3
0
		public void Intercept(ResolveInvocation invocation)
		{
			using (new InstanceScope())
			{
				invocation.Proceed();
			}
		}
		public void Intercept(ResolveInvocation invocation)
		{
			Releasing releasing = null;
			if (resolvers.Count > 0)
			{
				foreach (var resolver in resolvers)
				{
					var releaser = resolver(kernel, invocation.Context);
					if (releaser != null)
					{
						if (releasing == null)
						{
							releasing = new Releasing(resolvers.Count, kernel);
							invocation.RequireDecommission();
						}
						releasing.Add(releaser);
					}
				}
			}

			invocation.Proceed();

			if (releasing == null)
			{
				return;
			}
			var burden = invocation.Burden;
			if (burden == null)
			{
				return;
			}
			burden.Releasing += releasing.Invoked;
		}
Esempio n. 5
0
		protected override object Resolve(CreationContext context, bool instanceRequired)
		{
			if (resolveExtensions == null)
			{
				return base.Resolve(context, instanceRequired);
			}
			var invocation = new ResolveInvocation(context, instanceRequired);
			InvokeResolvePipeline(0, invocation);
			return invocation.ResolvedInstance;
		}
Esempio n. 6
0
        protected override object Resolve(CreationContext context, bool instanceRequired)
        {
            if (resolveExtensions == null)
            {
                return(base.Resolve(context, instanceRequired));
            }
            var invocation = new ResolveInvocation(context, instanceRequired);

            InvokeResolvePipeline(0, invocation);
            return(invocation.ResolvedInstance);
        }
Esempio n. 7
0
        private void InvokeResolvePipeline(int extensionIndex, ResolveInvocation invocation)
        {
            if (extensionIndex >= resolveExtensions.Length)
            {
                Burden burden;
                invocation.ResolvedInstance = ResolveCore(invocation.Context,
                                                          invocation.DecommissionRequired,
                                                          invocation.InstanceRequired,
                                                          out burden);
                invocation.Burden = burden;
                return;
            }
            var nextIndex = extensionIndex + 1;

            invocation.SetProceedDelegate(() => InvokeResolvePipeline(nextIndex, invocation));
            resolveExtensions[extensionIndex].Intercept(invocation);
        }
		public void Intercept(ResolveInvocation invocation)
		{
			List<ComponentReleasingDelegate> releasers = null;
			if (resolvingHandler != null)
			{
				foreach (ComponentResolvingDelegate resolver in resolvingHandler.GetInvocationList())
				{
					var releaser = resolver(kernel, invocation.Context);
					if (releaser != null)
					{
						if (releasers == null)
						{
							releasers = new List<ComponentReleasingDelegate>();
							invocation.RequireDecommission();
						}
						releasers.Add(releaser);
					}
				}
			}

			invocation.Proceed();

			if (releasers == null)
			{
				return;
			}

			lock (resolvingHandler)
			{
				if (releasingHandlers == null)
				{
					releasingHandlers = new Dictionary<object, IList<ComponentReleasingDelegate>>();
				}

				if (releasingHandlers.ContainsKey(invocation.ReturnValue) == false)
				{
					releasingHandlers.Add(invocation.ReturnValue, releasers);
				}
			}
		}
Esempio n. 9
0
		private void InvokeResolvePipeline(int extensionIndex, ResolveInvocation invocation)
		{
			if (extensionIndex >= resolveExtensions.Length)
			{
				Burden burden;
				invocation.ResolvedInstance = ResolveCore(invocation.Context,
				                                          invocation.DecommissionRequired,
				                                          invocation.InstanceRequired,
				                                          out burden);
				invocation.Burden = burden;
				return;
			}
			var nextIndex = extensionIndex + 1;
			invocation.SetProceedDelegate(() => InvokeResolvePipeline(nextIndex, invocation));
			resolveExtensions[extensionIndex].Intercept(invocation);
		}