public T GetExtension <T> () where T : ChainedExtension, new() { if (!chains.TryGetValue(typeof(T), out ChainedExtensionSentinel e)) { e = new ChainedExtensionSentinel(new T()); e.Update(this, typeof(T), -1); chains [typeof(T)] = e; } return((T)e.Extension); }
void Rechain(int firstChangeIndex) { // If we are in a batch update, only update where to start rechaining. if (batchModifier != null) { batchModifier.UpdateFirstIndex(firstChangeIndex); return; } // Re-chain every extension for (int n = extensions.Length - 2; n >= 0; n--) { extensions [n].InitChain(this, extensions [n + 1]); } // The first extension object in type-specific chains is a placeholder extension used only to hold // a reference to the real first extension. foreach (var kvp in chains) { ChainedExtensionSentinel fex = kvp.Value; fex.Update(this, kvp.Key, firstChangeIndex); } }