A bug or a special purpose
description
<p>Here is the StrategyChain.ExecuteTearDown implementation:</p>
<p> </p>
<p>public void ExecuteTearDown(IBuilderContext context)</p>
<p> {</p>
<p> Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(context, "context");</p>
<p> </p>
<p> int i = 0;</p>
<p> </p>
<p> try</p>
<p> {</p>
<p> for (; i < strategies.Count; ++i)</p>
<p> {</p>
<p> if (context.BuildComplete)</p>
<p> {</p>
<p> --i; // Skip current strategy's post</p>
<p> break;</p>
<p> }</p>
<p> strategies[i].PreTearDown(context);</p>
<p> }</p>
<p> </p>
<p> for (--i; i >= 0; --i)</p>
<p> {</p>
<p> strategies[i].PostTearDown(context);</p>
<p> }</p>
<p> }</p>
<p> catch(Exception)</p>
<p> {</p>
<p> context.RecoveryStack.ExecuteRecovery();</p>
<p> throw;</p>
<p> }</p>
<p> }</p>
<p> </p>
<p>When the last BuilderStrategy in the chain set the context.BuildComplete to true, the ‘i’ doesn’t decrement, so the PostTearDown of the last BuilderStrategy also gets run.</p>