removes unused code

master
xieguigang 7 years ago
parent 85e687d210
commit cb30259357

@ -1,158 +0,0 @@
#Region "Microsoft.VisualBasic::29306db6025bcb28ecbc5f64b5575737, ComputingServices\Cluster\Master.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 Master
'
' Properties: Nodes
'
' Constructor: (+1 Overloads) Sub New
'
' Function: [Select], GetPreferNode, Invoke
'
' Sub: Scan, ScanTask
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.ComponentModel.Collection
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Net.Http
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Tcp
Imports Microsoft.VisualBasic.Parallel
Imports sciBASIC.ComputingServices.TaskHost
Namespace Cluster
''' <summary>
''' Client
''' </summary>
Public Class Master
''' <summary>
''' Online avaliable nodes in this server cluster.
''' </summary>
Dim _nodes As New Dictionary(Of TaskRemote)
Dim node_port%
Dim net$
''' <summary>
'''
''' </summary>
''' <returns></returns>
Public ReadOnly Property Nodes As Integer
Get
Return _nodes.Count
End Get
End Property
''' <summary>
'''
''' </summary>
''' <param name="net$"><see cref="EnumerateAddress"/></param>
''' <param name="node_port%"></param>
Sub New(net$, node_port%)
Me.node_port = node_port
Me.net = net
End Sub
Public Sub Scan()
Dim request As New RequestStream(Protocols.ProtocolEntry, TaskProtocols.Handshake)
For Each IP$ In EnumerateAddress(Me.net)
Dim response = New TcpRequest(IP, node_port) _
.SendMessage(request, 200)
SyncLock _nodes
If response.Protocol = HTTP_RFC.RFC_OK Then
If Not _nodes.ContainsKey(IP) Then
Call _nodes.Add(New TaskRemote(IP, node_port))
Call $"Add new node: {IP}".__DEBUG_ECHO
End If
Else
If _nodes.ContainsKey(IP) Then
Call _nodes.Remove(IP)
Call $"Removes offline node: {IP}".__DEBUG_ECHO
End If
End If
End SyncLock
Next
End Sub
''' <summary>
'''
''' </summary>
''' <returns></returns>
Public Function GetPreferNode() As TaskRemote
SyncLock _nodes
Return LinqAPI.DefaultFirst(Of TaskRemote) <=
_
From node As TaskRemote
In _nodes.Values.AsParallel
Select node,
node.Load
Order By Load Ascending
End SyncLock
End Function
''' <summary>
'''
''' </summary>
''' <param name="target"></param>
''' <param name="args"></param>
Public Function Invoke(target As [Delegate], ParamArray args As Object()) As Object
Dim node As TaskRemote = GetPreferNode()
Dim out As Object = node.Invoke(target, args)
Return out
End Function
Public Iterator Function [Select](Of T, Tout)(source As IEnumerable(Of T), task As [Delegate], args As Object()) As IEnumerable(Of Tout)
Dim node As TaskRemote = GetPreferNode()
Dim out As ILinq(Of Tout) = node.Select(Of T, Tout)(task, source.ToArray, args)
For Each x As Tout In out
Yield x
Next
End Function
Public Sub ScanTask()
Call RunTask(AddressOf Scan)
End Sub
End Class
End Namespace

@ -1,78 +0,0 @@
#Region "Microsoft.VisualBasic::b18fd8363c2ff03baf0c40c12922f872, ComputingServices\ComponentModel\IHostBase.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 IHostBase
'
' Constructor: (+2 Overloads) Sub New
'
' Class IMasterBase
'
'
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Net.Abstract
Imports Microsoft.VisualBasic.Net.Tcp
Namespace ComponentModel
Public MustInherit Class IHostBase : Inherits IMasterBase(Of TcpServicesSocket)
Sub New(portal As Integer)
__host = New TcpServicesSocket(portal)
End Sub
Sub New()
End Sub
End Class
Public MustInherit Class IMasterBase(Of TSocket As IServicesSocket)
Public MustOverride ReadOnly Property Portal As IPEndPoint
Protected Friend __host As TSocket
Public Shared Narrowing Operator CType(master As IMasterBase(Of TSocket)) As IPEndPoint
Return master.Portal
End Operator
Public Shared Narrowing Operator CType(master As IMasterBase(Of TSocket)) As System.Net.IPEndPoint
Return master.Portal.GetIPEndPoint
End Operator
End Class
End Namespace

@ -1,51 +0,0 @@
#Region "Microsoft.VisualBasic::4ed036e6d3b96a7f496681ffbbb780e9, ComputingServices\ComponentModel\IRemote.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:
' Interface IRemoteSupport
'
' Properties: FileSystem
'
'
' /********************************************************************************/
#End Region
Imports sciBASIC.ComputingServices.FileSystem
Namespace ComponentModel
Public Interface IRemoteSupport
ReadOnly Property FileSystem As FileSystemHost
End Interface
End Namespace

@ -207,21 +207,6 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cluster\Master.vb" />
<Compile Include="ComponentModel\IRemote.vb" />
<Compile Include="ComponentModel\IHostBase.vb" />
<Compile Include="Extensions.vb" />
<Compile Include="FileSystem\Objects\DirectoryInfo.vb" />
<Compile Include="FileSystem\Objects\DriveInfo.vb" />
<Compile Include="FileSystem\Protocols\FileHandle.vb" />
<Compile Include="FileSystem\Protocols\FileURI.vb" />
<Compile Include="FileSystem\Protocols\NetTransfer.vb" />
<Compile Include="FileSystem\Protocols\FileStreamInfo.vb" />
<Compile Include="FileSystem\Protocols\FileSystemAPI.vb" />
<Compile Include="FileSystem\Protocols\FileOpen.vb" />
<Compile Include="FileSystem\Protocols\Protocols.vb" />
<Compile Include="FileSystem\FileSystemHost.vb" />
<Compile Include="FileSystem\FileSystem.vb" />
<Compile Include="Environment.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
@ -238,10 +223,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="SharedMemory\Protocols.vb" />
<Compile Include="SharedMemory\SharedSvr.vb" />
<Compile Include="SharedMemory\HashValue.vb" />
<Compile Include="SharedMemory\MemoryServices.vb" />
<Compile Include="Taskhost.d\Invoke\TaskInvoke.vb" />
<Compile Include="Taskhost.d\Linq\LinqPool.vb" />
<Compile Include="Taskhost.d\Linq\ILinq%28Of T%29.vb" />

@ -1,48 +0,0 @@
#Region "Microsoft.VisualBasic::352864497ee44603ec76226fc0b6f23e, ComputingServices\Extensions.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 Extensions
'
' Properties: Sha256Provider
'
' /********************************************************************************/
#End Region
''' <summary>
'''
''' </summary>
Module Extensions
Public ReadOnly Property Sha256Provider As New SecurityString.SHA256("xie.guigang@gmail.com", "ghTGAbcZ")
End Module

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,59 +0,0 @@
#Region "Microsoft.VisualBasic::36492bd31cd03dcecb89840dc9b70a6d, ComputingServices\FileSystem\Objects\DirectoryInfo.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 DirectoryInfo
'
' Constructor: (+1 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Runtime.Serialization
Namespace FileSystem
''' <summary>
'''
''' </summary>
Public Class DirectoryInfo
Sub New(info As System.IO.DirectoryInfo)
End Sub
End Class
End Namespace

@ -1,173 +0,0 @@
#Region "Microsoft.VisualBasic::9ef10319ded16d07938b6505bba5683c, ComputingServices\FileSystem\Objects\DriveInfo.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 DriveInfo
'
' Properties: AvailableFreeSpace, DriveFormat, DriveType, IsReady, Name
' RootDirectory, TotalFreeSpace, TotalSize, VolumeLabel
'
' Constructor: (+2 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Runtime.Serialization
Imports Microsoft.VisualBasic.Language
Namespace FileSystem
''' <summary>
''' Provides access to information on a drive.
''' </summary>
<ComVisible(True)> Public NotInheritable Class DriveInfo
Sub New(info As System.IO.DriveInfo)
Me.AvailableFreeSpace = info.AvailableFreeSpace
Me.DriveFormat = info.DriveFormat
Me.DriveType = info.DriveType
Me.IsReady = info.IsReady
Me.Name = info.Name
Me.RootDirectory = info.RootDirectory
Me.TotalFreeSpace = info.TotalFreeSpace
Me.TotalSize = info.TotalSize
Me.VolumeLabel = info.VolumeLabel
End Sub
Sub New()
End Sub
' Exceptions:
' T:System.UnauthorizedAccessException:
' Access to the drive information is denied.
'
' T:System.IO.IOException:
' An I/O error occurred (for example, a disk error or a drive was not ready).
''' <summary>
''' Indicates the amount of available free space on a drive, in bytes.
''' </summary>
''' <returns>The amount of free space available on the drive, in bytes.</returns>
Public Property AvailableFreeSpace As Long
' Exceptions:
' T:System.UnauthorizedAccessException:
' Access to the drive information is denied.
'
' T:System.IO.DriveNotFoundException:
' The drive does not exist or is not mapped.
'
' T:System.IO.IOException:
' An I/O error occurred (for example, a disk error or a drive was not ready).
''' <summary>
''' Gets the name of the file system, such as NTFS or FAT32.
''' </summary>
''' <returns>The name of the file system on the specified drive.</returns>
Public Property DriveFormat As String
''' <summary>
''' Gets the drive type, such as CD-ROM, removable, network, or fixed.
''' </summary>
''' <returns>One of the enumeration values that specifies a drive type.</returns>
Public Property DriveType As DriveType
''' <summary>
''' Gets a value that indicates whether a drive is ready.
''' </summary>
''' <returns>true if the drive is ready; false if the drive is not ready.</returns>
Public Property IsReady As Boolean
''' <summary>
''' Gets the name of a drive, such as C:\.
''' </summary>
''' <returns>The name of the drive.</returns>
Public Property Name As String
''' <summary>
''' Gets the root directory of a drive.
''' </summary>
''' <returns>An object that contains the root directory of the drive.</returns>
Public Property RootDirectory As System.IO.DirectoryInfo
' Exceptions:
' T:System.UnauthorizedAccessException:
' Access to the drive information is denied.
'
' T:System.IO.DriveNotFoundException:
' The drive is not mapped or does not exist.
'
' T:System.IO.IOException:
' An I/O error occurred (for example, a disk error or a drive was not ready).
''' <summary>
''' Gets the total amount of free space available on a drive, in bytes.
''' </summary>
''' <returns>The total free space available on a drive, in bytes.</returns>
Public Property TotalFreeSpace As Long
' Exceptions:
' T:System.UnauthorizedAccessException:
' Access to the drive information is denied.
'
' T:System.IO.DriveNotFoundException:
' The drive is not mapped or does not exist.
'
' T:System.IO.IOException:
' An I/O error occurred (for example, a disk error or a drive was not ready).
''' <summary>
''' Gets the total size of storage space on a drive, in bytes.
''' </summary>
''' <returns>The total size of the drive, in bytes.</returns>
Public Property TotalSize As Long
' Exceptions:
' T:System.IO.IOException:
' An I/O error occurred (for example, a disk error or a drive was not ready).
'
' T:System.IO.DriveNotFoundException:
' The drive is not mapped or does not exist.
'
' T:System.Security.SecurityException:
' The caller does not have the required permission.
'
' T:System.UnauthorizedAccessException:
' The volume label is being set on a network or CD-ROM drive.-or-Access to the
' drive information is denied.
''' <summary>
''' Gets or sets the volume label of a drive.
''' </summary>
''' <returns>The volume label.</returns>
Public Property VolumeLabel As String
End Class
End Namespace

@ -1,87 +0,0 @@
#Region "Microsoft.VisualBasic::29565e0839a1e3ff54d3cf4e55191e31, ComputingServices\FileSystem\Protocols\FileHandle.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 FileHandle
'
' Properties: FileName, Handle, HashCode
'
' Constructor: (+2 Overloads) Sub New
' Function: ToString
'
'
' /********************************************************************************/
#End Region
Namespace FileSystem.Protocols
''' <summary>
''' The file handle object on the remote server machine.
''' ()
''' </summary>
Public Class FileHandle
''' <summary>
''' The file location on the remote file system.
''' </summary>
''' <returns></returns>
Public Property FileName As String
''' <summary>
''' The hash code value on the remote services program.
''' </summary>
''' <returns></returns>
Public Property HashCode As Integer
Sub New()
End Sub
Sub New(handle As FileHandle)
Me.FileName = handle.FileName
Me.HashCode = handle.HashCode
End Sub
Public Overrides Function ToString() As String
Return Handle
End Function
''' <summary>
'''
''' </summary>
''' <returns></returns>
Public ReadOnly Property Handle As String
Get
Return $"{HashCode}+{FileName.ToFileURL}"
End Get
End Property
End Class
End Namespace

@ -1,232 +0,0 @@
#Region "Microsoft.VisualBasic::769f9f41ca2ca1d564d4532002c6307d, ComputingServices\FileSystem\Protocols\FileOpen.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 RenameArgs
'
' Properties: [New], old
'
' Class DeleteArgs
'
' Properties: [option], obj
'
' Class FileOpen
'
' Properties: Access, Mode
'
' Function: OpenHandle, ToString
'
' Class ReadBuffer
'
' Properties: length, offset
'
' Constructor: (+2 Overloads) Sub New
' Function: (+2 Overloads) CreateBuffer
'
' Interface IReadWriteBuffer
'
' Properties: length, offset
'
' Class WriteStream
'
' Properties: buffer, Handle, length, offset
'
' Constructor: (+2 Overloads) Sub New
' Function: CreateBuffer, Serialize
'
' Class FileStreamPosition
'
' Properties: Position
'
' Constructor: (+2 Overloads) Sub New
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace FileSystem.Protocols
Public Class RenameArgs
Public Property old As String
Public Property [New] As String
End Class
Public Class DeleteArgs
Public Property obj As String
Public Property [option] As Integer
End Class
''' <summary>
''' Initializes a new instance of the System.IO.FileStream class with the specified
''' path and creation mode.
''' </summary>
Public Class FileOpen : Inherits FileHandle
''' <summary>
''' Specifies how the operating system should open a file.
''' </summary>
''' <returns></returns>
Public Property Mode As Integer
Public Property Access As Integer = FileAccess.Read
Public Overrides Function ToString() As String
Return $"[{DirectCast(Mode, FileMode).ToString }] " & FileName.ToFileURL
End Function
''' <summary>
''' Initializes a new instance of the System.IO.FileStream class with the specified
''' path and creation mode.
''' </summary>
Public Function OpenHandle() As FileStream
Dim mode As FileMode = DirectCast(Me.Mode, FileMode)
Dim access As FileAccess = DirectCast(Me.Access, FileAccess)
Return New FileStream(FileName, mode, access)
End Function
End Class
Public Class ReadBuffer : Inherits FileHandle
Implements IReadWriteBuffer
Public Property offset As Integer Implements IReadWriteBuffer.offset
''' <summary>
'''
''' </summary>
''' <returns></returns>
Public Property length As Integer Implements IReadWriteBuffer.length
Sub New()
End Sub
Sub New(handle As FileHandle)
Call MyBase.New(handle)
End Sub
Public Function CreateBuffer() As Byte()
Return CreateBuffer(Me)
End Function
Public Shared Function CreateBuffer(op As IReadWriteBuffer) As Byte()
Dim buffer As Byte() = New Byte(op.length + op.offset - 1) {}
Return buffer
End Function
End Class
Public Interface IReadWriteBuffer
Property offset As Integer
Property length As Integer
End Interface
Public Class WriteStream : Inherits RawStream
Implements IReadWriteBuffer
Public Property Handle As FileHandle
Public Property length As Integer Implements IReadWriteBuffer.length
Public Property offset As Integer Implements IReadWriteBuffer.offset
Public Property buffer As Byte()
Sub New()
End Sub
Sub New(raw As Byte())
Dim buf As Byte() = New Byte(INT32 - 1) {}
Dim p As VBInteger = Scan0
Dim handleLen As Integer
Dim bufferLen As Integer
Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : length = BitConverter.ToInt32(buf, Scan0)
Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : offset = BitConverter.ToInt32(buf, Scan0)
Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : handleLen = BitConverter.ToInt32(buf, Scan0)
Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : bufferLen = BitConverter.ToInt32(buf, Scan0)
buf = New Byte(handleLen - 1) {}
Call Array.ConstrainedCopy(raw, p + handleLen, buf, Scan0, handleLen)
Dim json As String = Encoding.UTF8.GetString(buf)
Handle = json.LoadJSON(Of FileHandle)
buffer = New Byte(bufferLen - 1) {}
Call Array.ConstrainedCopy(raw, p, buffer, Scan0, bufferLen)
End Sub
Public Overrides Function Serialize() As Byte()
Dim handle As Byte() = System.Text.Encoding.UTF8.GetBytes(Me.Handle.GetJson)
Dim length As Byte() = BitConverter.GetBytes(Me.length)
Dim offset As Byte() = BitConverter.GetBytes(Me.offset)
Dim chunkBuffer As Byte() = New Byte(INT32 + ' length
INT32 + ' offset
INT32 + ' handle length
INT32 + ' buffer length
handle.Length +
buffer.Length - 1) {}
Dim p As VBInteger = Scan0
Dim handleLen As Byte() = BitConverter.GetBytes(handle.Length)
Dim bufferLen As Byte() = BitConverter.GetBytes(buffer.Length)
Call Array.ConstrainedCopy(length, Scan0, chunkBuffer, p + INT32, INT32)
Call Array.ConstrainedCopy(offset, Scan0, chunkBuffer, p + INT32, INT32)
Call Array.ConstrainedCopy(handleLen, Scan0, chunkBuffer, p + INT32, INT32)
Call Array.ConstrainedCopy(bufferLen, Scan0, chunkBuffer, p + INT32, INT32)
Call Array.ConstrainedCopy(handle, Scan0, chunkBuffer, p + handle.Length, handle.Length)
Call Array.ConstrainedCopy(buffer, Scan0, chunkBuffer, p, buffer.Length)
Return chunkBuffer
End Function
Public Function CreateBuffer() As Byte()
Return ReadBuffer.CreateBuffer(Me)
End Function
End Class
Public Class FileStreamPosition : Inherits FileHandle
Public Const [GET] As Long = -100
''' <summary>
''' -100
''' </summary>
''' <returns></returns>
Public Property Position As Long = [GET]
Sub New(handle As FileHandle)
Call MyBase.New(handle)
End Sub
Sub New()
End Sub
End Class
End Namespace

@ -1,135 +0,0 @@
#Region "Microsoft.VisualBasic::972387fdd3296832e8c2ce0ad5d79fe5, ComputingServices\FileSystem\Protocols\FileStreamInfo.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 FileStreamInfo
'
' Properties: CanRead, CanSeek, CanWrite, FileHandle, IsAsync
'
' Constructor: (+1 Overloads) Sub New
' Function: GetInfo
'
' Class SeekArgs
'
' Properties: offset, origin
'
' Constructor: (+2 Overloads) Sub New
' Function: Seek
'
' Class LockArgs
'
' Properties: length, Lock, position
'
' Constructor: (+2 Overloads) Sub New
' Sub: LockOrNot
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Imports Microsoft.VisualBasic.Serialization
Namespace FileSystem.Protocols
Public Class FileStreamInfo : Inherits FileHandle
Public Property CanRead As Boolean
Public Property CanSeek As Boolean
Public Property CanWrite As Boolean
Public Property FileHandle As IntPtr
Public Property IsAsync As Boolean
Sub New()
End Sub
Public Shared Function GetInfo(file As FileStream) As FileStreamInfo
#Disable Warning
Dim handle As New FileStreamInfo With {
.HashCode = file.GetHashCode,
.CanRead = file.CanRead,
.CanSeek = file.CanSeek,
.CanWrite = file.CanWrite,
.FileHandle = file.Handle,
.IsAsync = file.IsAsync
} ' 使
#Enable Warning
Return handle
End Function
End Class
Public Class SeekArgs : Inherits FileHandle
Public Property offset As Long
Public Property origin As Integer
Sub New(handle As FileHandle)
Call MyBase.New(handle)
End Sub
Sub New()
End Sub
Public Function Seek(stream As System.IO.FileStream) As Long
Dim ori As SeekOrigin = CType(origin, SeekOrigin)
Return stream.Seek(offset, ori)
End Function
End Class
Public Class LockArgs : Inherits FileHandle
Public Property Lock As Boolean
Public Property position As Long
Public Property length As Long
Sub New(handle As FileHandle)
Call MyBase.New(handle)
End Sub
Sub New()
End Sub
Public Sub LockOrNot(stream As System.IO.FileStream)
If Lock Then
Call stream.Lock(position, length)
Else
Call stream.Unlock(position, length)
End If
End Sub
End Class
End Namespace

@ -1,789 +0,0 @@
#Region "Microsoft.VisualBasic::25a2e448b3ecd884a4b8878d797fe957, ComputingServices\FileSystem\Protocols\FileSystemAPI.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 FileSystemAPI
'
' CloseHandle, CombinePath, CopyDirectory, CopyFile, CreateDirectory
' CurrentDirectory, DeleteDirectory, DeleteFile, DirectoryExists, Drives
' FileExists, FilePosition, FileStreamLength, FindInFiles, Flush
' GetDirectories, GetDirectoryInfo, GetDriveInfo, GetFileInfo, GetFiles
' GetFileStreamInfo, GetName, GetParentPath, GetTempFileName, MoveDirectory
' MoveFile, OpenHandle, ReadBuffer, RenameDirectory, RenameFile
' StreamLock, StreamSeek, WriteBuffer
'
'
'
'
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Namespace FileSystem.Protocols
''' <summary>
'''
''' </summary>
Public Enum FileSystemAPI As Long
''' <summary>
'''
''' </summary>
OpenHandle
GetFileStreamInfo
''' <summary>
'''
''' </summary>
FilePosition
FileStreamLength
StreamSeek
StreamLock
''' <summary>
''' Reads a block of bytes from the stream and writes the data in a given buffer.
''' </summary>
ReadBuffer
WriteBuffer
CloseHandle
Flush
''' <summary>
''' Gets or sets the current directory.
''' </summary>
CurrentDirectory
''' <summary>
''' Returns a read-only collection of all available drive names.
''' </summary>
Drives
'
' Summary:
' Copies the contents of a directory to another directory.
'
' Parameters:
' sourceDirectoryName:
' The directory to be copied.
'
' destinationDirectoryName:
' The location to which the directory contents should be copied.
'
' Exceptions:
' T:System.ArgumentException:
' The new name specified for the directory contains a colon (:) or slash (\ or
' /).
'
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' destinationDirectoryName or sourceDirectoryName is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The source directory does not exist.
'
' T:System.IO.IOException:
' The source directory is a root directory
'
' T:System.IO.IOException:
' The combined path points to an existing file.
'
' T:System.IO.IOException:
' The source path and target path are the same.
'
' T:System.InvalidOperationException:
' The operation is cyclic.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A folder name in the path contains a colon (:) or is in an invalid format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' A destination file exists but cannot be accessed.
''' <summary>
''' Copies the contents of a directory to another directory.
''' </summary>
CopyDirectory
'
' Summary:
' Copies a file to a new location.
'
' Parameters:
' sourceFileName:
' The file to be copied.
'
' destinationFileName:
' The location to which the file should be copied.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentException:
' The system could not retrieve the absolute path.
'
' T:System.ArgumentException:
' destinationFileName contains path information.
'
' T:System.ArgumentNullException:
' destinationFileName or sourceFileName is Nothing or an empty string.
'
' T:System.IO.FileNotFoundException:
' The source file is not valid or does not exist.
'
' T:System.IO.IOException:
' The combined path points to an existing directory.
'
' T:System.IO.IOException:
' The user does not have sufficient permissions to access the file.
'
' T:System.IO.IOException:
' A file in the target directory with the same name is in use.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.UnauthorizedAccessException:
' The user does not have required permission.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
CopyFile
'
' Summary:
' Creates a directory.
'
' Parameters:
' directory:
' Name and location of the directory.
'
' Exceptions:
' T:System.ArgumentException:
' The directory name is malformed. For example, it contains illegal characters
' or is only white space.
'
' T:System.ArgumentNullException:
' directory is Nothing or an empty string.
'
' T:System.IO.PathTooLongException:
' The directory name is too long.
'
' T:System.NotSupportedException:
' The directory name is only a colon (:).
'
' T:System.IO.IOException:
' The parent directory of the directory to be created is read-only
'
' T:System.UnauthorizedAccessException:
' The user does not have permission to create the directory.
CreateDirectory
'
' Summary:
' Deletes a directory.
'
' Parameters:
' directory:
' Directory to be deleted.
'
' onDirectoryNotEmpty:
' Specifies what should be done when a directory that is to be deleted contains
' files or directories. Default is DeleteDirectoryOption.DeleteAllContents.
'
' Exceptions:
' T:System.ArgumentException:
' The path is a zero-length string, is malformed, contains only white space, or
' contains invalid characters (including wildcard characters). The path is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' directory is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The directory does not exist or is a file.
'
' T:System.IO.IOException:
' The directory is not empty, and onDirectoryNotEmpty is set to ThrowIfDirectoryNonEmpty.
'
' T:System.IO.IOException:
' The user does not have permission to delete the directory or subdirectory.
'
' T:System.IO.IOException:
' A file in the directory or subdirectory is in use.
'
' T:System.NotSupportedException:
' The directory name contains a colon (:).
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.Security.SecurityException:
' The user does not have required permissions.
'
' T:System.OperationCanceledException:
' The user cancels the operation or the directory cannot be deleted.
DeleteDirectory
'
' Summary:
' Deletes a file.
'
' Parameters:
' file:
' Name and path of the file to be deleted.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; it has a trailing
' slash where a file must be specified; or it is a device path (starts with \\.\).
'
' T:System.ArgumentNullException:
' file is Nothing or an empty string.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.IO.IOException:
' The file is in use.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.IO.FileNotFoundException:
' The file does not exist.
'
' T:System.UnauthorizedAccessException:
' The user does not have permission to delete the file or the file is read-only.
DeleteFile
'
' Summary:
' Moves a directory from one location to another.
'
' Parameters:
' sourceDirectoryName:
' Path of the directory to be moved.
'
' destinationDirectoryName:
' Path of the directory to which the source directory is being moved.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.
'
' T:System.ArgumentNullException:
' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The directory does not exist.
'
' T:System.IO.IOException:
' The source is a root directory or The source path and the target path are the
' same.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.InvalidOperationException:
' The operation is cyclic.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user does not have required permission.
MoveDirectory
'
' Summary:
' Moves a file to a new location.
'
' Parameters:
' sourceFileName:
' Path of the file to be moved.
'
' destinationFileName:
' Path of the directory into which the file should be moved.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\); it ends with a trailing slash.
'
' T:System.ArgumentNullException:
' destinationFileName is Nothing or an empty string.
'
' T:System.IO.FileNotFoundException:
' The source file is not valid or does not exist.
'
' T:System.IO.IOException:
' The file is in use by another process, or an I/O error occurs.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
MoveFile
'
' Summary:
' Renames a directory.
'
' Parameters:
' directory:
' Path and name of directory to be renamed.
'
' newName:
' New name for directory.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentException:
' newName contains path information.
'
' T:System.ArgumentNullException:
' directory is Nothing.-or-newName is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The directory does not exist.
'
' T:System.IO.IOException:
' There is an existing file or directory with the name specified in newName.
'
' T:System.IO.PathTooLongException:
' The path exceeds 248 characters.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user does not have required permission.
RenameDirectory
'
' Summary:
' Renames a file.
'
' Parameters:
' file:
' File to be renamed.
'
' newName:
' New name of file.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentException:
' newName contains path information or ends with a backslash (\).
'
' T:System.ArgumentNullException:
' file is Nothing.-or-newName is Nothing or an empty string.
'
' T:System.IO.FileNotFoundException:
' The directory does not exist.
'
' T:System.IO.IOException:
' There is an existing file or directory with the name specified in newName.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user does not have required permission.
RenameFile
'
' Summary:
' Combines two paths and returns a properly formatted path.
'
' Parameters:
' baseDirectory:
' String. First path to be combined.
'
' relativePath:
' String. Second path to be combined.
'
' Returns:
' The combination of the specified paths.
'
' Exceptions:
' T:System.ArgumentException:
' baseDirectory or relativePath are malformed paths.
CombinePath
'
' Summary:
' Returns True if the specified directory exists.
'
' Parameters:
' directory:
' Path of the directory.
'
' Returns:
' True if the directory exists; otherwise False.
DirectoryExists
'
' Summary:
' Returns True if the specified file exists.
'
' Parameters:
' file:
' Name and path of the file.
'
' Returns:
' Returns True if the file exists; otherwise this method returns False.
'
' Exceptions:
' T:System.ArgumentException:
' The name of the file ends with a backslash (\).
FileExists
'
' Summary:
' Returns a read-only collection of strings representing the names of files containing
' the specified text.
'
' Parameters:
' directory:
' The directory to be searched.
'
' containsText:
' The search text.
'
' ignoreCase:
' True if the search should be case-sensitive; otherwise False. Default is True.
'
' searchType:
' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly.
'
' Returns:
' Read-only collection of the names of files containing the specified text..
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' directory is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The specified directory does not exist.
'
' T:System.IO.IOException:
' The specified directory points to an existing file.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' The specified directory path contains a colon (:) or is in an invalid format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user lacks necessary permissions.
FindInFiles
'
' Summary:
' Returns a collection of strings representing the path names of subdirectories
' within a directory.
'
' Parameters:
' directory:
' Name and path of directory.
'
' Returns:
' Read-only collection of the path names of subdirectories within the specified
' directory..
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' directory is Nothing or an empty string.
'
' T:System.IO.DirectoryNotFoundException:
' The specified directory does not exist.
'
' T:System.IO.IOException:
' The specified directory points to an existing file.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user lacks necessary permissions.
GetDirectories
'
' Summary:
' Returns a System.IO.DirectoryInfo object for the specified path.
'
' Parameters:
' directory:
' String. Path of directory.
'
' Returns:
' System.IO.DirectoryInfo object for the specified path.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' directory is Nothing or an empty string.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' The directory path contains a colon (:) or is in an invalid format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path
GetDirectoryInfo
'
' Summary:
' Returns a System.IO.DriveInfo object for the specified drive.
'
' Parameters:
' drive:
' Drive to be examined.
'
' Returns:
' System.IO.DriveInfo object for the specified drive.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' drive is Nothing or an empty string.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path
GetDriveInfo
'
' Summary:
' Returns a System.IO.FileInfo object for the specified file.
'
' Parameters:
' file:
' Name and path of the file.
'
' Returns:
' System.IO.FileInfo object for the specified file
'
' Exceptions:
' T:System.ArgumentException:
' The path name is malformed. For example, it contains invalid characters or is
' only white space. The file name has a trailing slash mark.
'
' T:System.ArgumentNullException:
' file is Nothing or an empty string.
'
' T:System.NotSupportedException:
' The path contains a colon in the middle of the string.
'
' T:System.IO.PathTooLongException:
' The path is too long.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions.
'
' T:System.UnauthorizedAccessException:
' The user lacks ACL (access control list) access to the file.
GetFileInfo
'
' Summary:
' Returns a read-only collection of strings representing the names of files within
' a directory.
'
' Parameters:
' directory:
' Directory to be searched.
'
' Returns:
' Read-only collection of file names from the specified directory.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentNullException:
' directory is Nothing.
'
' T:System.IO.DirectoryNotFoundException:
' The directory to search does not exist.
'
' T:System.IO.IOException:
' directory points to an existing file.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
'
' T:System.Security.SecurityException:
' The user lacks necessary permissions to view the path.
'
' T:System.UnauthorizedAccessException:
' The user lacks necessary permissions.
GetFiles
'
' Summary:
' Parses the file name out of the path provided.
'
' Parameters:
' path:
' Required. Path to be parsed. String.
'
' Returns:
' The file name from the specified path.
GetName
'
' Summary:
' Returns the parent path of the provided path.
'
' Parameters:
' path:
' Path to be examined.
'
' Returns:
' The parent path of the provided path.
'
' Exceptions:
' T:System.ArgumentException:
' The path is not valid for one of the following reasons: it is a zero-length string;
' it contains only white space; it contains invalid characters; or it is a device
' path (starts with \\.\).
'
' T:System.ArgumentException:
' Path does not have a parent path because it is a root path.
'
' T:System.ArgumentNullException:
' path is Nothing.
'
' T:System.IO.PathTooLongException:
' The path exceeds the system-defined maximum length.
'
' T:System.NotSupportedException:
' A file or directory name in the path contains a colon (:) or is in an invalid
' format.
GetParentPath
'
' Summary:
' Creates a uniquely named zero-byte temporary file on disk and returns the full
' path of that file.
'
' Returns:
' String containing the full path of the temporary file.
GetTempFileName
End Enum
End Namespace

@ -1,133 +0,0 @@
#Region "Microsoft.VisualBasic::ea59a5e11880b4d0f4759ad740bb81fe, ComputingServices\FileSystem\Protocols\FileURI.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 FileURI
'
' Properties: EntryPoint, File, IsLocal
'
' Constructor: (+3 Overloads) Sub New
'
' Function: ToString
'
' Sub: FileStreamParser
'
'
' /********************************************************************************/
#End Region
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic.Net
Namespace FileSystem.Protocols
''' <summary>
''' Represents a local file or remote file its location on the network.
''' ()
''' </summary>
Public Class FileURI
''' <summary>
''' The services portal of this remote filesystem object.
''' ()
''' </summary>
''' <returns></returns>
Public Property EntryPoint As IPEndPoint
''' <summary>
''' The reference location of this file system object on the target machine.
''' ((<see cref="EntryPoint"/>))
''' </summary>
''' <returns></returns>
Public Property File As String
''' <summary>
''' Is this file system object is a local file?.()
''' </summary>
''' <returns></returns>
Public ReadOnly Property IsLocal As Boolean
Get
Return EntryPoint Is Nothing
End Get
End Property
Sub New(uri As String)
Dim addr As String = Regex.Match(uri, "^\d+@\d+(\.\d+){3}[:]\/\/").Value
If String.IsNullOrEmpty(addr) Then '
File = uri
EntryPoint = Nothing
Else '
File = uri.Replace(addr, "")
Dim Tokens As String() = addr.Split(":"c).First.Split("@"c)
EntryPoint = New IPEndPoint(Tokens(1), Scripting.CTypeDynamic(Of Integer)(Tokens(Scan0)))
End If
End Sub
Sub New(path As String, portal As IPEndPoint)
File = path
EntryPoint = portal
End Sub
Sub New()
End Sub
''' <summary>
''' {port}@{ipaddress}://C:\xxx\xxx.file
''' </summary>
''' <returns></returns>
Public Overrides Function ToString() As String
If EntryPoint Is Nothing Then
Return File
Else
Return $"{EntryPoint.Port}@{EntryPoint.IPAddress}://{File}"
End If
End Function
''' <summary>
''' port@remote_IP://hash+&lt;path>
''' </summary>
''' <param name="uri"></param>
''' <param name="remote"></param>
''' <param name="handle"></param>
Public Shared Sub FileStreamParser(uri As String, ByRef remote As IPEndPoint, ByRef handle As FileHandle)
Dim file As New FileURI(uri)
remote = file.EntryPoint
uri = file.File
Dim hash As String = Regex.Match(uri, "^\d+\+").Value
uri = Mid(uri, hash.Length + 1)
handle = New FileHandle With {
.FileName = uri,
.HashCode = Scripting.CTypeDynamic(Of Integer)(hash)
}
End Sub
End Class
End Namespace

@ -1,90 +0,0 @@
#Region "Microsoft.VisualBasic::1c9ceb1759fb47880f8050db75993dff, ComputingServices\FileSystem\Protocols\NetTransfer.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 NetTransfer
'
' Sub: Download, Transfer, Upload
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Imports Microsoft.VisualBasic.Serialization
Namespace FileSystem.Protocols
Public Module NetTransfer
''' <summary>
'''
''' </summary>
''' <param name="local"></param>
''' <param name="destination"></param>
''' <param name="remote"></param>
Public Sub Upload(local As String, destination As String, remote As IPEndPoint)
Using file As New IO.RemoteFileStream(destination, FileMode.OpenOrCreate, remote)
Dim localFile As New FileStream(local, FileMode.Open)
Call Transfer(localFile, file, 1024 * 1024)
End Using
End Sub
Public Sub Transfer(source As Stream, target As Stream, bufLen As Integer)
Dim buffer As Byte() = New Byte(bufLen - 1) {}
Do While source.Position < source.Length
Dim d As Integer = (source.Length - source.Position) - buffer.Length
If d < 0 Then ' d
buffer = New Byte(-d - 1) {}
End If
Call source.Read(buffer, Scan0, buffer.Length)
Call target.Write(buffer, Scan0, buffer.Length)
Call target.Flush()
Loop
End Sub
Public Sub Download(destination As String, local As String, remote As IPEndPoint)
Using file As New IO.RemoteFileStream(destination, FileMode.OpenOrCreate, remote)
Dim localFile As New FileStream(local, FileMode.OpenOrCreate)
Call Transfer(file, localFile, 1024 * 1024)
End Using
End Sub
End Module
End Namespace

@ -1,92 +0,0 @@
#Region "Microsoft.VisualBasic::aca05c9a4d4b828005757006ecd85b3b, ComputingServices\FileSystem\Protocols\Protocols.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 API
'
' Properties: ProtocolEntry
'
' Function: GetSetLength, GetSetReadPosition, OpenHandle
'
'
' /********************************************************************************/
#End Region
Imports System.IO
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Imports Microsoft.VisualBasic.Serialization
Namespace FileSystem.Protocols
''' <summary>
'''
''' </summary>
Public Module API
Public ReadOnly Property ProtocolEntry As Long =
New Protocol(GetType(FileSystemAPI)).EntryPoint
Public Function OpenHandle(file As String, mode As FileMode, access As FileAccess) As RequestStream
Dim params As New FileOpen With {
.FileName = file,
.Mode = mode,
.Access = access
}
Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.OpenHandle, params)
End Function
''' <summary>
'''
''' </summary>
''' <param name="pos">-100set</param>
''' <param name="handle"></param>
''' <returns></returns>
Public Function GetSetReadPosition(pos As Long, handle As FileHandle) As RequestStream
Dim args As New FileStreamPosition(handle) With {.Position = pos}
Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.FilePosition, args)
End Function
''' <summary>
'''
''' </summary>
''' <param name="handle"></param>
''' <returns></returns>
Public Function GetSetLength(length As Long, handle As FileHandle) As RequestStream
Dim args As New FileStreamPosition(handle) With {.Position = length}
Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.FileStreamLength, args)
End Function
End Module
End Namespace

@ -1,125 +0,0 @@
#Region "Microsoft.VisualBasic::c58483be8460f06ce344738ca838bb24, ComputingServices\SharedMemory\HashValue.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 HashValue
'
' Properties: Identifier, Type, value
'
' Constructor: (+1 Overloads) Sub New
' Function: GetValueJson, ToString
'
' Structure Argv
'
' Properties: Identifier, value
'
' Constructor: (+1 Overloads) Sub New
' Function: ToString
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic
Imports Microsoft.VisualBasic.Scripting.MetaData
Imports Microsoft.VisualBasic.Serialization
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace SharedMemory
''' <summary>
''' The shared variable on the remote machine.
''' </summary>
Public Class HashValue : Implements INamedValue
''' <summary>
''' The variable name
''' </summary>
''' <returns></returns>
Public Property Identifier As String Implements INamedValue.Key
''' <summary>
''' variable value
''' </summary>
''' <returns></returns>
Public Property value As Object
''' <summary>
''' Simple type information
''' </summary>
''' <returns></returns>
Public Property Type As TypeInfo
Sub New(name As String, x As Object)
Identifier = name
value = x
Type = New TypeInfo(x.GetType)
End Sub
''' <summary>
''' Json serialization for the network transfer.
''' </summary>
''' <returns></returns>
Public Function GetValueJson() As String
Return JsonContract.GetObjectJson(value, Type.GetType(True))
End Function
Public Overrides Function ToString() As String
Return $"Dim {Identifier} As {Type.ToString} = {JsonContract.GetObjectJson(value, Type.GetType(True))}"
End Function
End Class
''' <summary>
''' Variable value for the network transfer
''' </summary>
Public Structure Argv : Implements INamedValue
''' <summary>
''' The variable name
''' </summary>
''' <returns></returns>
Public Property Identifier As String Implements INamedValue.Key
''' <summary>
''' Json value, and the type information is also included in this property.
''' </summary>
''' <returns></returns>
Public Property value As TaskHost.Argv
Sub New(name As String, x As Object)
Identifier = name
value = New TaskHost.Argv(x)
End Sub
Public Overrides Function ToString() As String
Return Me.GetJson
End Function
End Structure
End Namespace

@ -1,149 +0,0 @@
#Region "Microsoft.VisualBasic::f1497ae2c071750c405e5def5d49cd13, ComputingServices\SharedMemory\MemoryServices.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 MemoryServices
'
' Constructor: (+1 Overloads) Sub New
'
' Function: [TypeOf], Allocate, GetValue, IsCompatible, Run
' SetValue, ToString
'
' Sub: (+2 Overloads) Dispose
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.ComponentModel
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace SharedMemory
''' <summary>
''' Shared the memory with the remote machine.
''' </summary>
Public Class MemoryServices : Implements IDisposable
Implements ITaskDriver
''' <summary>
''' Gets the memory data from remote machine.
''' </summary>
''' <typeparam name="T"></typeparam>
''' <param name="name">使NameOf</param>
''' <returns></returns>
Public Function GetValue(Of T)(name As String) As T
Return __remote.ReadValue(Of T)(name)
End Function
''' <summary>
'''
''' </summary>
''' <typeparam name="T"></typeparam>
''' <param name="name">使NameOf</param>
''' <param name="value"></param>
''' <returns></returns>
Public Function SetValue(Of T)(name As String, value As T) As Boolean
Return __remote.WriteValue(name, value)
End Function
Public Function [TypeOf](name As String) As Type
Return __remote.TypeOf(name)
End Function
Public Function IsCompatible(Of T)(name As String, x As T) As Boolean
Dim type As Type = [TypeOf](name)
Dim ref As Type = GetType(T)
Return type.Equals(ref) OrElse ref.IsInheritsFrom(type)
End Function
ReadOnly __remote As IPEndPoint
ReadOnly __localSvr As SharedSvr
''' <summary>
'''
''' </summary>
''' <param name="remote"></param>
''' <param name="local">local services port that provides to the remote</param>
Sub New(remote As IPEndPoint, local As Integer)
__remote = remote
__localSvr = New SharedSvr(local)
End Sub
Public Function Allocate(name As String, value As Object, Optional [overrides] As Boolean = False) As Boolean
Return __localSvr.Allocate(name, value, [overrides])
End Function
Public Overrides Function ToString() As String
Return __remote.GetJson
End Function
Public Function Run() As Integer Implements ITaskDriver.Run
Return __localSvr.Run
End Function
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
Call __localSvr.Dispose()
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
Dispose(True)
' TODO: uncomment the following line if Finalize() is overridden above.
' GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
End Namespace

@ -1,111 +0,0 @@
#Region "Microsoft.VisualBasic::cd447f9172100e00081232e47d07a5e3, ComputingServices\SharedMemory\Protocols.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 Protocols
'
'
' Enum MemoryProtocols
'
' [TypeOf], Read, Write
'
'
'
'
'
' Properties: ProtocolEntry
'
' Function: [TypeOf], (+3 Overloads) ReadValue, (+2 Overloads) WriteValue
'
'
' /********************************************************************************/
#End Region
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Net
Imports Microsoft.VisualBasic.Net.Http
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Imports Microsoft.VisualBasic.Net.Tcp
Imports Microsoft.VisualBasic.Scripting.MetaData
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace SharedMemory
Module Protocols
Public Enum MemoryProtocols
Read
Write
[TypeOf]
End Enum
Public ReadOnly Property ProtocolEntry As Long = New Protocol(GetType(MemoryProtocols)).EntryPoint
<Extension>
Public Function [TypeOf](remote As IPEndPoint, name As String) As Type
Dim req As New RequestStream(ProtocolEntry, MemoryProtocols.TypeOf, name)
Dim ref As TypeInfo = req.LoadObject(Of TypeInfo)
Return ref.GetType(True)
End Function
Public Function ReadValue(name As String) As RequestStream
Return New RequestStream(ProtocolEntry, MemoryProtocols.Read, name)
End Function
Public Function WriteValue(name As String, value As Object) As RequestStream
Dim json As New Argv(name, value)
Dim req As New RequestStream(ProtocolEntry, MemoryProtocols.Write, json.GetJson)
Return req
End Function
<Extension>
Public Function ReadValue(remote As IPEndPoint, name As String, type As Type) As Object
Dim req As RequestStream = ReadValue(name)
Dim rep As RequestStream = New TcpRequest(remote).SendMessage(req)
Return JsonContract.LoadObject(rep.GetUTF8String, type)
End Function
<Extension>
Public Function ReadValue(Of T)(remote As IPEndPoint, name As String) As T
Return DirectCast(remote.ReadValue(name, GetType(T)), T)
End Function
<Extension>
Public Function WriteValue(remote As IPEndPoint, name As String, value As Object) As Boolean
Dim req As RequestStream = WriteValue(name, value)
Dim rep As RequestStream = New TcpRequest(remote).SendMessage(req)
Return rep.Protocol = HTTP_RFC.RFC_OK
End Function
End Module
End Namespace

@ -1,179 +0,0 @@
#Region "Microsoft.VisualBasic::82604e6c81155abbea4b93f4ca4eb7ca, ComputingServices\SharedMemory\SharedSvr.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 SharedSvr
'
' Constructor: (+1 Overloads) Sub New
'
' Function: __typeOf, Allocate, Read, Run, ToString
' Write
'
' Sub: (+2 Overloads) Dispose
'
'
' /********************************************************************************/
#End Region
Imports Microsoft.VisualBasic.ComponentModel
Imports Microsoft.VisualBasic.ComponentModel.Collection
Imports Microsoft.VisualBasic.Net.Http
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
Imports Microsoft.VisualBasic.Net.Tcp
Imports Microsoft.VisualBasic.Scripting.MetaData
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace SharedMemory
''' <summary>
''' Memory shared services.
''' </summary>
'''
<Protocol(GetType(Protocols.MemoryProtocols))>
Public Class SharedSvr : Implements IDisposable
Implements ITaskDriver
ReadOnly __localSvr As TcpServicesSocket
''' <summary>
''' 使
''' </summary>
ReadOnly __variables As New Dictionary(Of HashValue)
Sub New(local As Integer)
__localSvr = New TcpServicesSocket(local)
__localSvr.Responsehandler = AddressOf New ProtocolHandler(Me).HandleRequest
End Sub
''' <summary>
'''
''' </summary>
''' <param name="name"></param>
''' <param name="value"></param>
''' <param name="[overrides]">If the value type is not equals, overrides the exists value?</param>
''' <returns>Write or update the memory success?</returns>
Public Function Allocate(name As String, value As Object, Optional [overrides] As Boolean = False) As Boolean
If __variables.ContainsKey(name) Then
Dim x As HashValue = __variables ^ name
Dim type As Type = value.GetType
If type.Equals(x.value.GetType) Then
x.value = value
Else
If [overrides] Then
x.value = value
Else
Return False
End If
End If
Else
__variables.Add(name, New HashValue(name, value))
End If
Return True
End Function
<Protocol(MemoryProtocols.TypeOf)>
Private Function __typeOf(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream
Dim name As String = args.GetUTF8String
Dim type As TypeInfo
If __variables.ContainsKey(name) Then
type = __variables(name).Type
Else
type = New TypeInfo(GetType(Void))
End If
Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, type.GetJson)
End Function
<Protocol(MemoryProtocols.Read)>
Private Function Read(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream
Dim name As String = args.GetUTF8String
If __variables.ContainsKey(name) Then
Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, __variables(name).GetValueJson)
Else
Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, "null")
End If
End Function
<Protocol(MemoryProtocols.Write)>
Private Function Write(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream
Dim value As Argv = args.LoadObject(Of Argv)
Dim b As Long = If(Allocate(value.Identifier, value.value.GetValue), HTTP_RFC.RFC_OK, HTTP_RFC.RFC_INTERNAL_SERVER_ERROR)
Return New RequestStream(b, b, CStr(b))
End Function
Public Overrides Function ToString() As String
Return __localSvr.ToString
End Function
Public Function Run() As Integer Implements ITaskDriver.Run
Return __localSvr.Run
End Function
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
Call __localSvr.Dispose()
Call __variables.Clear()
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
Dispose(True)
' TODO: uncomment the following line if Finalize() is overridden above.
' GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
End Namespace
Loading…
Cancel
Save