private void InvokeReleasePipeline(int extensionIndex, ReleaseInvocation invocation) { if (extensionIndex >= releaseExtensions.Length) { invocation.ReturnValue = base.Release(invocation.Burden); return; } var nextIndex = extensionIndex + 1; invocation.SetProceedDelegate(() => InvokeReleasePipeline(nextIndex, invocation)); releaseExtensions[extensionIndex].Intercept(invocation); }
public override bool Release(Burden burden) { if (releaseExtensions == null) { return base.Release(burden); } var invocation = new ReleaseInvocation(burden); InvokeReleasePipeline(0, invocation); return invocation.ReturnValue; }
public override bool Release(object instance) { if (releaseExtensions == null) { return base.Release(instance); } var invocation = new ReleaseInvocation(instance); InvokeReleasePipeline(0, invocation); return invocation.ReturnValue; }
public override bool Release(Burden burden) { if (releaseExtensions == null) { return(base.Release(burden)); } var invocation = new ReleaseInvocation(burden); InvokeReleasePipeline(0, invocation); return(invocation.ReturnValue); }
public void Intercept(ReleaseInvocation invocation) { if (releasingHandlers != null) { IList<ComponentReleasingDelegate> releasers; lock (releasingHandlers) { if (releasingHandlers.TryGetValue(invocation.Instance, out releasers)) { releasingHandlers.Remove(invocation.Instance); } } if (releasers != null) { foreach (var releaser in releasers) { releaser(kernel); } } } invocation.Proceed(); }