1 |
#Region "Microsoft.VisualBasic::a58f699a4273d018adb130277e0420cf, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Extensions\APIExtensions2.vb"
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
#End Region
|
42 |
|
43 |
Imports System.Runtime.CompilerServices
|
44 |
Imports Microsoft.VisualBasic.ApplicationServices.Development.XmlDoc.Assembly
|
45 |
Imports Microsoft.VisualBasic.Language
|
46 |
Imports Microsoft.VisualBasic.Linq
|
47 |
Imports Microsoft.VisualBasic.Text
|
48 |
|
49 |
Namespace ApplicationServices.Development.XmlDoc.Serialization
|
50 |
|
51 |
Partial Module APIExtensions
|
52 |
|
53 |
<Extension> Public Function Sum(projects As IEnumerable(Of Project), Optional excludeNamespace$() = Nothing, <CallerMemberName> Optional name$ = Nothing) As Project
|
54 |
Dim namespaces As New Dictionary(Of String, ProjectNamespace)
|
55 |
Dim out As New Project(name, namespaces)
|
56 |
|
57 |
For Each proj As Project In projects
|
58 |
For Each ns In proj.Namespaces
|
59 |
|
60 |
If Not excludeNamespace Is Nothing Then
|
61 |
Dim skip As Boolean = False
|
62 |
|
63 |
For Each nsName As String In excludeNamespace
|
64 |
If InStr(ns.Path, nsName) = 1 Then
|
65 |
skip = True
|
66 |
Exit For
|
67 |
End If
|
68 |
Next
|
69 |
|
70 |
If skip Then
|
71 |
Continue For
|
72 |
End If
|
73 |
End If
|
74 |
|
75 |
With ns.Path.ToLower
|
76 |
If namespaces.ContainsKey(.ByRef) Then
|
77 |
namespaces(.ByRef) = namespaces(.ByRef).Add(ns, proj:=out)
|
78 |
Else
|
79 |
namespaces.Add(.ByRef, ns)
|
80 |
End If
|
81 |
End With
|
82 |
Next
|
83 |
Next
|
84 |
|
85 |
Return out
|
86 |
End Function
|
87 |
|
88 |
<Extension>
|
89 |
Public Function Sum(members As IEnumerable(Of ProjectMember), type As ProjectType) As ProjectMember
|
90 |
Dim list = members.ToArray
|
91 |
Return New ProjectMember(type) With {
|
92 |
.Name = list(0).Name,
|
93 |
.Declare = list.Select(Function(m) m.Declare).Distinct.JoinBy(vbLf),
|
94 |
.Remarks = list.Select(Function(m) m.Remarks).Distinct.JoinBy(vbLf),
|
95 |
.Returns = list.Select(Function(m) m.Returns).Distinct.JoinBy(vbLf),
|
96 |
.Summary = list.Select(Function(m) m.Summary).Distinct.JoinBy(vbLf),
|
97 |
.Params = list.Select(Function(m) m.Params).IteratesALL.ToArray
|
98 |
}
|
99 |
End Function
|
100 |
|
101 |
<Extension>
|
102 |
Private Function Add(ns1 As ProjectNamespace, ns2 As ProjectNamespace, proj As Project) As ProjectNamespace
|
103 |
Dim path$ = ns1.Path
|
104 |
Dim types As New Dictionary(Of String, ProjectType)
|
105 |
|
106 |
For Each type As ProjectType In ns1.Types + ns2.Types.AsList
|
107 |
Dim key = type.Name.ToLower
|
108 |
|
109 |
If types.ContainsKey(key) Then
|
110 |
types(key) = types(key).Add(type)
|
111 |
Else
|
112 |
types.Add(key, type)
|
113 |
End If
|
114 |
Next
|
115 |
|
116 |
Return New ProjectNamespace(proj, types) With {
|
117 |
.Path = path
|
118 |
}
|
119 |
End Function
|
120 |
|
121 |
<Extension>
|
122 |
Private Function Add(t1 As ProjectType, t2 As ProjectType) As ProjectType
|
123 |
Return New ProjectType(t1, t2) With {
|
124 |
.Name = t1.Name,
|
125 |
.Remarks = mergeAnnotations(t1.Remarks, t2.Remarks),
|
126 |
.Summary = mergeAnnotations(t1.Summary, t2.Summary)
|
127 |
}
|
128 |
End Function
|
129 |
|
130 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
131 |
Friend Function mergeAnnotations(a$, b$) As String
|
132 |
Return {a, b}.Distinct.JoinBy(ASCII.LF & ASCII.LF)
|
133 |
End Function
|
134 |
End Module
|
135 |
End Namespace
|