add xdr code handler

master
この中二病に爆焔を! 5 years ago
parent 2ae679ced0
commit 9fa50d58d6

@ -11,6 +11,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BinaryData", "..\sciBASIC#\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework", "framework", "{AAD1FC97-3157-4516-A6B4-2B19D673474E}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "XDRStream", "XDRStream\XDRStream.vbproj", "{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
BioDeep_database|Any CPU = BioDeep_database|Any CPU
@ -708,6 +710,204 @@ Global
{487D7C92-D05A-4908-BF81-E6BABA0BF592}.Yilia-Release_x64|x64.Build.0 = Release|x64
{487D7C92-D05A-4908-BF81-E6BABA0BF592}.Yilia-Release_x64|x86.ActiveCfg = Release|x86
{487D7C92-D05A-4908-BF81-E6BABA0BF592}.Yilia-Release_x64|x86.Build.0 = Release|x86
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.BioDeep_database|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep_UNIX_x64|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biodeep|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Biostack-Debug|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Debug|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.DEMO|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Docker|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.docs|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(Release_X64)|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GCModeller(UNIX-Release_X64)|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.GTA5-game-test|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.installer_x64|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.linux-profiler|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.LipidSearch|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.MetaCardio|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mysqli_X64_release|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit_UnixDocker|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.mzkit|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.node-debug|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.PlantMAT|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.ProteoWizard.d|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Publish|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.R-dotnet|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Release|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Rsharp_app_release|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.RsharpDev|x86.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.sciBASIC.NET-test-release|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Surveillance-of-infectious-diseases|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.test|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Voyager1|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|Any CPU.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|Any CPU.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|x64.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|x64.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|x86.ActiveCfg = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.WebAssembly|x86.Build.0 = Debug|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|Any CPU.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|Any CPU.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|x64.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|x64.Build.0 = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|x86.ActiveCfg = Release|Any CPU
{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}.Yilia-Release_x64|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,63 @@
#Region "Microsoft.VisualBasic::e82582233ab9370ed4a916d504f35ba8, Data\BinaryData\BinaryData\XDR\Attributes\CaseAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class CaseAttribute
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=True)>
Public Class CaseAttribute
Inherits Attribute
Public ReadOnly Value As Object
Public Sub New(val As Object)
Dim vT As Type = val.GetType()
If vT Is GetType(Integer) OrElse vT.IsEnum Then
Value = val
Else
Throw New InvalidOperationException("required enum type or int")
End If
End Sub
End Class
End Namespace

@ -0,0 +1,69 @@
#Region "Microsoft.VisualBasic::3d125c37a2d81976cafb2e6bb4cd022a, Data\BinaryData\BinaryData\XDR\Attributes\FixAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class FixAttribute
'
' Properties: Length
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=False)>
Public Class FixAttribute
Inherits Attribute
Private _Length As UInteger
Public Property Length As UInteger
Get
Return _Length
End Get
Private Set(value As UInteger)
_Length = value
End Set
End Property
Public Sub New(length As UInteger)
If length = 0 Then Throw New ArgumentException("length must be greater than zero")
Me.Length = length
End Sub
End Class
End Namespace

@ -0,0 +1,54 @@
#Region "Microsoft.VisualBasic::681922f83acfe5c665a73aa9e5f05bf3, Data\BinaryData\BinaryData\XDR\Attributes\OptionAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class OptionAttribute
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=False)>
Public Class OptionAttribute
Inherits Attribute
Public Sub New()
End Sub
End Class
End Namespace

@ -0,0 +1,68 @@
#Region "Microsoft.VisualBasic::6d7e61d58408ced9cd1a94f5515eeb60, Data\BinaryData\BinaryData\XDR\Attributes\OrderAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class OrderAttribute
'
' Properties: Order
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=False)>
Public Class OrderAttribute
Inherits Attribute
Private _Order As UInteger
Public Property Order As UInteger
Get
Return _Order
End Get
Private Set(value As UInteger)
_Order = value
End Set
End Property
Public Sub New(order As UInteger)
Me.Order = order
End Sub
End Class
End Namespace

@ -0,0 +1,54 @@
#Region "Microsoft.VisualBasic::043e5bf23dadfd7c723b336c04ab4aca, Data\BinaryData\BinaryData\XDR\Attributes\SwitchAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class SwitchAttribute
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=False)>
Public Class SwitchAttribute
Inherits Attribute
Public Sub New()
End Sub
End Class
End Namespace

@ -0,0 +1,73 @@
#Region "Microsoft.VisualBasic::6f93eeec3aac712957ec93b2f9ffe6df, Data\BinaryData\BinaryData\XDR\Attributes\VarAttribute.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class VarAttribute
'
' Properties: MaxLength
'
' Constructor: (+2 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, Inherited:=True, AllowMultiple:=False)>
Public Class VarAttribute
Inherits Attribute
Private _MaxLength As UInteger
Public Property MaxLength As UInteger
Get
Return _MaxLength
End Get
Private Set(value As UInteger)
_MaxLength = value
End Set
End Property
Public Sub New()
MaxLength = UInteger.MaxValue
End Sub
Public Sub New(maxLength As UInteger)
If maxLength = 0 Then Throw New ArgumentException("length must be greater than zero")
Me.MaxLength = maxLength
End Sub
End Class
End Namespace

@ -0,0 +1,64 @@
#Region "Microsoft.VisualBasic::f212c520101918e343e9cc664a31306a, Data\BinaryData\BinaryData\XDR\Delegates.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Delegate Function
'
'
' Delegate Function
'
'
' Delegate Sub
'
'
' Delegate Sub
'
'
'
'
'
'
'
'
'
' /********************************************************************************/
#End Region
Namespace Xdr
Public Delegate Function ReadOneDelegate(Of T)(reader As Reader) As T
Public Delegate Function ReadManyDelegate(Of T)(reader As Reader, len As UInteger) As T
Public Delegate Sub WriteOneDelegate(Of T)(writer As Writer, item As T)
Public Delegate Sub WriteManyDelegate(Of T)(writer As Writer, len As UInteger, item As T)
End Namespace

@ -0,0 +1,51 @@
#Region "Microsoft.VisualBasic::ecdb7d9b305fb129b4e7b0ac7ab18d36, Data\BinaryData\BinaryData\XDR\Emit\BuildRequest.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class BuildRequest
'
' Properties: Method, TargetType
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Friend NotInheritable Class BuildRequest
Public Property TargetType As Type
Public Property Method As OpaqueType
End Class
End Namespace

@ -0,0 +1,60 @@
#Region "Microsoft.VisualBasic::d9c9f765057d5f82049889558353172d, Data\BinaryData\BinaryData\XDR\Emit\DelegateCacheDescription.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class BuildBinderDescription
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Reflection.Emit
Imports System.Reflection
Namespace Xdr.Emit
Public Class BuildBinderDescription
Public ReadOnly Result As Type
Public ReadOnly BuildRequest As FieldInfo
Public Sub New(modBuilder As ModuleBuilder)
Dim typeBuilder = modBuilder.DefineType("BuildBinder", TypeAttributes.Public Or TypeAttributes.Class Or TypeAttributes.Abstract Or TypeAttributes.Sealed)
Dim fb_request = typeBuilder.DefineField("Request", GetType(Action(Of Type, OpaqueType)), FieldAttributes.Public Or FieldAttributes.Static)
Result = typeBuilder.CreateType()
BuildRequest = fb_request
End Sub
End Class
End Namespace

@ -0,0 +1,71 @@
#Region "Microsoft.VisualBasic::e6da63e5707615687bc169b000d8cd3d, Data\BinaryData\BinaryData\XDR\Emit\ErrorStub.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Module ErrorStub
'
' Function: ReadManyDelegate, ReadOneDelegate, StubDelegate, WriteManyDelegate, WriteOneDelegate
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Friend Module ErrorStub
Private Function StubDelegate(ex As Exception, method As String, targetType As Type, genDelegateType As Type) As [Delegate]
Dim stubType = GetType(ErrorStubType(Of)).MakeGenericType(targetType)
Dim stubInstance = Activator.CreateInstance(stubType, ex)
Dim mi = stubType.GetMethod(method)
Return [Delegate].CreateDelegate(genDelegateType.MakeGenericType(targetType), stubInstance, mi)
End Function
Friend Function ReadOneDelegate(t As Type, ex As Exception) As [Delegate]
Return StubDelegate(ex, "ReadOne", t, GetType(ReadOneDelegate(Of)))
End Function
Friend Function ReadManyDelegate(t As Type, ex As Exception) As [Delegate]
Return StubDelegate(ex, "ReadMany", t, GetType(ReadManyDelegate(Of)))
End Function
Friend Function WriteOneDelegate(t As Type, ex As Exception) As [Delegate]
Return StubDelegate(ex, "WriteOne", t, GetType(WriteOneDelegate(Of)))
End Function
Friend Function WriteManyDelegate(t As Type, ex As Exception) As [Delegate]
Return StubDelegate(ex, "WriteMany", t, GetType(WriteManyDelegate(Of)))
End Function
End Module
End Namespace

@ -0,0 +1,74 @@
#Region "Microsoft.VisualBasic::aca7ad23e0d93dd7158815a5910f7457, Data\BinaryData\BinaryData\XDR\Emit\ErrorStubType.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class ErrorStubType
'
' Constructor: (+1 Overloads) Sub New
'
' Function: ReadMany, ReadOne
'
' Sub: WriteMany, WriteOne
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Friend NotInheritable Class ErrorStubType(Of T)
Public ReadOnly [Error] As Exception
Public Sub New(ex As Exception)
[Error] = ex
End Sub
Public Function ReadOne(reader As Reader) As T
Throw [Error]
End Function
Public Function ReadMany(reader As Reader, len As UInteger) As T
Throw [Error]
End Function
Public Sub WriteOne(writer As Writer, v As T)
Throw [Error]
End Sub
Public Sub WriteMany(writer As Writer, len As UInteger, v As T)
Throw [Error]
End Sub
End Class
End Namespace

@ -0,0 +1,89 @@
#Region "Microsoft.VisualBasic::6b4087e1862e5a0af5c252092ad6880a, Data\BinaryData\BinaryData\XDR\Emit\StaticCacheDescription.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class StaticCacheDescription
'
' Constructor: (+1 Overloads) Sub New
' Function: Instance
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Reflection.Emit
Imports System.Reflection
Namespace Xdr.Emit
Public Class StaticCacheDescription
Public ReadOnly Result As Type
Public Sub New(modBuilder As ModuleBuilder, delegCacheDesc As BuildBinderDescription, name As String, read As Boolean, mType As OpaqueType)
Dim typeBuilder = modBuilder.DefineType(name, TypeAttributes.Public Or TypeAttributes.Class Or TypeAttributes.Abstract Or TypeAttributes.Sealed)
Dim genTypeParam = typeBuilder.DefineGenericParameters("T")(0)
Dim instanceType As Type
If read Then
If mType = OpaqueType.One Then
instanceType = GetType(ReadOneDelegate(Of))
Else
instanceType = GetType(ReadManyDelegate(Of))
End If
Else
If mType = OpaqueType.One Then
instanceType = GetType(WriteOneDelegate(Of))
Else
instanceType = GetType(WriteManyDelegate(Of))
End If
End If
typeBuilder.DefineField("Instance", instanceType.MakeGenericType(genTypeParam), FieldAttributes.Public Or FieldAttributes.Static)
Dim ctor = typeBuilder.DefineConstructor(MethodAttributes.Static, CallingConventions.Standard, New Type(-1) {})
Dim il As ILGenerator = ctor.GetILGenerator()
il.Emit(OpCodes.Ldsfld, delegCacheDesc.BuildRequest)
il.Emit(OpCodes.Ldtoken, genTypeParam)
il.Emit(OpCodes.Call, GetType(Type).GetMethod("GetTypeFromHandle"))
il.Emit(OpCodes.Ldc_I4_S, mType)
il.Emit(OpCodes.Callvirt, GetType(Action(Of Type, OpaqueType)).GetMethod("Invoke"))
il.Emit(OpCodes.Ret)
Result = typeBuilder.CreateType()
End Sub
Public Function Instance(genType As Type) As FieldInfo
Return TypeBuilder.GetField(Result.MakeGenericType(genType), Result.GetField("Instance"))
End Function
End Class
End Namespace

@ -0,0 +1,113 @@
#Region "Microsoft.VisualBasic::eba4374986d38a7d2892e1953bc7b70f, Data\BinaryData\BinaryData\XDR\EmitContexts\EmitContext.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Module EmitContext
'
' Function: EmitReader, EmitWriter, GetReader, GetWriter
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Collections.Generic
Namespace Xdr.EmitContexts
Public Module EmitContext
Private _sync As Object = New Object()
Private _readerCache As Dictionary(Of Type, EmitResult) = New Dictionary(Of Type, EmitResult)()
Private _writerCache As Dictionary(Of Type, EmitResult) = New Dictionary(Of Type, EmitResult)()
Public Function GetReader(targetType As Type) As [Delegate]
SyncLock _sync
Dim result As EmitResult = Nothing
If Not _readerCache.TryGetValue(targetType, result) Then
result = New EmitResult()
Try
result.Method = EmitReader(targetType)
Catch ex As Exception
result.Error = New InvalidOperationException("can't emit reader", ex)
End Try
_readerCache.Add(targetType, result)
End If
If result.Error IsNot Nothing Then Throw result.Error
Return result.Method
End SyncLock
End Function
Public Function GetWriter(targetType As Type) As [Delegate]
SyncLock _sync
Dim result As EmitResult = Nothing
If Not _writerCache.TryGetValue(targetType, result) Then
result = New EmitResult()
Try
result.Method = EmitWriter(targetType)
Catch ex As Exception
result.Error = New InvalidOperationException("can't emit writer", ex)
End Try
_writerCache.Add(targetType, result)
End If
If result.Error IsNot Nothing Then Throw result.Error
Return result.Method
End SyncLock
End Function
Public Function EmitReader(targetType As Type) As [Delegate]
Dim ordModel = OrderModel.Create(targetType)
Dim swModel = SwitchModel.Create(targetType)
If swModel IsNot Nothing AndAlso ordModel IsNot Nothing Then Throw New InvalidOperationException("unknown way to convert")
If swModel IsNot Nothing Then Return swModel.BuildReader(targetType)
If ordModel IsNot Nothing Then Return ordModel.BuildReader(targetType)
Return Nothing
End Function
Public Function EmitWriter(targetType As Type) As [Delegate]
Dim ordModel = OrderModel.Create(targetType)
Dim swModel = SwitchModel.Create(targetType)
If swModel IsNot Nothing AndAlso ordModel IsNot Nothing Then Throw New InvalidOperationException("unknown way to convert")
If swModel IsNot Nothing Then Return swModel.BuildWriter(targetType)
If ordModel IsNot Nothing Then Return ordModel.BuildWriter(targetType)
Return Nothing
End Function
End Module
End Namespace

@ -0,0 +1,51 @@
#Region "Microsoft.VisualBasic::706fbb594e121661e231fb34de656bbe, Data\BinaryData\BinaryData\XDR\EmitContexts\EmitResult.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class EmitResult
'
'
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Public Class EmitResult
Public Method As [Delegate] = Nothing
Public [Error] As Exception = Nothing
End Class
End Namespace

@ -0,0 +1,151 @@
#Region "Microsoft.VisualBasic::d37052787037d2d6a3d6bd4ce29511c1, Data\BinaryData\BinaryData\XDR\EmitContexts\FieldDesc.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class FieldDesc
'
' Constructor: (+1 Overloads) Sub New
'
' Function: BuildAssign, BuildRead, BuildReadOne, BuildWrite, BuildWriteOne
'
' Sub: ExtractAttributes
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Reflection
Imports System.Linq.Expressions
Namespace Xdr.EmitContexts
Public Class FieldDesc
Public ReadOnly FieldType As Type
Public ReadOnly MInfo As MemberInfo
Protected _isOption As Boolean = False
Protected _isMany As Boolean = False
Protected _isFix As Boolean = False
Protected _len As UInteger = 0
Public Sub New(mi As MemberInfo)
MInfo = mi
Dim fi As FieldInfo = TryCast(mi, FieldInfo)
If fi IsNot Nothing Then
FieldType = fi.FieldType
ExtractAttributes()
Return
End If
Dim pi As PropertyInfo = TryCast(mi, PropertyInfo)
If pi IsNot Nothing Then
FieldType = pi.PropertyType
ExtractAttributes()
Return
End If
Throw New NotImplementedException("only PropertyInfo or FieldInfo")
End Sub
Private Sub ExtractAttributes()
Dim optAttr = MInfo.GetAttr(Of OptionAttribute)()
If optAttr IsNot Nothing Then
If FieldType.IsValueType Then Throw New InvalidOperationException("ValueType not supported Option attribute (use Nullable<> type)")
_isOption = True
End If
Dim fixAttr = MInfo.GetAttr(Of FixAttribute)()
Dim varAttr = MInfo.GetAttr(Of VarAttribute)()
If fixAttr IsNot Nothing AndAlso varAttr IsNot Nothing Then Throw New InvalidOperationException("can not use Fix and Var attributes both")
If fixAttr IsNot Nothing Then
_isMany = True
_isFix = True
_len = fixAttr.Length
End If
If varAttr IsNot Nothing Then
_isMany = True
_isFix = False
_len = varAttr.MaxLength
End If
If _isOption AndAlso _isMany Then Throw New InvalidOperationException("can not use Fix and Option attributes both or Var and Option attributes both")
End Sub
Friend Function BuildRead(pReader As Expression) As Expression
If _isMany Then
Return Expression.Call(pReader, GetType(Reader).GetMethod(If(_isFix, "ReadFix", "ReadVar")).MakeGenericMethod(FieldType), Expression.Constant(_len))
Else
Return Expression.Call(pReader, GetType(Reader).GetMethod(If(_isOption, "ReadOption", "Read")).MakeGenericMethod(FieldType))
End If
End Function
Friend Function BuildReadOne(pReader As Expression) As Expression
Return Expression.Call(pReader, GetType(Reader).GetMethod("Read").MakeGenericMethod(FieldType))
End Function
Friend Function BuildWriteOne(pWriter As Expression, key As Object) As Expression
Dim inTryBody As Expression = Expression.Call(pWriter, GetType(Writer).GetMethod("Write").MakeGenericMethod(FieldType), Expression.Constant(key))
Dim exParam = Expression.Parameter(GetType(SystemException), "ex")
Dim inCatchBody = Expression.Throw(Expression.[New](GetType(FormatException).GetConstructor(New Type() {GetType(String), GetType(Exception)}), Expression.Constant("can't write '" & MInfo.Name & "' field"), exParam))
Return Expression.TryCatch(inTryBody, Expression.Catch(exParam, inCatchBody))
End Function
Friend Function BuildWrite(pWriter As Expression, pItem As Expression) As Expression
Dim field As Expression = Expression.PropertyOrField(pItem, MInfo.Name)
Dim inTryBody As Expression
If _isMany Then
inTryBody = Expression.Call(pWriter, GetType(Writer).GetMethod(If(_isFix, "WriteFix", "WriteVar")).MakeGenericMethod(FieldType), Expression.Constant(_len), field)
Else
inTryBody = Expression.Call(pWriter, GetType(Writer).GetMethod(If(_isOption, "WriteOption", "Write")).MakeGenericMethod(FieldType), field)
End If
Dim exParam = Expression.Parameter(GetType(SystemException), "ex")
Dim inCatchBody = Expression.Throw(Expression.[New](GetType(FormatException).GetConstructor(New Type() {GetType(String), GetType(Exception)}), Expression.Constant("can't write '" & MInfo.Name & "' field"), exParam))
Return Expression.TryCatch(inTryBody, Expression.Catch(exParam, inCatchBody))
End Function
Friend Function BuildAssign(readed As Expression, result As ParameterExpression) As Expression
Dim inTryBody = Expression.Assign(Expression.PropertyOrField(result, MInfo.Name), readed)
Dim exParam = Expression.Parameter(GetType(SystemException), "ex")
Dim inCatchBody = Expression.Throw(Expression.[New](GetType(FormatException).GetConstructor(New Type() {GetType(String), GetType(Exception)}), Expression.Constant("can't read '" & MInfo.Name & "' field"), exParam))
Return Expression.TryCatch(Expression.Block(GetType(Void), inTryBody), Expression.Catch(exParam, inCatchBody))
End Function
End Class
End Namespace

@ -0,0 +1,123 @@
#Region "Microsoft.VisualBasic::950940959274ac47a33d956210928806, Data\BinaryData\BinaryData\XDR\EmitContexts\OrderModel.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class OrderModel
'
' Properties: Fields
'
' Function: BuildReader, BuildWriter, Create
'
' Sub: AppendField
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Linq
Imports System.Reflection
Imports System.Collections.Generic
Imports System.Linq.Expressions
Namespace Xdr.EmitContexts
Public Class OrderModel
Private _Fields As System.Collections.Generic.List(Of Xdr.EmitContexts.FieldDesc)
Public Property Fields As List(Of FieldDesc)
Get
Return _Fields
End Get
Private Set(value As List(Of FieldDesc))
_Fields = value
End Set
End Property
Public Function BuildReader(targetType As Type) As [Delegate]
Dim pReader = Expression.Parameter(GetType(Reader))
Dim variables As List(Of ParameterExpression) = New List(Of ParameterExpression)()
Dim body As List(Of Expression) = New List(Of Expression)()
Dim resultVar = Expression.Variable(targetType, "result")
variables.Add(resultVar)
Dim assign = Expression.Assign(resultVar, Expression.[New](targetType))
body.Add(assign)
For Each fieldDesc In Fields
body.Add(fieldDesc.BuildAssign(fieldDesc.BuildRead(pReader), resultVar))
Next
body.Add(resultVar)
Dim block = Expression.Block(variables, body)
Return Expression.Lambda(CType(GetType(ReadOneDelegate(Of)).MakeGenericType(targetType), Type), CType(block, Expression), pReader).Compile()
End Function
Public Function BuildWriter(targetType As Type) As [Delegate]
Dim pWriter = Expression.Parameter(GetType(Writer))
Dim pItem = Expression.Parameter(targetType)
Dim variables As List(Of ParameterExpression) = New List(Of ParameterExpression)()
Dim body As List(Of Expression) = New List(Of Expression)()
For Each fieldDesc In Fields
body.Add(fieldDesc.BuildWrite(pWriter, pItem))
Next
Dim block = Expression.Block(variables, body)
Return Expression.Lambda(CType(GetType(WriteOneDelegate(Of)).MakeGenericType(targetType), Type), CType(block, Expression), CType(pWriter, ParameterExpression), CType(pItem, ParameterExpression)).Compile()
End Function
Public Shared Function Create(t As Type) As OrderModel
Dim fields As SortedList(Of UInteger, FieldDesc) = New SortedList(Of UInteger, FieldDesc)()
For Each f In t.GetFields().Where(Function(fi) fi.IsPublic AndAlso Not fi.IsStatic)
AppendField(fields, f)
Next
For Each p In t.GetProperties().Where(Function(pi) pi.CanWrite AndAlso pi.CanRead)
AppendField(fields, p)
Next
If fields.Count = 0 Then Return Nothing
Dim result As OrderModel = New OrderModel()
result.Fields = fields.Values.ToList()
Return result
End Function
Private Shared Sub AppendField(fields As SortedList(Of UInteger, FieldDesc), mi As MemberInfo)
Dim fAttr As OrderAttribute = mi.GetAttr(Of OrderAttribute)()
If fAttr Is Nothing Then Return
If fields.ContainsKey(fAttr.Order) Then Throw New InvalidOperationException("duplicate order " & fAttr.Order)
fields.Add(fAttr.Order, New FieldDesc(mi))
End Sub
End Class
End Namespace

@ -0,0 +1,177 @@
#Region "Microsoft.VisualBasic::d7cbb4b586290172266459ddb63244f0, Data\BinaryData\BinaryData\XDR\EmitContexts\SwitchModel.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class SwitchModel
'
' Properties: Branches, SwitchField
'
' Function: BuildReadBranch, BuildReader, BuildWriteBranch, BuildWriter, Create
' ThrowUnexpectedValue
'
' Sub: AppendField
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Linq
Imports System.Reflection
Imports System.Collections.Generic
Imports System.Linq.Expressions
Namespace Xdr.EmitContexts
Public Class SwitchModel
Private _SwitchField As Xdr.EmitContexts.FieldDesc, _Branches As System.Collections.Generic.Dictionary(Of Object, Xdr.EmitContexts.FieldDesc)
Public Property SwitchField As FieldDesc
Get
Return _SwitchField
End Get
Private Set(value As FieldDesc)
_SwitchField = value
End Set
End Property
Public Property Branches As Dictionary(Of Object, FieldDesc)
Get
Return _Branches
End Get
Private Set(value As Dictionary(Of Object, FieldDesc))
_Branches = value
End Set
End Property
Public Function BuildWriter(targetType As Type) As [Delegate]
Dim pWriter = Expression.Parameter(GetType(Writer))
Dim pItem = Expression.Parameter(targetType)
Dim variables As List(Of ParameterExpression) = New List(Of ParameterExpression)()
Dim body As List(Of Expression) = New List(Of Expression)()
Dim [exit] As LabelTarget = Expression.Label()
Dim cases As List(Of SwitchCase) = New List(Of SwitchCase)()
For Each branch In Branches
cases.Add(BuildWriteBranch(branch.Key, branch.Value, pWriter, pItem, [exit]))
Next
body.Add(Expression.Switch(Expression.PropertyOrField(pItem, SwitchField.MInfo.Name), Expression.Block(ThrowUnexpectedValue(Expression.PropertyOrField(pItem, SwitchField.MInfo.Name))), cases.ToArray()))
body.Add(Expression.Label([exit]))
Dim block = Expression.Block(variables, body)
Return Expression.Lambda(CType(GetType(WriteOneDelegate(Of)).MakeGenericType(targetType), Type), CType(block, Expression), CType(pWriter, ParameterExpression), CType(pItem, ParameterExpression)).Compile()
End Function
Private Function BuildWriteBranch(key As Object, fieldDesc As FieldDesc, pWriter As Expression, pItem As Expression, [exit] As LabelTarget) As SwitchCase
Dim body As List(Of Expression) = New List(Of Expression)()
body.Add(SwitchField.BuildWriteOne(pWriter, key))
If fieldDesc IsNot Nothing Then body.Add(fieldDesc.BuildWrite(pWriter, pItem))
body.Add(Expression.Return([exit]))
Return Expression.SwitchCase(Expression.Block(body), Expression.Constant(key))
End Function
Public Function BuildReader(targetType As Type) As [Delegate]
Dim pReader = Expression.Parameter(GetType(Reader))
Dim variables As List(Of ParameterExpression) = New List(Of ParameterExpression)()
Dim body As List(Of Expression) = New List(Of Expression)()
Dim resultVar = Expression.Variable(targetType, "result")
variables.Add(resultVar)
Dim assign = Expression.Assign(resultVar, Expression.[New](targetType))
body.Add(assign)
body.Add(SwitchField.BuildAssign(SwitchField.BuildReadOne(pReader), resultVar))
Dim [exit] As LabelTarget = Expression.Label()
Dim cases As List(Of SwitchCase) = New List(Of SwitchCase)()
For Each branch In Branches
cases.Add(BuildReadBranch(branch.Key, branch.Value, resultVar, pReader, [exit]))
Next
body.Add(Expression.Switch(Expression.PropertyOrField(resultVar, SwitchField.MInfo.Name), Expression.Block(ThrowUnexpectedValue(Expression.PropertyOrField(resultVar, SwitchField.MInfo.Name))), cases.ToArray()))
body.Add(Expression.Label([exit]))
body.Add(resultVar)
Dim block = Expression.Block(variables, body)
Return Expression.Lambda(CType(GetType(ReadOneDelegate(Of)).MakeGenericType(targetType), Type), CType(block, Expression), pReader).Compile()
End Function
Private Shared Function ThrowUnexpectedValue(value As MemberExpression) As Expression
'throw new FormatException(string.Format("unexpected value: {0}", result.Type));
Dim strExpr = Expression.Call(GetType(String).GetMethod("Format", New Type() {GetType(String), GetType(Object)}), Expression.Constant("unexpected value: {0}"), Expression.Call(value, GetType(Object).GetMethod("ToString")))
Return Expression.Throw(Expression.[New](GetType(FormatException).GetConstructor(New Type() {GetType(String)}), strExpr))
End Function
Private Shared Function BuildReadBranch(key As Object, fieldDesc As FieldDesc, resultVar As ParameterExpression, pReader As Expression, [exit] As LabelTarget) As SwitchCase
Dim body As List(Of Expression) = New List(Of Expression)()
If fieldDesc IsNot Nothing Then body.Add(fieldDesc.BuildAssign(fieldDesc.BuildRead(pReader), resultVar))
body.Add(Expression.Break([exit]))
Return Expression.SwitchCase(Expression.Block(body), Expression.Constant(key))
End Function
Public Shared Function Create(t As Type) As SwitchModel
Dim model As SwitchModel = New SwitchModel()
model.Branches = New Dictionary(Of Object, FieldDesc)()
For Each f In t.GetFields().Where(Function(fi) fi.IsPublic AndAlso Not fi.IsStatic)
AppendField(model, f)
Next
For Each p In t.GetProperties().Where(Function(pi) pi.CanWrite AndAlso pi.CanRead)
AppendField(model, p)
Next
If model.SwitchField Is Nothing AndAlso model.Branches.Count = 0 Then Return Nothing
If model.SwitchField Is Nothing Then Throw New InvalidOperationException("switch attribute not found")
If model.Branches.Count <= 1 Then Throw New InvalidOperationException("requires more than two case attributes")
If model.Branches.Values.All(Function(f) f Is Nothing) Then Throw New InvalidOperationException("required no void case attribute")
Return model
End Function
Private Shared Sub AppendField(model As SwitchModel, mi As MemberInfo)
If mi.GetAttr(Of SwitchAttribute)() IsNot Nothing Then ' switch field
If model.SwitchField IsNot Nothing Then Throw New InvalidOperationException("duplicate switch attribute")
model.SwitchField = New FieldDesc(mi)
For Each cAttr In mi.GetAttrs(Of CaseAttribute)()
If model.Branches.ContainsKey(cAttr.Value) Then Throw New InvalidOperationException("duplicate case value " & cAttr.Value.ToString())
model.Branches.Add(cAttr.Value, Nothing)
Next ' case field
Else
For Each cAttr In mi.GetAttrs(Of CaseAttribute)()
If model.Branches.ContainsKey(cAttr.Value) Then Throw New InvalidOperationException("duplicate case value " & cAttr.Value.ToString())
model.Branches.Add(cAttr.Value, New FieldDesc(mi))
Next
End If
End Sub
End Class
End Namespace

@ -0,0 +1,93 @@
#Region "Microsoft.VisualBasic::4ada7b8a809323e160746d9883d0d5ec, Data\BinaryData\BinaryData\XDR\EnumHelper.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class EnumHelper
'
' Constructor: (+1 Overloads) Sub New
' Function: EnumToInt, IntToEnum
'
'
' /********************************************************************************/
#End Region
Namespace Xdr
Public Class EnumHelper(Of T As Structure)
Private Shared ReadOnly _enumMap As Dictionary(Of T, Integer)
Private Shared ReadOnly _intMap As Dictionary(Of Integer, T)
Shared Sub New()
Dim underType As Type = GetType(T).GetEnumUnderlyingType()
Dim conv As Func(Of T, Integer)
If underType Is GetType(Byte) Then
conv = Function(item) CByte(CType(item, ValueType))
ElseIf underType Is GetType(SByte) Then
conv = Function(item) CSByte(CType(item, ValueType))
ElseIf underType Is GetType(Short) Then
conv = Function(item) CShort(CType(item, ValueType))
ElseIf underType Is GetType(UShort) Then
conv = Function(item) CUShort(CType(item, ValueType))
ElseIf underType Is GetType(Integer) Then
conv = Function(item) CType(item, ValueType)
Else
Throw New NotSupportedException(String.Format("unsupported type {0}", GetType(T).FullName))
End If
_intMap = New Dictionary(Of Integer, T)()
_enumMap = New Dictionary(Of T, Integer)()
For Each item In [Enum].GetValues(GetType(T)).Cast(Of T)()
Dim exist As T = Nothing
Dim key = conv(item)
If Not _intMap.TryGetValue(key, exist) Then _intMap.Add(key, item)
If Not _enumMap.TryGetValue(item, key) Then _enumMap.Add(item, conv(item))
Next
End Sub
Public Shared Function IntToEnum(val As Integer) As T
Dim exist As T = Nothing
If _intMap.TryGetValue(val, exist) Then Return exist
Throw New InvalidCastException(String.Format("type `{0}' not contain {1}", GetType(T).FullName, val))
End Function
Public Shared Function EnumToInt(item As T) As Integer
Dim val As Integer
If _enumMap.TryGetValue(item, val) Then Return val
Throw New InvalidCastException(String.Format("enum {0} not contain value {1}", GetType(T).FullName, item))
End Function
End Class
End Namespace

@ -0,0 +1,88 @@
#Region "Microsoft.VisualBasic::3be836190f27e2289be3669c639d36b4, Data\BinaryData\BinaryData\XDR\MapException.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class MapException
'
' Constructor: (+3 Overloads) Sub New
' Function: ReadFix, ReadOne, ReadVar, WriteFix, WriteOne
' WriteVar
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Public Class MapException
Inherits SystemException
Public Sub New()
MyBase.New()
End Sub
Public Sub New(message As String)
MyBase.New(message)
End Sub
Public Sub New(message As String, innerEx As Exception)
MyBase.New(message, innerEx)
End Sub
Public Shared Function ReadOne(type As Type, innerEx As Exception) As MapException
Return New MapException(String.Format("can't read an instance of `{0}'", type.FullName), innerEx)
End Function
Friend Shared Function ReadVar(type As Type, max As UInteger, innerEx As SystemException) As Exception
Return New MapException(String.Format("can't read collection of `{0}' (length <= {1})", type.FullName, max), innerEx)
End Function
Friend Shared Function ReadFix(type As Type, len As UInteger, innerEx As SystemException) As Exception
Return New MapException(String.Format("can't read collection of `{0}' (length = {1})", type.FullName, len), innerEx)
End Function
Friend Shared Function WriteOne(type As Type, innerEx As SystemException) As Exception
Return New MapException(String.Format("can't write an instance of `{0}'", type.FullName), innerEx)
End Function
Friend Shared Function WriteFix(type As Type, len As UInteger, innerEx As SystemException) As Exception
Return New MapException(String.Format("can't write collection of `{0}' (length = {1})", type.FullName, len), innerEx)
End Function
Friend Shared Function WriteVar(type As Type, max As UInteger, innerEx As SystemException) As Exception
Return New MapException(String.Format("can't write collection of `{0}' (length <= {1})", type.FullName, max), innerEx)
End Function
End Class
End Namespace

@ -0,0 +1,13 @@
'------------------------------------------------------------------------------
' <auto-generated>
'
' :4.0.30319.42000
'
'
'
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>1</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>

@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
'
'
'
'
<Assembly: AssemblyTitle("XDRStream")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("XDRStream")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
' COM GUID typelib ID
<Assembly: Guid("87aeea11-7ada-4e56-bcfd-e4d3c68426c2")>
' :
'
'
'
'
'
'
'使
'使 "*":
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

@ -0,0 +1,63 @@
'------------------------------------------------------------------------------
' <auto-generated>
'
' :4.0.30319.42000
'
'
'
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
' StronglyTypedResourceBuilder
' ResGen Visual Studio
' .ResX ResGen
'( /str ) VS
'''<summary>
'''
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' 使 ResourceManager
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("XDR.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' 线 CurrentUICulture
''' 使
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,73 @@
'------------------------------------------------------------------------------
' <auto-generated>
'
' :4.0.30319.42000
'
'
'
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings 自动保存功能"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.XDR.My.MySettings
Get
Return Global.XDR.My.MySettings.Default
End Get
End Property
End Module
End Namespace

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

@ -0,0 +1,50 @@
#Region "Microsoft.VisualBasic::0b28834e300186ade27b116682f21ce1, Data\BinaryData\BinaryData\XDR\NamespaceDoc.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Module NamespaceDoc
'
'
'
'
' /********************************************************************************/
#End Region
Namespace Xdr
''' <summary>
''' https://github.com/ExM/OncRpc
''' </summary>
Module NamespaceDoc
End Module
End Namespace

@ -0,0 +1,54 @@
#Region "Microsoft.VisualBasic::c443b173f450c3542b99627efe067598, Data\BinaryData\BinaryData\XDR\OpaqueType.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Enum OpaqueType
'
'
'
'
'
'
'
' /********************************************************************************/
#End Region
Namespace Xdr
Public Enum OpaqueType
One = 0
Fix = 1
Var = 2
End Enum
End Namespace

@ -0,0 +1,100 @@
#Region "Microsoft.VisualBasic::cab6f19b2cac9246bf0cc15b0992f8fc, Data\BinaryData\BinaryData\XDR\Reading\ReadBuilder.EmitDynReadMapper.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class ReadBuilder
'
' Function: DefineCacheField, EmitDynReadMapper
'
' Sub: EmitInitField, EmitOverride_GetCacheType
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Namespace Xdr
Public NotInheritable Partial Class ReadBuilder
Private Function EmitDynReadMapper() As Type
Dim typeBuilder = _modBuilder.DefineType("DynReadMapper", TypeAttributes.NotPublic Or TypeAttributes.Class Or TypeAttributes.Sealed, GetType(ReadMapper))
Dim fb_oneCacheType = DefineCacheField(typeBuilder, "_oneCacheType")
Dim fb_fixCacheType = DefineCacheField(typeBuilder, "_fixCacheType")
Dim fb_varCacheType = DefineCacheField(typeBuilder, "_varCacheType")
Dim ctor = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, New Type(-1) {})
Dim ilCtor As ILGenerator = ctor.GetILGenerator()
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Call, GetType(ReadMapper).GetConstructor(BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Type(-1) {}, Nothing))
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Ldftn, GetType(ReadMapper).GetMethod("AppendBuildRequest", BindingFlags.NonPublic Or BindingFlags.Instance))
ilCtor.Emit(OpCodes.Newobj, GetType(Action(Of Type, OpaqueType)).GetConstructor(New Type() {GetType(Object), GetType(IntPtr)}))
ilCtor.Emit(OpCodes.Stsfld, _buildBinderDescription.BuildRequest)
EmitInitField(ilCtor, fb_oneCacheType, _oneCacheDescription.Result)
EmitInitField(ilCtor, fb_fixCacheType, _fixCacheDescription.Result)
EmitInitField(ilCtor, fb_varCacheType, _varCacheDescription.Result)
' run init
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Call, GetType(ReadMapper).GetMethod("Init", BindingFlags.Instance Or BindingFlags.NonPublic))
ilCtor.Emit(OpCodes.Ret)
EmitOverride_GetCacheType(typeBuilder, "GetOneCacheType", fb_oneCacheType)
EmitOverride_GetCacheType(typeBuilder, "GetFixCacheType", fb_fixCacheType)
EmitOverride_GetCacheType(typeBuilder, "GetVarCacheType", fb_varCacheType)
Return typeBuilder.CreateType()
End Function
Private Shared Function DefineCacheField(typeBuilder As TypeBuilder, name As String) As FieldBuilder
Return typeBuilder.DefineField(name, GetType(Type), FieldAttributes.Private Or FieldAttributes.InitOnly)
End Function
Private Shared Sub EmitInitField(il As ILGenerator, fb As FieldBuilder, type As Type)
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Ldtoken, type)
il.Emit(OpCodes.Call, GetType(Type).GetMethod("GetTypeFromHandle"))
il.Emit(OpCodes.Stfld, fb)
End Sub
Private Sub EmitOverride_GetCacheType(typeBuilder As TypeBuilder, overrideName As String, fb_cacheType As FieldBuilder)
Dim mb = typeBuilder.DefineMethod(overrideName, MethodAttributes.Family Or MethodAttributes.Virtual)
mb.SetReturnType(GetType(Type))
typeBuilder.DefineMethodOverride(mb, GetType(ReadMapper).GetMethod(overrideName, BindingFlags.NonPublic Or BindingFlags.Instance))
Dim il As ILGenerator = mb.GetILGenerator()
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Ldfld, fb_cacheType)
il.Emit(OpCodes.Ret)
End Sub
End Class
End Namespace

@ -0,0 +1,111 @@
#Region "Microsoft.VisualBasic::e7ca7ca1c9f2cd669436be7e5ed4e188, Data\BinaryData\BinaryData\XDR\Reading\ReadBuilder.EmitDynReader.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class ReadBuilder
'
' Function: EmitDynReader
'
' Sub: EmitOverride_ReadTMany, EmitOverride_ReadTOne
'
'
' /********************************************************************************/
#End Region
Imports System.Reflection
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic.Data.IO.Xdr.Emit
Namespace Xdr
Public NotInheritable Partial Class ReadBuilder
Private Function EmitDynReader() As Type
Dim typeBuilder = _modBuilder.DefineType("DynReader", TypeAttributes.NotPublic Or TypeAttributes.Class Or TypeAttributes.Sealed, GetType(Reader))
Dim fb_mapperInstance = typeBuilder.DefineField("Mapper", GetType(ReadMapper), FieldAttributes.Public Or FieldAttributes.Static)
Dim ctor = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, New Type() {GetType(IByteReader)})
Dim ilCtor As ILGenerator = ctor.GetILGenerator()
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Ldarg_1) ' reader
ilCtor.Emit(OpCodes.Call, GetType(Reader).GetConstructor(BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Type() {GetType(IByteReader)}, Nothing))
ilCtor.Emit(OpCodes.Ret)
EmitOverride_ReadTOne(typeBuilder, fb_mapperInstance)
EmitOverride_ReadTMany(typeBuilder, "CacheReadFix", _fixCacheDescription, fb_mapperInstance)
EmitOverride_ReadTMany(typeBuilder, "CacheReadVar", _varCacheDescription, fb_mapperInstance)
Return typeBuilder.CreateType()
End Function
Private Sub EmitOverride_ReadTOne(typeBuilder As TypeBuilder, mapperInstance As FieldInfo)
Dim miDeclaration = GetType(Reader).GetMethod("CacheRead", BindingFlags.NonPublic Or BindingFlags.Instance)
Dim mb = typeBuilder.DefineMethod("CacheRead", MethodAttributes.Family Or MethodAttributes.Virtual)
Dim genTypeParam = mb.DefineGenericParameters("T")(0)
mb.SetReturnType(genTypeParam)
typeBuilder.DefineMethodOverride(mb, miDeclaration)
Dim fi = TypeBuilder.GetField(_oneCacheDescription.Result.MakeGenericType(genTypeParam), _oneCacheDescription.Result.GetField("Instance"))
Dim il As ILGenerator = mb.GetILGenerator()
Dim noBuild As Label = il.DefineLabel()
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Brtrue, noBuild)
il.Emit(OpCodes.Ldsfld, mapperInstance)
il.Emit(OpCodes.Call, GetType(ReadMapper).GetMethod("BuildCaches", BindingFlags.Public Or BindingFlags.Instance))
il.MarkLabel(noBuild)
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Ldarg_0) ' this reader
Dim miInvoke = TypeBuilder.GetMethod(GetType(ReadOneDelegate(Of)).MakeGenericType(genTypeParam), GetType(ReadOneDelegate(Of)).GetMethod("Invoke"))
il.Emit(OpCodes.Callvirt, miInvoke)
il.Emit(OpCodes.Ret)
End Sub
Private Shared Sub EmitOverride_ReadTMany(tb As TypeBuilder, name As String, readManyCacheDesc As StaticCacheDescription, mapperInstance As FieldInfo)
Dim miDeclaration = GetType(Reader).GetMethod(name, BindingFlags.NonPublic Or BindingFlags.Instance)
Dim mb = tb.DefineMethod(name, MethodAttributes.Family Or MethodAttributes.Virtual)
Dim genTypeParam = mb.DefineGenericParameters("T")(0)
mb.SetReturnType(genTypeParam)
mb.SetParameters(GetType(UInteger))
tb.DefineMethodOverride(mb, miDeclaration)
Dim fi = readManyCacheDesc.Instance(genTypeParam)
Dim il As ILGenerator = mb.GetILGenerator()
Dim noBuild As Label = il.DefineLabel()
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Brtrue, noBuild)
il.Emit(OpCodes.Ldsfld, mapperInstance)
il.Emit(OpCodes.Call, GetType(ReadMapper).GetMethod("BuildCaches", BindingFlags.Public Or BindingFlags.Instance))
il.MarkLabel(noBuild)
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Ldarg_0) ' this reader
il.Emit(OpCodes.Ldarg_1) ' len or max
Dim miInvoke = TypeBuilder.GetMethod(GetType(ReadManyDelegate(Of)).MakeGenericType(genTypeParam), GetType(ReadManyDelegate(Of)).GetMethod("Invoke"))
il.Emit(OpCodes.Callvirt, miInvoke)
il.Emit(OpCodes.Ret)
End Sub
End Class
End Namespace

@ -0,0 +1,104 @@
#Region "Microsoft.VisualBasic::04495aeb2ec95bc163bff7ad36f3acb8, Data\BinaryData\BinaryData\XDR\Reading\ReadBuilder.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class ReadBuilder
'
' Constructor: (+1 Overloads) Sub New
' Function: Create, EmitCreater, Map, MapFix, MapVar
'
'
' /********************************************************************************/
#End Region
Imports System.Reflection
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic.Data.IO.Xdr.Emit
Namespace Xdr
Public NotInheritable Partial Class ReadBuilder
Private _rm As ReadMapper
Private _creater As Func(Of IByteReader, Reader)
Private _modBuilder As ModuleBuilder
Private _buildBinderDescription As BuildBinderDescription
Private _oneCacheDescription As StaticCacheDescription
Private _varCacheDescription As StaticCacheDescription
Private _fixCacheDescription As StaticCacheDescription
Public Sub New()
Dim name = "DynamicXdrReadMapper"
Dim asmName As AssemblyName = New AssemblyName(name)
Dim asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave)
_modBuilder = asmBuilder.DefineDynamicModule(name & ".dll", name & ".dll")
_buildBinderDescription = New BuildBinderDescription(_modBuilder)
_oneCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "OneCache", True, OpaqueType.One)
_fixCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "FixCache", True, OpaqueType.Fix)
_varCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "VarCache", True, OpaqueType.Var)
Dim dynReadMapperType As Type = EmitDynReadMapper()
_rm = CType(Activator.CreateInstance(dynReadMapperType), ReadMapper)
Dim dynReaderType As Type = EmitDynReader()
Dim mapperInstance = dynReaderType.GetField("Mapper", BindingFlags.Public Or BindingFlags.Static)
mapperInstance.SetValue(Nothing, _rm)
_creater = EmitCreater(dynReaderType.GetConstructor(New Type() {GetType(IByteReader)}))
End Sub
Private Shared Function EmitCreater(ci As ConstructorInfo) As Func(Of IByteReader, Reader)
Dim dm = New DynamicMethod("DynCreateReader", GetType(Reader), New Type() {GetType(IByteReader)}, GetType(ReadBuilder), True)
Dim il = dm.GetILGenerator()
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Newobj, ci)
il.Emit(OpCodes.Ret)
Return CType(dm.CreateDelegate(GetType(Func(Of IByteReader, Reader))), Func(Of IByteReader, Reader))
End Function
Public Function Map(Of T)(reader As ReadOneDelegate(Of T)) As ReadBuilder
_rm.AppendMethod(GetType(T), OpaqueType.One, reader)
Return Me
End Function
Public Function MapFix(Of T)(reader As ReadManyDelegate(Of T)) As ReadBuilder
_rm.AppendMethod(GetType(T), OpaqueType.Fix, reader)
Return Me
End Function
Public Function MapVar(Of T)(reader As ReadManyDelegate(Of T)) As ReadBuilder
_rm.AppendMethod(GetType(T), OpaqueType.Var, reader)
Return Me
End Function
Public Function Create(reader As IByteReader) As Reader
Return _creater(reader)
End Function
End Class
End Namespace

@ -0,0 +1,341 @@
#Region "Microsoft.VisualBasic::ff85d8c11739908dca1c3faff8baa77c, Data\BinaryData\BinaryData\XDR\Reading\ReadMapper.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class ReadMapper
'
' Constructor: (+1 Overloads) Sub New
'
' Function: BuildDelegate, CheckedReadLength, CreateEnumReader, CreateFixArrayReader, CreateFixListReader
' CreateLinkedListReader, CreateNullableReader, CreateVarArrayReader, CreateVarListReader, EnumRead
' GetCacheType, ReadBool, ReadFixArray, ReadFixList, ReadFixOpaque
' ReadLinkedList, ReadNullable, ReadOption, ReadString, ReadVarArray
' ReadVarList, ReadVarOpaque
'
' Sub: AppendBuildRequest, AppendMethod, BuildCaches, Init, LockedAppendMethod
' SetFix, SetOne, SetVar
'
'
' /********************************************************************************/
#End Region
Imports System.Text
Imports Microsoft.VisualBasic.Data.IO.Xdr.EmitContexts
Namespace Xdr
Public MustInherit Class ReadMapper
Private _sync As Object = New Object()
Private _dependencySync As Object = New Object()
Private _dependency As Queue(Of BuildRequest) = New Queue(Of BuildRequest)()
Private _builders As Dictionary(Of OpaqueType, Func(Of Type, [Delegate])()) = New Dictionary(Of OpaqueType, Func(Of Type, [Delegate])())()
Protected Sub New()
End Sub
Protected Sub Init()
Call SetOne(Function(r) New Void())
SetOne(Function(r) DecodeInt32(r.ByteReader))
SetOne(Function(r) DecodeUInt32(r.ByteReader))
SetOne(Function(r) DecodeInt64(r.ByteReader))
SetOne(Function(r) DecodeUInt64(r.ByteReader))
SetOne(Of Single)(Function(r) XdrEncoding.DecodeSingle(r.ByteReader))
SetOne(Of Double)(Function(r) XdrEncoding.DecodeDouble(r.ByteReader))
Call SetOne(New ReadOneDelegate(Of Boolean)(AddressOf ReadBool))
Call SetFix(New ReadManyDelegate(Of Byte())(AddressOf ReadFixOpaque))
Call SetVar(New ReadManyDelegate(Of Byte())(AddressOf ReadVarOpaque))
Call SetVar(New ReadManyDelegate(Of String)(AddressOf ReadString))
_builders.Add(OpaqueType.One, New Func(Of Type, [Delegate])() {AddressOf CreateEnumReader, AddressOf CreateNullableReader, AddressOf CreateLinkedListReader, AddressOf GetReader})
_builders.Add(OpaqueType.Fix, New Func(Of Type, [Delegate])() {AddressOf CreateFixArrayReader, AddressOf CreateFixListReader})
_builders.Add(OpaqueType.Var, New Func(Of Type, [Delegate])() {AddressOf CreateVarArrayReader, AddressOf CreateVarListReader})
End Sub
Private Shared Function ReadBool(r As Reader) As Boolean
Dim val = DecodeUInt32(r.ByteReader)
If val = 0 Then Return False
If val = 1 Then Return True
Throw New InvalidOperationException("unexpected value: " & val.ToString())
End Function
Private Shared Function ReadFixOpaque(r As Reader, len As UInteger) As Byte()
Dim result = r.ByteReader.Read(len)
Dim tail = len Mod 4UI
If tail <> 0 Then r.ByteReader.Read(4UI - tail)
Return result
End Function
Private Shared Function ReadVarOpaque(r As Reader, max As UInteger) As Byte()
Return ReadFixOpaque(r, CheckedReadLength(r, max))
End Function
Private Shared Function ReadString(r As Reader, max As UInteger) As String
Return Encoding.ASCII.GetString(ReadVarOpaque(r, max))
End Function
Private Function BuildDelegate(methodType As OpaqueType, targetType As Type) As [Delegate]
Dim wrap As Exception = Nothing
Try
For Each build In _builders(methodType)
Dim result = build(targetType)
If result IsNot Nothing Then Return result
Next
Catch ex As Exception
wrap = New InvalidOperationException(String.Format("impossible to create a {0} method type for `{1}'", methodType, targetType.FullName), ex)
End Try
If wrap Is Nothing Then wrap = New NotImplementedException(String.Format("unknown type `{0}' in {1} method type", targetType.FullName, methodType))
If methodType = OpaqueType.One Then
Return ReadOneDelegate(targetType, wrap)
Else
Return ReadManyDelegate(targetType, wrap)
End If
End Function
Protected Sub SetOne(Of T)(method As ReadOneDelegate(Of T))
GetOneCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Protected Sub SetFix(Of T)(method As ReadManyDelegate(Of T))
GetFixCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Protected Sub SetVar(Of T)(method As ReadManyDelegate(Of T))
GetVarCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Private Function GetCacheType(methodType As OpaqueType) As Type
Select Case methodType
Case OpaqueType.One
Return GetOneCacheType()
Case OpaqueType.Fix
Return GetFixCacheType()
Case OpaqueType.Var
Return GetVarCacheType()
Case Else
Throw New NotImplementedException("unknown opaque type")
End Select
End Function
Protected MustOverride Function GetOneCacheType() As Type
Protected MustOverride Function GetFixCacheType() As Type
Protected MustOverride Function GetVarCacheType() As Type
Public Sub BuildCaches()
SyncLock _sync
While True
Dim bReq As BuildRequest = Nothing
SyncLock _dependencySync
If _dependency.Count <> 0 Then bReq = _dependency.Dequeue()
End SyncLock
If bReq Is Nothing Then Return
Dim fi = GetCacheType(bReq.Method).MakeGenericType(bReq.TargetType).GetField("Instance")
If fi.GetValue(Nothing) Is Nothing Then fi.SetValue(Nothing, BuildDelegate(bReq.Method, bReq.TargetType))
End While
End SyncLock
End Sub
Friend Sub AppendMethod(targetType As Type, methodType As OpaqueType, method As [Delegate])
SyncLock _sync
LockedAppendMethod(targetType, methodType, method)
End SyncLock
End Sub
Private Sub LockedAppendMethod(targetType As Type, methodType As OpaqueType, method As [Delegate])
Dim fi = GetCacheType(methodType).MakeGenericType(targetType).GetField("Instance")
If fi.GetValue(Nothing) IsNot Nothing Then Throw New InvalidOperationException("type already mapped")
fi.SetValue(Nothing, method)
End Sub
Protected Sub AppendBuildRequest(targetType As Type, methodType As OpaqueType)
SyncLock _dependencySync
_dependency.Enqueue(New BuildRequest With {
.TargetType = targetType,
.Method = methodType
})
End SyncLock
End Sub
Public Shared Function CreateFixArrayReader(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ArraySubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadFixArray").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Function ReadFixArray(Of T)(r As Reader, len As UInteger) As T()
Dim i As UInteger = 0
Try
Dim result = New T(len - 1) {}
While i < len
result(i) = r.Read(Of T)()
i += 1
End While
Return result
Catch ex As Exception
Throw New FormatException(String.Format("cant't read {0} item", i), ex)
End Try
End Function
Public Shared Function CreateLinkedListReader(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadLinkedList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadOneDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Function ReadLinkedList(Of T)(r As Reader) As List(Of T)
Dim result As List(Of T) = New List(Of T)()
While ReadOption(r)
Try
result.Add(r.Read(Of T)())
Catch ex As Exception
Throw New FormatException(String.Format("cant't read {0} item", result.Count + 1), ex)
End Try
End While
Return result
End Function
Public Shared Function CreateFixListReader(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadFixList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Function ReadFixList(Of T)(r As Reader, len As UInteger) As List(Of T)
Dim i As UInteger = 0
Try
Dim result As List(Of T) = New List(Of T)()
While i < len
result.Add(r.Read(Of T)())
i += 1
End While
Return result
Catch ex As Exception
Throw New FormatException(String.Format("cant't read {0} item", i), ex)
End Try
End Function
Public Shared Function CreateEnumReader(targetType As Type) As [Delegate]
If Not targetType.IsEnum Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("EnumRead").MakeGenericMethod(targetType)
Return [Delegate].CreateDelegate(GetType(ReadOneDelegate(Of)).MakeGenericType(targetType), mi)
End Function
Public Shared Function EnumRead(Of T As Structure)(reader As Reader) As T
Return EnumHelper(Of T).IntToEnum(reader.Read(Of Integer)())
End Function
Public Shared Function CreateNullableReader(targetType As Type) As [Delegate]
Dim itemType As Type = targetType.NullableSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadNullable").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadOneDelegate(Of)).MakeGenericType(targetType), mi)
End Function
Public Shared Function ReadNullable(Of T As Structure)(reader As Reader) As T?
Dim exist = ReadOption(reader)
Try
If exist Then
Return reader.Read(Of T)()
Else
Return Nothing
End If
Catch ex As SystemException
Throw New FormatException("cant't read 'value'", ex)
End Try
End Function
Private Shared Function ReadOption(reader As Reader) As Boolean
Try
Return reader.Read(Of Boolean)()
Catch ex As SystemException
Throw New FormatException("cant't read 'option'", ex)
End Try
End Function
Public Shared Function CreateVarArrayReader(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ArraySubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadVarArray").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Function ReadVarArray(Of T)(r As Reader, max As UInteger) As T()
Return ReadFixArray(Of T)(r, CheckedReadLength(r, max))
End Function
Public Shared Function CreateVarListReader(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(ReadMapper).GetMethod("ReadVarList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(ReadManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Function ReadVarList(Of T)(r As Reader, max As UInteger) As List(Of T)
Return ReadFixList(Of T)(r, CheckedReadLength(r, max))
End Function
Private Shared Function CheckedReadLength(r As Reader, max As UInteger) As UInteger
Dim len As UInteger
Try
len = DecodeUInt32(r.ByteReader)
Catch ex As SystemException
Throw New FormatException("cant't read 'length'", ex)
End Try
If len > max Then Throw New FormatException("unexpected length: " & len.ToString())
Return len
End Function
End Class
End Namespace

@ -0,0 +1,93 @@
#Region "Microsoft.VisualBasic::3271e9eeeb902e1fdc2ec9be3a8c3df6, Data\BinaryData\BinaryData\XDR\Reading\Reader.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class Reader
'
' Constructor: (+1 Overloads) Sub New
' Function: Read, ReadFix, ReadOption, ReadVar
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Public MustInherit Class Reader
Public ReadOnly ByteReader As IByteReader
Protected Sub New(reader As IByteReader)
ByteReader = reader
End Sub
Public Function Read(Of T)() As T
Try
Return CacheRead(Of T)()
Catch ex As SystemException
Throw MapException.ReadOne(GetType(T), ex)
End Try
End Function
Protected MustOverride Function CacheRead(Of T)() As T
Public Function ReadFix(Of T)(len As UInteger) As T
Try
Return CacheReadFix(Of T)(len)
Catch ex As SystemException
Throw MapException.ReadFix(GetType(T), len, ex)
End Try
End Function
Protected MustOverride Function CacheReadFix(Of T)(len As UInteger) As T
Public Function ReadVar(Of T)(max As UInteger) As T
Try
Return CacheReadVar(Of T)(max)
Catch ex As SystemException
Throw MapException.ReadVar(GetType(T), max, ex)
End Try
End Function
Protected MustOverride Function CacheReadVar(Of T)(max As UInteger) As T
Public Function ReadOption(Of T As Class)() As T
If Read(Of Boolean)() Then
Return Read(Of T)()
Else
Return Nothing
End If
End Function
End Class
End Namespace

@ -0,0 +1,85 @@
#Region "Microsoft.VisualBasic::2f151b3ffd00dcc8fdb8a017dd0a15ba, Data\BinaryData\BinaryData\XDR\TypeExtensions.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Module TypeExtensions
'
' Function: ArraySubType, GetAttr, GetAttrs, ListSubType, NullableSubType
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Reflection
Imports System.Runtime.CompilerServices
Namespace Xdr
Public Module TypeExtensions
<Extension()>
Public Function GetAttr(Of T As Attribute)(mi As MemberInfo) As T
Return TryCast(mi.GetCustomAttributes(GetType(T), True).FirstOrDefault(), T)
End Function
<Extension()>
Public Function GetAttrs(Of T As Attribute)(mi As MemberInfo) As IEnumerable(Of T)
Return mi.GetCustomAttributes(GetType(T), True).Cast(Of T)()
End Function
<Extension()>
Public Function NullableSubType(type As Type) As Type
If Not type.IsGenericType Then Return Nothing
If type.GetGenericTypeDefinition() IsNot GetType(Nullable(Of)) Then Return Nothing
Return type.GetGenericArguments()(0)
End Function
<Extension()>
Public Function ArraySubType(type As Type) As Type
If Not type.HasElementType Then Return Nothing
Dim itemType As Type = type.GetElementType()
If itemType Is Nothing OrElse itemType.MakeArrayType() IsNot type Then Return Nothing
Return itemType
End Function
<Extension()>
Public Function ListSubType(type As Type) As Type
If Not type.IsGenericType Then Return Nothing
Dim genericType As Type = type.GetGenericTypeDefinition()
If genericType IsNot GetType(List(Of)) Then Return Nothing
Return type.GetGenericArguments()(0)
End Function
End Module
End Namespace

@ -0,0 +1,52 @@
#Region "Microsoft.VisualBasic::2355bf29771a422fab3f38724ab559bd, Data\BinaryData\BinaryData\XDR\Void.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Structure Void
'
'
'
'
' /********************************************************************************/
#End Region
Namespace Xdr
''' <summary>
''' Void
''' http://tools.ietf.org/html/rfc4506#section-4.16
''' </summary>
Public Structure Void
End Structure
End Namespace

@ -0,0 +1,100 @@
#Region "Microsoft.VisualBasic::04e4e0fa9494d6e2b4dd89c54241251e, Data\BinaryData\BinaryData\XDR\Writing\WriteBuilder.EmitDynWriteMapper.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class WriteBuilder
'
' Function: DefineCacheField, EmitDynWriteMapper
'
' Sub: EmitInitField, EmitOverride_GetCacheType
'
'
' /********************************************************************************/
#End Region
Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Namespace Xdr
Public NotInheritable Partial Class WriteBuilder
Private Function EmitDynWriteMapper() As Type
Dim typeBuilder = _modBuilder.DefineType("DynWriteMapper", TypeAttributes.NotPublic Or TypeAttributes.Class Or TypeAttributes.Sealed, GetType(WriteMapper))
Dim fb_oneCacheType = DefineCacheField(typeBuilder, "_oneCacheType")
Dim fb_fixCacheType = DefineCacheField(typeBuilder, "_fixCacheType")
Dim fb_varCacheType = DefineCacheField(typeBuilder, "_varCacheType")
Dim ctor = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, New Type(-1) {})
Dim ilCtor As ILGenerator = ctor.GetILGenerator()
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Call, GetType(WriteMapper).GetConstructor(BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Type(-1) {}, Nothing))
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Ldftn, GetType(WriteMapper).GetMethod("AppendBuildRequest", BindingFlags.NonPublic Or BindingFlags.Instance))
ilCtor.Emit(OpCodes.Newobj, GetType(Action(Of Type, OpaqueType)).GetConstructor(New Type() {GetType(Object), GetType(IntPtr)}))
ilCtor.Emit(OpCodes.Stsfld, _buildBinderDescription.BuildRequest)
EmitInitField(ilCtor, fb_oneCacheType, _oneCacheDescription.Result)
EmitInitField(ilCtor, fb_fixCacheType, _fixCacheDescription.Result)
EmitInitField(ilCtor, fb_varCacheType, _varCacheDescription.Result)
' run init
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Call, GetType(WriteMapper).GetMethod("Init", BindingFlags.Instance Or BindingFlags.NonPublic))
ilCtor.Emit(OpCodes.Ret)
EmitOverride_GetCacheType(typeBuilder, "GetOneCacheType", fb_oneCacheType)
EmitOverride_GetCacheType(typeBuilder, "GetFixCacheType", fb_fixCacheType)
EmitOverride_GetCacheType(typeBuilder, "GetVarCacheType", fb_varCacheType)
Return typeBuilder.CreateType()
End Function
Private Shared Function DefineCacheField(typeBuilder As TypeBuilder, name As String) As FieldBuilder
Return typeBuilder.DefineField(name, GetType(Type), FieldAttributes.Private Or FieldAttributes.InitOnly)
End Function
Private Shared Sub EmitInitField(il As ILGenerator, fb As FieldBuilder, type As Type)
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Ldtoken, type)
il.Emit(OpCodes.Call, GetType(Type).GetMethod("GetTypeFromHandle"))
il.Emit(OpCodes.Stfld, fb)
End Sub
Private Sub EmitOverride_GetCacheType(typeBuilder As TypeBuilder, overrideName As String, fb_cacheType As FieldBuilder)
Dim mb = typeBuilder.DefineMethod(overrideName, MethodAttributes.Family Or MethodAttributes.Virtual)
mb.SetReturnType(GetType(Type))
typeBuilder.DefineMethodOverride(mb, GetType(WriteMapper).GetMethod(overrideName, BindingFlags.NonPublic Or BindingFlags.Instance))
Dim il As ILGenerator = mb.GetILGenerator()
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Ldfld, fb_cacheType)
il.Emit(OpCodes.Ret)
End Sub
End Class
End Namespace

@ -0,0 +1,114 @@
#Region "Microsoft.VisualBasic::af1a372ac5207d90b3e37baaaa9079b6, Data\BinaryData\BinaryData\XDR\Writing\WriteBuilder.EmitDynWriter.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class WriteBuilder
'
' Function: EmitDynWriter
'
' Sub: EmitOverride_WriteTMany, EmitOverride_WriteTOne
'
'
' /********************************************************************************/
#End Region
Imports System.Reflection
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic.Data.IO.Xdr.Emit
Namespace Xdr
Partial Public NotInheritable Class WriteBuilder
Private Function EmitDynWriter() As Type
Dim typeBuilder = _modBuilder.DefineType("DynWriter", TypeAttributes.NotPublic Or TypeAttributes.Class Or TypeAttributes.Sealed, GetType(Writer))
Dim fb_mapperInstance = typeBuilder.DefineField("Mapper", GetType(WriteMapper), FieldAttributes.Public Or FieldAttributes.Static)
Dim ctor = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, New Type() {GetType(IByteWriter)})
Dim ilCtor As ILGenerator = ctor.GetILGenerator()
ilCtor.Emit(OpCodes.Ldarg_0)
ilCtor.Emit(OpCodes.Ldarg_1) ' reader
ilCtor.Emit(OpCodes.Call, GetType(Writer).GetConstructor(BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Type() {GetType(IByteWriter)}, Nothing))
ilCtor.Emit(OpCodes.Ret)
EmitOverride_WriteTOne(typeBuilder, fb_mapperInstance)
EmitOverride_WriteTMany(typeBuilder, "CacheWriteFix", _fixCacheDescription, fb_mapperInstance)
EmitOverride_WriteTMany(typeBuilder, "CacheWriteVar", _varCacheDescription, fb_mapperInstance)
Return typeBuilder.CreateType()
End Function
Private Sub EmitOverride_WriteTOne(typeBuilder As TypeBuilder, mapperInstance As FieldInfo)
Dim miDeclaration = GetType(Writer).GetMethod("CacheWrite", BindingFlags.NonPublic Or BindingFlags.Instance)
Dim mb = typeBuilder.DefineMethod("CacheWrite", MethodAttributes.Family Or MethodAttributes.Virtual)
Dim genTypeParam = mb.DefineGenericParameters("T")(0)
mb.SetReturnType(Nothing)
mb.SetParameters(genTypeParam)
typeBuilder.DefineMethodOverride(mb, miDeclaration)
Dim fi = TypeBuilder.GetField(_oneCacheDescription.Result.MakeGenericType(genTypeParam), _oneCacheDescription.Result.GetField("Instance"))
Dim il As ILGenerator = mb.GetILGenerator()
Dim noBuild As Label = il.DefineLabel()
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Brtrue, noBuild)
il.Emit(OpCodes.Ldsfld, mapperInstance)
il.Emit(OpCodes.Call, GetType(WriteMapper).GetMethod("BuildCaches", BindingFlags.Public Or BindingFlags.Instance))
il.MarkLabel(noBuild)
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Ldarg_0) ' this writer
il.Emit(OpCodes.Ldarg_1) ' item
Dim miInvoke = TypeBuilder.GetMethod(GetType(WriteOneDelegate(Of)).MakeGenericType(genTypeParam), GetType(WriteOneDelegate(Of)).GetMethod("Invoke"))
il.Emit(OpCodes.Callvirt, miInvoke)
il.Emit(OpCodes.Ret)
End Sub
Private Shared Sub EmitOverride_WriteTMany(tb As TypeBuilder, name As String, manyCacheDesc As StaticCacheDescription, mapperInstance As FieldInfo)
Dim miDeclaration = GetType(Writer).GetMethod(name, BindingFlags.NonPublic Or BindingFlags.Instance)
Dim mb = tb.DefineMethod(name, MethodAttributes.Family Or MethodAttributes.Virtual)
Dim genTypeParam = mb.DefineGenericParameters("T")(0)
mb.SetReturnType(Nothing)
mb.SetParameters(GetType(UInteger), genTypeParam)
tb.DefineMethodOverride(mb, miDeclaration)
Dim fi = manyCacheDesc.Instance(genTypeParam)
Dim il As ILGenerator = mb.GetILGenerator()
Dim noBuild As Label = il.DefineLabel()
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Brtrue, noBuild)
il.Emit(OpCodes.Ldsfld, mapperInstance)
il.Emit(OpCodes.Call, GetType(WriteMapper).GetMethod("BuildCaches", BindingFlags.Public Or BindingFlags.Instance))
il.MarkLabel(noBuild)
il.Emit(OpCodes.Ldsfld, fi)
il.Emit(OpCodes.Ldarg_0) ' this writer
il.Emit(OpCodes.Ldarg_1) ' len or max
il.Emit(OpCodes.Ldarg_2) ' item
Dim miInvoke = TypeBuilder.GetMethod(GetType(WriteManyDelegate(Of)).MakeGenericType(genTypeParam), GetType(WriteManyDelegate(Of)).GetMethod("Invoke"))
il.Emit(OpCodes.Callvirt, miInvoke)
il.Emit(OpCodes.Ret)
End Sub
End Class
End Namespace

@ -0,0 +1,104 @@
#Region "Microsoft.VisualBasic::e686ed45971518f5d34a3e3fd2cb38b7, Data\BinaryData\BinaryData\XDR\Writing\WriteBuilder.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class WriteBuilder
'
' Constructor: (+1 Overloads) Sub New
' Function: Create, EmitCreater, Map, MapFix, MapVar
'
'
' /********************************************************************************/
#End Region
Imports System.Reflection
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic.Data.IO.Xdr.Emit
Namespace Xdr
Public NotInheritable Partial Class WriteBuilder
Private _wm As WriteMapper
Private _creater As Func(Of IByteWriter, Writer)
Private _modBuilder As ModuleBuilder
Private _buildBinderDescription As BuildBinderDescription
Private _oneCacheDescription As StaticCacheDescription
Private _varCacheDescription As StaticCacheDescription
Private _fixCacheDescription As StaticCacheDescription
Public Sub New()
Dim name = "DynamicXdrWriteMapper"
Dim asmName As AssemblyName = New AssemblyName(name)
Dim asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave)
_modBuilder = asmBuilder.DefineDynamicModule(name & ".dll", name & ".dll")
_buildBinderDescription = New BuildBinderDescription(_modBuilder)
_oneCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "OneCache", False, OpaqueType.One)
_fixCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "FixCache", False, OpaqueType.Fix)
_varCacheDescription = New StaticCacheDescription(_modBuilder, _buildBinderDescription, "VarCache", False, OpaqueType.Var)
Dim dynWriteMapperType As Type = EmitDynWriteMapper()
_wm = CType(Activator.CreateInstance(dynWriteMapperType), WriteMapper)
Dim dynWriterType As Type = EmitDynWriter()
Dim mapperInstance = dynWriterType.GetField("Mapper", BindingFlags.Public Or BindingFlags.Static)
mapperInstance.SetValue(Nothing, _wm)
_creater = EmitCreater(dynWriterType.GetConstructor(New Type() {GetType(IByteWriter)}))
End Sub
Private Shared Function EmitCreater(ci As ConstructorInfo) As Func(Of IByteWriter, Writer)
Dim dm = New DynamicMethod("DynCreateWriter", GetType(Writer), New Type() {GetType(IByteWriter)}, GetType(WriteBuilder), True)
Dim il = dm.GetILGenerator()
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Newobj, ci)
il.Emit(OpCodes.Ret)
Return CType(dm.CreateDelegate(GetType(Func(Of IByteWriter, Writer))), Func(Of IByteWriter, Writer))
End Function
Public Function Map(Of T)(writer As WriteOneDelegate(Of T)) As WriteBuilder
_wm.AppendMethod(GetType(T), OpaqueType.One, writer)
Return Me
End Function
Public Function MapFix(Of T)(writer As WriteManyDelegate(Of T)) As WriteBuilder
_wm.AppendMethod(GetType(T), OpaqueType.Fix, writer)
Return Me
End Function
Public Function MapVar(Of T)(writer As WriteManyDelegate(Of T)) As WriteBuilder
_wm.AppendMethod(GetType(T), OpaqueType.Var, writer)
Return Me
End Function
Public Function Create(writer As IByteWriter) As Writer
Return _creater(writer)
End Function
End Class
End Namespace

@ -0,0 +1,377 @@
#Region "Microsoft.VisualBasic::313d875a366955af6a1292fd1c1e144c, Data\BinaryData\BinaryData\XDR\Writing\WriteMapper.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class WriteMapper
'
' Constructor: (+1 Overloads) Sub New
'
' Function: BuildDelegate, CreateEnumWriter, CreateFixArrayWriter, CreateFixListWriter, CreateLinkedListWriter
' CreateNullableWriter, CreateVarArrayWriter, CreateVarListWriter, GetCacheType
'
' Sub: AppendBuildRequest, AppendMethod, BuildCaches, EnumWriter, Init
' LockedAppendMethod, NoCheckWriteFixOpaque, SetFix, SetOne, SetVar
' WriteBool, WriteFixArray, WriteFixList, WriteFixOpaque, WriteLinkedList
' WriteNullable, WriteOption, WriteString, WriteVarArray, WriteVarList
' WriteVarOpaque
'
'
' /********************************************************************************/
#End Region
Imports System.Text
Imports Microsoft.VisualBasic.Data.IO.Xdr.EmitContexts
Namespace Xdr
Public MustInherit Class WriteMapper
Private _sync As Object = New Object()
Private _dependencySync As Object = New Object()
Private _dependency As Queue(Of BuildRequest) = New Queue(Of BuildRequest)()
Private _builders As Dictionary(Of OpaqueType, Func(Of Type, [Delegate])()) = New Dictionary(Of OpaqueType, Func(Of Type, [Delegate])())()
Protected Sub New()
End Sub
Protected Sub Init()
SetOne(Of Void)(Sub(w, i)
End Sub)
SetOne(Of Integer)(Sub(w, i) EncodeInt32(i, w.ByteWriter))
SetOne(Of UInteger)(Sub(w, i) EncodeUInt32(i, w.ByteWriter))
SetOne(Of Long)(Sub(w, i) EncodeInt64(i, w.ByteWriter))
SetOne(Of ULong)(Sub(w, i) EncodeUInt64(i, w.ByteWriter))
SetOne(Of Single)(Sub(w, i) XdrEncoding.EncodeSingle(i, w.ByteWriter))
SetOne(Of Double)(Sub(w, i) XdrEncoding.EncodeDouble(i, w.ByteWriter))
Call SetOne(New WriteOneDelegate(Of Boolean)(AddressOf WriteBool))
Call SetFix(New WriteManyDelegate(Of Byte())(AddressOf WriteFixOpaque))
Call SetVar(New WriteManyDelegate(Of Byte())(AddressOf WriteVarOpaque))
Call SetVar(New WriteManyDelegate(Of String)(AddressOf WriteString))
_builders.Add(OpaqueType.One, New Func(Of Type, [Delegate])() {AddressOf CreateEnumWriter, AddressOf CreateNullableWriter, AddressOf CreateLinkedListWriter, AddressOf GetWriter})
_builders.Add(OpaqueType.Fix, New Func(Of Type, [Delegate])() {AddressOf CreateFixArrayWriter, AddressOf CreateFixListWriter})
_builders.Add(OpaqueType.Var, New Func(Of Type, [Delegate])() {AddressOf CreateVarArrayWriter, AddressOf CreateVarListWriter})
End Sub
Private Shared Sub WriteBool(w As Writer, v As Boolean)
w.Write(If(v, 1, 0))
End Sub
Private Shared _tails As Byte()() = New Byte()() {Nothing, New Byte() {&H00}, New Byte() {&H00, &H00}, New Byte() {&H00, &H00, &H00}}
Private Shared Sub WriteFixOpaque(w As Writer, len As UInteger, v As Byte())
If v.LongLength <> len Then Throw New FormatException("unexpected length: " & v.LongLength.ToString())
NoCheckWriteFixOpaque(w, len, v)
End Sub
Private Shared Sub WriteVarOpaque(w As Writer, max As UInteger, v As Byte())
Dim len As UInteger = v.LongLength
If len > max Then Throw New FormatException("unexpected length: " & len.ToString())
Try
w.Write(len)
Catch ex As SystemException
Throw New FormatException("can't write length", ex)
End Try
NoCheckWriteFixOpaque(w, len, v)
End Sub
Private Shared Sub NoCheckWriteFixOpaque(w As Writer, len As UInteger, v As Byte())
Try
w.ByteWriter.Write(v)
Dim tail = len Mod 4UI
If tail <> 0 Then w.ByteWriter.Write(_tails(4UI - tail))
Catch ex As SystemException
Throw New FormatException("can't write byte array", ex)
End Try
End Sub
Private Shared Sub WriteString(w As Writer, max As UInteger, v As String)
WriteVarOpaque(w, max, Encoding.ASCII.GetBytes(v))
End Sub
Private Function BuildDelegate(methodType As OpaqueType, targetType As Type) As [Delegate]
Dim wrap As Exception = Nothing
Try
For Each build In _builders(methodType)
Dim result = build(targetType)
If result IsNot Nothing Then Return result
Next
Catch ex As Exception
wrap = New InvalidOperationException(String.Format("impossible to create a {0} method type for `{1}'", methodType, targetType.FullName), ex)
End Try
If wrap Is Nothing Then wrap = New NotImplementedException(String.Format("unknown type `{0}' in {1} method type", targetType.FullName, methodType))
If methodType = OpaqueType.One Then
Return WriteOneDelegate(targetType, wrap)
Else
Return WriteManyDelegate(targetType, wrap)
End If
End Function
Protected Sub SetOne(Of T)(method As WriteOneDelegate(Of T))
GetOneCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Protected Sub SetFix(Of T)(method As WriteManyDelegate(Of T))
GetFixCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Protected Sub SetVar(Of T)(method As WriteManyDelegate(Of T))
GetVarCacheType().MakeGenericType(GetType(T)).GetField("Instance").SetValue(Nothing, method)
End Sub
Private Function GetCacheType(methodType As OpaqueType) As Type
Select Case methodType
Case OpaqueType.One
Return GetOneCacheType()
Case OpaqueType.Fix
Return GetFixCacheType()
Case OpaqueType.Var
Return GetVarCacheType()
Case Else
Throw New NotImplementedException("unknown opaque type")
End Select
End Function
Protected MustOverride Function GetOneCacheType() As Type
Protected MustOverride Function GetFixCacheType() As Type
Protected MustOverride Function GetVarCacheType() As Type
Public Sub BuildCaches()
SyncLock _sync
While True
Dim bReq As BuildRequest = Nothing
SyncLock _dependencySync
If _dependency.Count <> 0 Then bReq = _dependency.Dequeue()
End SyncLock
If bReq Is Nothing Then Return
Dim fi = GetCacheType(bReq.Method).MakeGenericType(bReq.TargetType).GetField("Instance")
If fi.GetValue(Nothing) Is Nothing Then fi.SetValue(Nothing, BuildDelegate(bReq.Method, bReq.TargetType))
End While
End SyncLock
End Sub
Friend Sub AppendMethod(targetType As Type, methodType As OpaqueType, method As [Delegate])
SyncLock _sync
LockedAppendMethod(targetType, methodType, method)
End SyncLock
End Sub
Private Sub LockedAppendMethod(targetType As Type, methodType As OpaqueType, method As [Delegate])
Dim fi = GetCacheType(methodType).MakeGenericType(targetType).GetField("Instance")
If fi.GetValue(Nothing) IsNot Nothing Then Throw New InvalidOperationException("type already mapped")
fi.SetValue(Nothing, method)
End Sub
Protected Sub AppendBuildRequest(targetType As Type, methodType As OpaqueType)
SyncLock _dependencySync
_dependency.Enqueue(New BuildRequest With {
.TargetType = targetType,
.Method = methodType
})
End SyncLock
End Sub
Public Shared Function CreateFixArrayWriter(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ArraySubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteFixArray").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Sub WriteFixArray(Of T)(w As Writer, len As UInteger, val As T())
If val.LongLength <> len Then Throw New FormatException("unexpected length: " & val.LongLength.ToString())
Dim i As UInteger = 0
Try
While i < len
w.Write(val(i))
i += 1
End While
Catch ex As SystemException
Throw New FormatException(String.Format("can't write {0} item", i), ex)
End Try
End Sub
Public Shared Function CreateLinkedListWriter(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteLinkedList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteOneDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Sub WriteLinkedList(Of T)(w As Writer, val As List(Of T))
For i = 0 To val.Count - 1
WriteOption(w, True)
Try
w.Write(val(i))
Catch ex As SystemException
Throw New FormatException(String.Format("can't write {0} item", i), ex)
End Try
Next
WriteOption(w, False)
End Sub
Public Shared Function CreateFixListWriter(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteFixList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Sub WriteFixList(Of T)(w As Writer, len As UInteger, val As List(Of T))
If val.Count <> len Then Throw New FormatException("unexpected length: " & val.Count.ToString())
Dim i = 0
Try
While i < val.Count
w.Write(val(i))
i += 1
End While
Catch ex As SystemException
Throw New FormatException(String.Format("can't write {0} item", i), ex)
End Try
End Sub
Public Shared Function CreateEnumWriter(targetType As Type) As [Delegate]
If Not targetType.IsEnum Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("EnumWriter").MakeGenericMethod(targetType)
Return [Delegate].CreateDelegate(GetType(WriteOneDelegate(Of)).MakeGenericType(targetType), mi)
End Function
Public Shared Sub EnumWriter(Of T As Structure)(writer As Writer, val As T)
writer.Write(EnumHelper(Of T).EnumToInt(val))
End Sub
Public Shared Function CreateNullableWriter(targetType As Type) As [Delegate]
Dim itemType As Type = targetType.NullableSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteNullable").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteOneDelegate(Of)).MakeGenericType(targetType), mi)
End Function
Public Shared Sub WriteNullable(Of T As Structure)(writer As Writer, val As T?)
WriteOption(writer, val.HasValue)
If Not val.HasValue Then Return
Try
writer.Write(val.Value)
Catch ex As SystemException
Throw New FormatException("can't write value", ex)
End Try
End Sub
Private Shared Sub WriteOption(writer As Writer, val As Boolean)
Try
writer.Write(val)
Catch ex As SystemException
Throw New FormatException("can't write option", ex)
End Try
End Sub
Public Shared Function CreateVarArrayWriter(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ArraySubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteVarArray").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Sub WriteVarArray(Of T)(w As Writer, max As UInteger, val As T())
Dim len As UInteger = val.LongLength
If len > max Then Throw New FormatException("unexpected length: " & len.ToString())
Try
w.Write(len)
Catch ex As SystemException
Throw New FormatException("can't write length", ex)
End Try
Dim i As UInteger = 0
Try
While i < len
w.Write(val(i))
i += 1
End While
Catch ex As SystemException
Throw New FormatException(String.Format("can't write {0} item", i), ex)
End Try
End Sub
Public Shared Function CreateVarListWriter(collectionType As Type) As [Delegate]
Dim itemType As Type = collectionType.ListSubType()
If itemType Is Nothing Then Return Nothing
Dim mi = GetType(WriteMapper).GetMethod("WriteVarList").MakeGenericMethod(itemType)
Return [Delegate].CreateDelegate(GetType(WriteManyDelegate(Of)).MakeGenericType(collectionType), mi)
End Function
Public Shared Sub WriteVarList(Of T)(w As Writer, max As UInteger, val As List(Of T))
Dim len = val.Count
If len > max Then Throw New FormatException("unexpected length: " & len.ToString())
Try
w.Write(Of UInteger)(len)
Catch ex As SystemException
Throw New FormatException("can't write length", ex)
End Try
Dim i = 0
Try
While i < len
w.Write(val(i))
i += 1
End While
Catch ex As SystemException
Throw New FormatException(String.Format("can't write {0} item", i), ex)
End Try
End Sub
End Class
End Namespace

@ -0,0 +1,94 @@
#Region "Microsoft.VisualBasic::e8ea3985ba52d2f47bc6f5004d9aa066, Data\BinaryData\BinaryData\XDR\Writing\Writer.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' /********************************************************************************/
' Summaries:
' Class Writer
'
' Constructor: (+1 Overloads) Sub New
' Sub: Write, WriteFix, WriteOption, WriteVar
'
'
' /********************************************************************************/
#End Region
Imports System
Namespace Xdr
Public MustInherit Class Writer
Public ReadOnly ByteWriter As IByteWriter
Protected Sub New(writer As IByteWriter)
ByteWriter = writer
End Sub
Public Sub Write(Of T)(item As T)
Try
CacheWrite(item)
Catch ex As SystemException
Throw MapException.WriteOne(GetType(T), ex)
End Try
End Sub
Protected MustOverride Sub CacheWrite(Of T)(item As T)
Public Sub WriteFix(Of T)(len As UInteger, item As T)
Try
CacheWriteFix(len, item)
Catch ex As SystemException
Throw MapException.WriteFix(GetType(T), len, ex)
End Try
End Sub
Protected MustOverride Sub CacheWriteFix(Of T)(len As UInteger, item As T)
Public Sub WriteVar(Of T)(max As UInteger, item As T)
Try
CacheWriteVar(max, item)
Catch ex As SystemException
Throw MapException.WriteVar(GetType(T), max, ex)
End Try
End Sub
Protected MustOverride Sub CacheWriteVar(Of T)(max As UInteger, item As T)
Public Sub WriteOption(Of T As Class)(item As T)
If item Is Nothing Then
Write(False)
Else
Write(True)
Write(item)
End If
End Sub
End Class
End Namespace

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{806818F5-D50A-4BFF-ACA3-CFF60D3FC61E}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>XDR</RootNamespace>
<AssemblyName>XDRStream</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>XDRStream.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>XDRStream.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Diagnostics" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\CaseAttribute.vb" />
<Compile Include="Attributes\FixAttribute.vb" />
<Compile Include="Attributes\OptionAttribute.vb" />
<Compile Include="Attributes\OrderAttribute.vb" />
<Compile Include="Attributes\SwitchAttribute.vb" />
<Compile Include="Attributes\VarAttribute.vb" />
<Compile Include="Delegates.vb" />
<Compile Include="EmitContexts\EmitContext.vb" />
<Compile Include="EmitContexts\EmitResult.vb" />
<Compile Include="EmitContexts\FieldDesc.vb" />
<Compile Include="EmitContexts\OrderModel.vb" />
<Compile Include="EmitContexts\SwitchModel.vb" />
<Compile Include="Emit\BuildRequest.vb" />
<Compile Include="Emit\DelegateCacheDescription.vb" />
<Compile Include="Emit\ErrorStub.vb" />
<Compile Include="Emit\ErrorStubType.vb" />
<Compile Include="Emit\StaticCacheDescription.vb" />
<Compile Include="EnumHelper.vb" />
<Compile Include="MapException.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="NamespaceDoc.vb" />
<Compile Include="OpaqueType.vb" />
<Compile Include="Reading\ReadBuilder.EmitDynReader.vb" />
<Compile Include="Reading\ReadBuilder.EmitDynReadMapper.vb" />
<Compile Include="Reading\ReadBuilder.vb" />
<Compile Include="Reading\Reader.vb" />
<Compile Include="Reading\ReadMapper.vb" />
<Compile Include="TypeExtensions.vb" />
<Compile Include="Void.vb" />
<Compile Include="Writing\WriteBuilder.EmitDynWriteMapper.vb" />
<Compile Include="Writing\WriteBuilder.EmitDynWriter.vb" />
<Compile Include="Writing\WriteBuilder.vb" />
<Compile Include="Writing\WriteMapper.vb" />
<Compile Include="Writing\Writer.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
Loading…
Cancel
Save