code style improvements

This commit is contained in:
xieguigang 2018-10-05 21:53:43 +08:00
parent 8e0c9eed86
commit fa930c92fa
2 changed files with 84 additions and 84 deletions

View File

@ -1,51 +1,51 @@
#Region "Microsoft.VisualBasic::2b0445de7dfb962360dc63693f8cbfeb, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Network\Protocol\Reflection\AppMgr.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/>.
' 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:
' Summaries:
' Class AppMgr
'
' Properties: ProtocolApps, ProtocolEntry
'
' Constructor: (+1 Overloads) Sub New
' Function: HandleRequest, Register, RegisterApp
'
'
' /********************************************************************************/
' Class AppMgr
'
' Properties: ProtocolApps, ProtocolEntry
'
' Constructor: (+1 Overloads) Sub New
' Function: HandleRequest, Register, RegisterApp
'
'
' /********************************************************************************/
#End Region
Imports System.Net
Imports Microsoft.VisualBasic.Net.Abstract
Imports Microsoft.VisualBasic.Net.Http
Imports TcpEndPoint = System.Net.IPEndPoint
Namespace Net.Protocols.Reflection
@ -54,8 +54,7 @@ Namespace Net.Protocols.Reflection
''' </summary>
Public Class AppMgr : Inherits IProtocolHandler
Public ReadOnly Property ProtocolApps As Dictionary(Of Long, ProtocolHandler) =
New Dictionary(Of Long, ProtocolHandler)
Public ReadOnly Property ProtocolApps As New Dictionary(Of Long, ProtocolHandler)
Public Overrides ReadOnly Property ProtocolEntry As Long
Get
@ -68,20 +67,22 @@ Namespace Net.Protocols.Reflection
End Sub
Public Function Register(app As Object, [overrides] As Boolean) As Boolean
Dim Protocol = ProtocolHandler.SafelyCreateObject(app)
Dim protocol = ProtocolHandler.SafelyCreateObject(app)
If Protocol Is Nothing Then
If protocol Is Nothing Then
Return False
End If
If ProtocolApps.ContainsKey(Protocol.ProtocolEntry) Then
If ProtocolApps.ContainsKey(protocol.ProtocolEntry) Then
If [overrides] Then
Call ProtocolApps.Remove(Protocol.ProtocolEntry) ' 覆盖掉原有的协议数据
' 覆盖掉原有的协议数据
Call ProtocolApps.Remove(protocol.ProtocolEntry)
Else
Return False ' 没有被注册
' 没有被注册
Return False
End If
End If
Call ProtocolApps.Add(Protocol.ProtocolEntry, Protocol)
Call ProtocolApps.Add(protocol.ProtocolEntry, protocol)
Return True
End Function
@ -97,13 +98,13 @@ Namespace Net.Protocols.Reflection
Return Register(DirectCast(App, Object), [overrides])
End Function
Public Overrides Function HandleRequest(request As RequestStream, remoteDevcie As System.Net.IPEndPoint) As RequestStream
Public Overrides Function HandleRequest(request As RequestStream, remoteDevcie As TcpEndPoint) As RequestStream
If Not ProtocolApps.ContainsKey(request.ProtocolCategory) Then
Return NetResponse.RFC_NOT_FOUND
End If
Dim Protocol As ProtocolHandler = ProtocolApps(request.ProtocolCategory)
Return Protocol.HandleRequest(request, remoteDevcie)
Dim protocol As ProtocolHandler = ProtocolApps(request.ProtocolCategory)
Return protocol.HandleRequest(request, remoteDevcie)
End Function
End Class
End Namespace

View File

@ -1,49 +1,48 @@
#Region "Microsoft.VisualBasic::c398a6f52c8a576693287a14ae9a4418, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Network\Protocol\Reflection\ProtocolHandler.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/>.
' 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:
' Summaries:
' Class ProtocolHandler
'
' Properties: DeclaringType, ProtocolEntry
'
' Constructor: (+1 Overloads) Sub New
' Function: GetMethod, HandlePush, HandleRequest, (+2 Overloads) SafelyCreateObject, ToString
'
'
' /********************************************************************************/
' Class ProtocolHandler
'
' Properties: DeclaringType, ProtocolEntry
'
' Constructor: (+1 Overloads) Sub New
' Function: GetMethod, HandlePush, HandleRequest, (+2 Overloads) SafelyCreateObject, ToString
'
'
' /********************************************************************************/
#End Region
Imports System.Net
Imports Microsoft.VisualBasic.Net.Abstract
Imports Microsoft.VisualBasic.Net.Http
@ -54,7 +53,7 @@ Namespace Net.Protocols.Reflection
''' </summary>
Public Class ProtocolHandler : Inherits IProtocolHandler
Protected Protocols As Dictionary(Of Long, Net.Abstract.DataRequestHandler)
Protected Protocols As Dictionary(Of Long, DataRequestHandler)
''' <summary>
''' 这个类型建议一般为某种枚举类型
''' </summary>