private void BuildMethodEntries(string collectionName, List <MethodDef> entries, Entry typeEntry, ICommentSource commentsXml)
        {
            if (entries.Count == 0)
            {
                return;
            }

            ReflectedMember containingType = (ReflectedMember)typeEntry.Item;

            Entry eventsEntry = EntryCreator.Create(entries, collectionName, commentsXml, typeEntry);

            eventsEntry.IsSearchable = false;
            eventsEntry.Key          = containingType.GetGloballyUniqueId();
            eventsEntry.SubKey       = collectionName;

            foreach (MethodDef current in entries)
            {
                PreEntryAddedEventArgs e = new PreEntryAddedEventArgs(current);
                this.OnPreEntryAdded(e);
                if (!e.Filter)
                {
                    Entry propertyEntry = EntryCreator.Create(current, current.GetDisplayName(false, false), commentsXml, eventsEntry);
                    propertyEntry.IsSearchable = true;
                    propertyEntry.Key          = current.GetGloballyUniqueId();
                    eventsEntry.Children.Add(propertyEntry);
                }
            }

            if (eventsEntry.Children.Count > 0)
            {
                eventsEntry.Children.Sort();
                typeEntry.Children.Add(eventsEntry);
            }
        }
        protected override Entry GenerateDocumentForAssembly(DocumentMap map, DocumentedAssembly current, ref int fileCounter)
        {
            AssemblyDef    assembly    = GetAssemblyDef(current);
            ICommentSource xmlComments = GetXmlCommentFile(current);

            Entry assemblyEntry = EntryCreator.Create(assembly, System.IO.Path.GetFileName(current.FileName), xmlComments);

            current.UniqueId           = assembly.UniqueId = fileCounter++;
            assemblyEntry.Key          = assembly.GetGloballyUniqueId();
            assemblyEntry.IsSearchable = false;
            Entry namespaceEntry = null;

            // Add the namespaces to the document map
            Dictionary <string, List <TypeDef> > typesInNamespaces = assembly.GetTypesInNamespaces();

            foreach (KeyValuePair <string, List <TypeDef> > currentNamespace in typesInNamespaces)
            {
                if (currentNamespace.Value.Count == 0)
                {
                    continue;
                }
                string namespaceSubKey = BuildSubkey(currentNamespace);

                namespaceEntry = Find(map, namespaceSubKey);
                if (namespaceEntry == null)
                {
                    string displayName = currentNamespace.Key;

                    if (string.IsNullOrEmpty(currentNamespace.Key))
                    {
                        displayName = "None";
                    }

                    namespaceEntry              = EntryCreator.Create(currentNamespace, displayName, xmlComments);
                    namespaceEntry.Key          = assemblyEntry.Key;
                    namespaceEntry.SubKey       = namespaceSubKey;
                    namespaceEntry.IsSearchable = false;
                }

                // Add the types from that namespace to its map
                foreach (TypeDef currentType in currentNamespace.Value)
                {
                    if (currentType.IsCompilerGenerated || currentType.Name[0] == '<')
                    {
                        continue;
                    }

                    PreEntryAddedEventArgs e = new PreEntryAddedEventArgs(currentType);
                    this.OnPreEntryAdded(e);
                    if (!e.Filter)
                    {
                        Entry typeEntry = EntryCreator.Create(currentType, currentType.GetDisplayName(false), xmlComments, namespaceEntry);
                        typeEntry.Key          = currentType.GetGloballyUniqueId();
                        typeEntry.IsSearchable = true;

                        // For some elements we will not want to load the child objects
                        // this is currently for System.Enum derived values.
                        if
                        (
                            currentType.InheritsFrom != null && currentType.InheritsFrom.GetFullyQualifiedName() == "System.Enum" ||
                            currentType.IsDelegate)
                        {
                            // Ignore children
                        }
                        else
                        {
                            this.GenerateTypeMap(currentType, typeEntry, xmlComments);
                            typeEntry.Children.Sort();
                        }

                        namespaceEntry.Children.Add(typeEntry);
                    }
                }
                if (namespaceEntry.Children.Count > 0)
                {
                    namespaceEntry.Children.Sort();
                    // we still need to add here otherwise we get duplicate namespaces.
                    assemblyEntry.Children.Add(namespaceEntry);
                    if (!map.Contains(namespaceEntry))
                    {
                        map.Add(namespaceEntry);
                    }
                    else
                    {
                        // update the type list is the contianing namespace
                        KeyValuePair <string, List <TypeDef> > original = (KeyValuePair <string, List <TypeDef> >)namespaceEntry.Item;
                        original.Value.AddRange(currentNamespace.Value);
                    }
                }
            }

            // we are not interested in assemblies being used here so make them childless
            return(this.EntryCreator.Create(null, string.Empty, null));
        }
示例#3
0
        protected override Entry GenerateDocumentForAssembly(DocumentMap map, DocumentedAssembly current, ref int fileCounter)
        {
            AssemblyDef assembly = AssemblyDef.Create(current.FileName);

            current.LoadedAssembly = assembly;

            XmlCommentFile commentFile = new XmlCommentFile(current.XmlFileName, new FileSystem());

            commentFile.Load();
            ICommentSource xmlComments = commentFile; // not nice having to call load then cast we wil have to fix this


            Entry assemblyEntry = this.EntryCreator.Create(assembly, System.IO.Path.GetFileName(current.FileName), xmlComments);

            current.UniqueId           = assembly.UniqueId = fileCounter++;
            assemblyEntry.Key          = assembly.GetGloballyUniqueId();
            assemblyEntry.IsSearchable = false;

            // Add the namespaces to the document map
            Dictionary <string, List <TypeDef> > typesInNamespaces = assembly.GetTypesInNamespaces();

            foreach (KeyValuePair <string, List <TypeDef> > currentNamespace in typesInNamespaces)
            {
                if (string.IsNullOrEmpty(currentNamespace.Key) || currentNamespace.Value.Count == 0)
                {
                    continue;
                }
                string namespaceSubKey = this.BuildSubkey(currentNamespace);

                Entry namespaceEntry = this.FindByKey(map, assemblyEntry.Key, namespaceSubKey, false);
                if (namespaceEntry == null)
                {
                    namespaceEntry              = this.EntryCreator.Create(currentNamespace, currentNamespace.Key, xmlComments, assemblyEntry);
                    namespaceEntry.Key          = assemblyEntry.Key;
                    namespaceEntry.SubKey       = namespaceSubKey;
                    namespaceEntry.IsSearchable = false;
                }

                // Add the types from that namespace to its map
                foreach (TypeDef currentType in currentNamespace.Value)
                {
                    if (currentType.Name.StartsWith("<"))
                    {
                        continue;
                    }
                    PreEntryAddedEventArgs e = new PreEntryAddedEventArgs(currentType);
                    this.OnPreEntryAdded(e);
                    if (!e.Filter)
                    {
                        Entry typeEntry = this.EntryCreator.Create(currentType, currentType.GetDisplayName(false), xmlComments, namespaceEntry);
                        typeEntry.Key          = currentType.GetGloballyUniqueId();
                        typeEntry.IsSearchable = true;

                        // For some elements we will not want to load the child objects
                        // this is currently for System.Enum derived values.
                        if (
                            currentType.InheritsFrom != null && currentType.InheritsFrom.GetFullyQualifiedName() == "System.Enum" ||
                            currentType.IsDelegate)
                        {
                            // Ignore children
                        }
                        else
                        {
                            this.GenerateTypeMap(currentType, typeEntry, xmlComments);
                            typeEntry.Children.Sort();
                        }

                        namespaceEntry.Children.Add(typeEntry);
                    }
                }
                if (namespaceEntry.Children.Count > 0)
                {
                    assemblyEntry.Children.Add(namespaceEntry);
                    namespaceEntry.Children.Sort();
                }
            }

            assemblyEntry.Children.Sort();

            return(assemblyEntry);
        }
 /// <summary>
 /// Fires before a member is added to the document map.
 /// </summary>
 /// <param name="e">The event arguments</param>
 protected void OnPreEntryAdded(PreEntryAddedEventArgs e)
 {
     _preEntryAddedEvent?.Invoke(this, e);
 }
示例#5
0
 /// <summary>
 /// Method that handles the PreEntryAdded event fired by the DocumentMapper before a
 /// member is added to the document map being generated.
 /// </summary>
 /// <param name="sender">The calling object.</param>
 /// <param name="e">The event arguments.</param>
 private void PreEntryAdded(object sender, PreEntryAddedEventArgs e)
 {
     e.Filter = IsMemberFiltered(e.Member);
 }