1 #Region "Microsoft.VisualBasic::167126275e3a2151b15d8e95d708d721, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectNamespace.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Class ProjectNamespace
35     
36     '         Properties: Path, Types
37     
38     '         Constructor: (+3 OverloadsSub New
39     '         Function: [GetType], EnsureType, ToString
40     
41     
42     ' /********************************************************************************/
43
44 #End Region
45
46 ' Copyright (c) Bendyline LLC. All rights reserved. Licensed under the Apache License, Version 2.0.
47 '    You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 
48
49 Imports System.Runtime.CompilerServices
50
51 Namespace ApplicationServices.Development.XmlDoc.Assembly
52
53     ''' <summary>
54     ''' A namespace within a project -- typically a collection of related types.  Equates to a .net Namespace.
55     ''' </summary>
56     Public Class ProjectNamespace
57
58         Protected project As Project
59         Protected _types As Dictionary(Of String, ProjectType)
60
61         Public Property Path() As String
62
63         Public ReadOnly Property Types() As IEnumerable(Of ProjectType)
64             <MethodImpl(MethodImplOptions.AggressiveInlining)>
65             Get
66                 Return Me._types.Values
67             End Get
68         End Property
69
70         Public Sub New(project As Project)
71             Me.project = project
72             Me._types = New Dictionary(Of String, ProjectType)()
73         End Sub
74
75         Public Sub New(proj As Project, types As Dictionary(Of String, ProjectType))
76             Me.project = proj
77             Me._types = types
78         End Sub
79
80         Protected Sub New(ns As ProjectNamespace)
81             Call Me.New(ns.project, ns._types)
82         End Sub
83
84         Public Overrides Function ToString() As String
85             Return Path
86         End Function
87
88         Public Overloads Function [GetType](typeName As StringAs ProjectType
89             If Me._types.ContainsKey(typeName.ToLower()) Then
90                 Return Me._types(typeName.ToLower())
91             End If
92
93             Return Nothing
94         End Function
95
96         Public Function EnsureType(typeName As StringAs ProjectType
97             Dim pt As ProjectType = Me.[GetType](typeName)
98
99             If pt Is Nothing Then
100                 pt = New ProjectType(Me) With {
101                     .Name = typeName
102                 }
103
104                 Me._types.Add(typeName.ToLower(), pt)
105             End If
106
107             Return pt
108         End Function
109     End Class
110 End Namespace