} // end _RegisterGenericViewDefinition()

            internal bool RemoveByName(string typeName)
            {
                if (DbgTemplate.LooksLikeATemplateName(typeName))
                {
                    var template = DbgTemplate.CrackTemplate(typeName);
                    return(m_genericsMap.Remove(template.TemplateName));
                }
                else
                {
                    return(m_map.Remove(typeName));
                }
                // Note that we do not have the opposite of _RaiseViewRegistered. But I
                // don't think it's needed.
            } // end RemoveByName()
            } // end ScrubFileList()

            private IEnumerable <AltTypeFormatEntryPair> _EnumerateEntriesForTypeNames(IEnumerable <string> typeNames)
            {
                if (null == typeNames)
                {
                    throw new ArgumentNullException("typeNames");
                }

                List <ViewDefinitionInfo> views = null;

                foreach (var rawName in typeNames)
                {
                    bool   isGenericOrTemplate;
                    string typeName = Util.MassageManagedTypeName(rawName, out isGenericOrTemplate);
                    if (!isGenericOrTemplate)
                    {
                        isGenericOrTemplate = DbgTemplate.LooksLikeATemplateName(typeName);
                    }

                    if (isGenericOrTemplate)
                    {
                        var template = DbgTemplate.CrackTemplate(typeName);
                        TypeNameMatchList <GenericViewDefinitionInfoList> tnml;
                        if (m_genericsMap.TryGetValue(template.TemplateName, out tnml))
                        {
                            foreach (var gvdil in tnml.FindMatchingItems(template))
                            {
                                foreach (var vdi in gvdil.Views)
                                {
                                    yield return(new AltTypeFormatEntryPair(typeName, vdi));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (m_map.TryGetValue(typeName, out views))
                        {
                            foreach (var vdi in views)
                            {
                                yield return(new AltTypeFormatEntryPair(typeName, vdi));
                            }
                        }
                    } // end else( not generic )
                }     // end foreach( typeName )
            }         // end _EnumerateEntriesForTypeNames()
            } // end _RaiseViewRegistered()

            internal void RegisterViewDefinition(AltTypeFormatEntry typeEntry)
            {
                if (typeEntry.ViewDefinitions.Count > 0)
                {
                    // It will be the same for all the views in the same AltTypeFormatEntry,
                    // so we can just use the first one.
                    m_scriptLoader.AddSourceFile(typeEntry.ViewDefinitions[0].SourceScript);
                }

                if (DbgTemplate.LooksLikeATemplateName(typeEntry.TypeName))
                {
                    _RegisterGenericViewDefinition(typeEntry);
                }
                else
                {
                    _RegisterViewDefinition(typeEntry);
                }
            } // end RegisterViewDefinition()
            } // end _RegisterViewDefinition()

            private void _RegisterGenericViewDefinition(AltTypeFormatEntry typeEntry)
            {
                var template = DbgTemplate.CrackTemplate(typeEntry.TypeName);
                TypeNameMatchList <GenericViewDefinitionInfoList> existingViews;

                if (!m_genericsMap.TryGetValue(template.TemplateName, out existingViews))
                {
                    //views = new TypeNameMatchList< GenericViewDefinitionInfoList >( typeEntry.TypeName, typeEntry.ViewDefinitions );
                    existingViews = new TypeNameMatchList <GenericViewDefinitionInfoList>();
                    if (!existingViews.AddOrReplace(new GenericViewDefinitionInfoList(template, typeEntry.ViewDefinitions)))
                    {
                        LogManager.Trace("Replacing existing view definitions for: {0}",
                                         template);
                    }
                    m_genericsMap.Add(template.TemplateName, existingViews);
                    // TODO: check for duplicate view types. Then, TODO: how to warn that
                    // they are ignored. Pass an IPipelineCallback, I guess.
                    _RaiseViewRegistered(typeEntry);
                    return;
                }

                // Rather than just blindly adding to the list, we check to see if
                // we already have views of the same type, and if so, update them.

                var updatedInPlace = new HashSet <ViewDefinitionInfo>();

                //existingViews.UpdateItemsExact( template, ( existingViewList ) =>
                foreach (var existingViewList in existingViews.FindMatchingItemsExact(template))
                {
                    for (int i = 0; i < existingViewList.Views.Count; i++)
                    {
                        foreach (var newView in typeEntry.ViewDefinitions)
                        {
                            if (existingViewList.Views[i].ViewDefinition.GetType() == newView.ViewDefinition.GetType())
                            {
                                // In-place update.
                                existingViewList.Views[i] = newView;
                                updatedInPlace.Add(newView);
                            }
                        }
                    }
                }

                GenericViewDefinitionInfoList list;

                if (0 == updatedInPlace.Count)
                {
                    list = new GenericViewDefinitionInfoList(template, typeEntry.ViewDefinitions);
                }
                else
                {
                    list = new GenericViewDefinitionInfoList(template, typeEntry.ViewDefinitions.Count - updatedInPlace.Count);
                    foreach (var view in typeEntry.ViewDefinitions)
                    {
                        if (!updatedInPlace.Contains(view))
                        {
                            list.Views.Add(view);
                        }
                    }
                }
                if (!existingViews.AddOrReplace(list))
                {
                    LogManager.Trace("Replacing existing view definition list for: {0}", list.TypeName);
                }

                _RaiseViewRegistered(typeEntry);
            } // end _RegisterGenericViewDefinition()