System.ComponentModel.TypeDescriptor.PipelineInitialize C# (CSharp) Method

PipelineInitialize() private static method

This is the first stage in the pipeline. This checks the incoming member collection and if it differs from what we have seen in the past, it invalidates all successive pipelines.
private static PipelineInitialize ( int pipelineType, ICollection members, IDictionary cache ) : ICollection
pipelineType int
members ICollection
cache IDictionary
return ICollection
        private static ICollection PipelineInitialize(int pipelineType, ICollection members, IDictionary cache)
        {
            if (cache != null)
            {
                bool cacheValid = true;

                ICollection cachedMembers = cache[s_pipelineInitializeKeys[pipelineType]] as ICollection;
                if (cachedMembers != null && cachedMembers.Count == members.Count)
                {
                    IEnumerator cacheEnum = cachedMembers.GetEnumerator();
                    IEnumerator memberEnum = members.GetEnumerator();

                    while (cacheEnum.MoveNext() && memberEnum.MoveNext())
                    {
                        if (cacheEnum.Current != memberEnum.Current)
                        {
                            cacheValid = false;
                            break;
                        }
                    }
                }

                if (!cacheValid)
                {
                    // The cache wasn't valid.  Remove all subsequent cache layers
                    // and then save off new data.
                    cache.Remove(s_pipelineMergeKeys[pipelineType]);
                    cache.Remove(s_pipelineFilterKeys[pipelineType]);
                    cache.Remove(s_pipelineAttributeFilterKeys[pipelineType]);
                    cache[s_pipelineInitializeKeys[pipelineType]] = members;
                }
            }

            return members;
        }