1 | #Region "Microsoft.VisualBasic::a7cc59b32cd410df49b8c0ec11bb7a4d, Microsoft.VisualBasic.Core\Serialization\BinaryDumping\BinaryWriter.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 | ' Module BinaryWriter |
35 | ' |
36 | ' Function: __serialize, GetReadProperty, (+2 Overloads) Serialization |
37 | ' |
38 | ' |
39 | ' /********************************************************************************/ |
40 | |
41 | #End Region |
42 | |
43 | Imports System.Reflection |
44 | Imports System.Runtime.CompilerServices |
45 | |
46 | Namespace Serialization.BinaryDumping |
47 | |
48 | Public Module BinaryWriter |
49 | |
50 | <Extension> Public Function Serialization(Of T)(obj As T) As Byte() |
51 | Dim type As Type = GetType(T) |
52 | Return Serialization(obj, type).ToArray |
53 | End Function |
54 | |
55 | Public Function Serialization(obj As Object, type As Type) As List(Of Byte) |
56 | Dim visited As New List(Of Object) |
57 | Dim readProps As PropertyInfo() = type.GetReadProperty |
58 | Dim buffer As New List(Of Byte) |
59 | |
60 | For Each prop As PropertyInfo In readProps |
61 | |
62 | Next |
63 | |
64 | Return buffer |
65 | End Function |
66 | |
67 | <Extension> |
68 | Public Function GetReadProperty(type As Type) As PropertyInfo() |
69 | Dim LQuery = (From p As PropertyInfo |
70 | In type.GetProperties(BindingFlags.Public Or BindingFlags.Instance) |
71 | Where p.CanRead AndAlso |
72 | p.GetIndexParameters.IsNullOrEmpty |
73 | Select p).ToArray |
74 | Return LQuery |
75 | End Function |
76 | |
77 | Private Function __serialize(obj As Object, type As Type, ByRef visited As List(Of Object)) As List(Of Byte) |
78 | Dim readProps As PropertyInfo() = type.GetReadProperty |
79 | Throw New NotImplementedException |
80 | End Function |
81 | End Module |
82 | End Namespace |