internal static T CreateChain <T> (ChainedExtension next) where T : ChainedExtension, new()
        {
            var first = new T();

            first.nextInChain = ChainedExtension.FindNextImplementation <T> (next);
            return(first);
        }
Exemple #2
0
        public T GetExtension <T> () where T : ChainedExtension, new()
        {
            ChainedExtension e;

            if (!chains.TryGetValue(typeof(T), out e))
            {
                e = new T();
                e.InitChain(this, ChainedExtension.FindNextImplementation <T> (extensions[0]));
                chains [typeof(T)] = e;
            }
            return((T)e);
        }
            public void Update(ExtensionChain chain, Type type, int firstChainChangeIndex)
            {
                // We only want to update an extension if we insert somewhere before the extension we found.
                if (extensionIndex < firstChainChangeIndex)
                {
                    return;
                }

                // Maybe it would be useful to skip extensions until min(indices), as they've already been scanned
                // in a previous check
                var impl = ChainedExtension.FindNextImplementation(type, chain.extensions[0], out extensionIndex);

                Extension.InitChain(chain, impl);
            }
Exemple #4
0
        void Rechain()
        {
            // 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 fex in chains)
            {
                fex.Value.InitChain(this, ChainedExtension.FindNextImplementation(fex.Key, extensions[0]));
            }
        }