11# Region "Microsoft.VisualBasic::613a5e2782e9f04919acfbebca5be083, Microsoft.VisualBasic.Core\src\ComponentModel\DataSource\Repository\InMemoryDb.vb"
22
3- ' Author:
4- '
5- 6- 7- 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-
35- ' Code Statistics:
36-
37- ' Total Lines: 30
38- ' Code Lines: 17 (56.67%)
39- ' Comment Lines: 5 (16.67%)
40- ' - Xml Docs: 100.00%
41- '
42- ' Blank Lines: 8 (26.67%)
43- ' File Size: 1.09 KB
44-
45-
46- ' Class InMemoryDb
47- '
48- ' Function: [Get]
49- '
50- ' Sub: Put
51- '
52- '
53- ' /********************************************************************************/
3+ ' Author:
4+ '
5+ 6+ 7+ 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+
35+ ' Code Statistics:
36+
37+ ' Total Lines: 30
38+ ' Code Lines: 17 (56.67%)
39+ ' Comment Lines: 5 (16.67%)
40+ ' - Xml Docs: 100.00%
41+ '
42+ ' Blank Lines: 8 (26.67%)
43+ ' File Size: 1.09 KB
44+
45+
46+ ' Class InMemoryDb
47+ '
48+ ' Function: [Get]
49+ '
50+ ' Sub: Put
51+ '
52+ '
53+ ' /********************************************************************************/
5454
5555# End Region
5656
@@ -59,14 +59,22 @@ Imports System.Text
5959
6060Namespace ComponentModel.DataSourceModel.Repository
6161
62- Public MustInherit Class InMemoryDb
62+ Public MustInherit Class InMemoryDb : Implements IDisposable
63+
64+ Private disposedValue As Boolean
6365
6466 ''' <summary>
6567 ''' 枚举数据库中所有的键。
6668 ''' 此操作会遍历所有数据文件,可能比较耗时,建议在需要时调用。
6769 ''' </summary>
6870 ''' <returns>返回一个包含所有键的字符串集合。</returns>
6971 Public MustOverride Iterator Function EnumerateAllKeys() As IEnumerable( Of Byte ())
72+ Public MustOverride Function HasKey(keydata As Byte ()) As Boolean
73+
74+ <MethodImpl(MethodImplOptions.AggressiveInlining)>
75+ Public Function HasKey( key As String ) As Boolean
76+ Return HasKey(Encoding.UTF8.GetBytes( key ))
77+ End Function
7078
7179 <MethodImpl(MethodImplOptions.AggressiveInlining)>
7280 Public Function [Get]( key As String ) As Byte ()
@@ -82,5 +90,38 @@ Namespace ComponentModel.DataSourceModel.Repository
8290
8391 Public MustOverride Sub Put(keybuf As Byte (), data As Byte ())
8492
93+ ''' <summary>
94+ ''' close the database connection
95+ ''' </summary>
96+ ''' <remarks>
97+ ''' this function will be called on dispose
98+ ''' </remarks>
99+ Protected MustOverride Sub Close()
100+
101+ Protected Overridable Sub Dispose(disposing As Boolean )
102+ If Not disposedValue Then
103+ If disposing Then
104+ ' TODO: dispose managed state (managed objects)
105+ Call Close()
106+ End If
107+
108+ ' TODO: free unmanaged resources (unmanaged objects) and override finalizer
109+ ' TODO: set large fields to null
110+ disposedValue = True
111+ End If
112+ End Sub
113+
114+ ' ' TODO: override finalizer only if 'Dispose(disposing As Boolean)' has code to free unmanaged resources
115+ ' Protected Overrides Sub Finalize()
116+ ' ' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
117+ ' Dispose(disposing:=False)
118+ ' MyBase.Finalize()
119+ ' End Sub
120+
121+ Public Sub Dispose() Implements IDisposable.Dispose
122+ ' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
123+ Dispose(disposing:= True )
124+ GC.SuppressFinalize( Me )
125+ End Sub
85126 End Class
86127End Namespace
0 commit comments