protected void FillInheritance(NameGeneratorContext context, ArticleItemYaml yaml, XElement node) { if (yaml.Type == MemberType.Interface) { return; } var nodeIdHash = new Dictionary <string, string>(); var idHash = new Dictionary <string, List <string> >(); var inheritanceGraph = node.NullableElement("inheritancegraph"); foreach (var n in inheritanceGraph.Elements("node")) { string nodeId = n.NullableAttribute("id").NullableValue(); string id = n.NullableElement("link").NullableAttribute("refid").NullableValue() ?? _nameGenerator.GenerateLabel(context, n); nodeIdHash.Add(nodeId, id); var childNode = n.NullableElement("childnode"); if (!childNode.IsNull()) { if (!idHash.ContainsKey(nodeId)) { idHash[nodeId] = new List <string>(); } idHash[nodeId].Add(childNode.NullableAttribute("refid").NullableValue()); } } //yaml.Inheritance = idHash.ToDictionary(pair => nodeIdHash[pair.Key], pair => pair.Value.Select(n => nodeIdHash[n]).ToList()); // var dict = idHash.ToDictionary(pair => nodeIdHash[pair.Key], pair => pair.Value.Select(n => nodeIdHash[n]).ToList()); var dict = idHash.GroupBy(pair => Regex.Replace(nodeIdHash[pair.Key], "<.*?>", string.Empty)).ToDictionary(g => g.Key, g => g.SelectMany(p => p.Value).Select(n => nodeIdHash[n]).ToList()); yaml.Inheritance = new List <string>(); string start = yaml.Uid; while (dict.ContainsKey(start)) { start = dict[start].Single(); yaml.Inheritance.Add(start); } var defaultInheritance = GetDefaultInheritance(yaml); yaml.Inheritance.AddRange(defaultInheritance); yaml.Inheritance.Reverse(); }