diff --git a/47-dotnet_Microsoft.VisualBasic.sln b/47-dotnet_Microsoft.VisualBasic.sln
index 0e295273..acade65c 100644
--- a/47-dotnet_Microsoft.VisualBasic.sln
+++ b/47-dotnet_Microsoft.VisualBasic.sln
@@ -263,8 +263,8 @@ Global
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|Win32.ActiveCfg = Debug|Any CPU
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|Win32.Build.0 = Debug|Any CPU
- {8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x64.ActiveCfg = Debug|Any CPU
- {8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x64.Build.0 = Debug|Any CPU
+ {8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x64.ActiveCfg = Debug|x64
+ {8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x64.Build.0 = Debug|x64
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x86.ActiveCfg = Debug|x86
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.Debug|x86.Build.0 = Debug|x86
{8CDE6B49-9B2B-4A0E-8954-5A46E9AECB88}.DEMO|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/47-dotnet_Microsoft.VisualBasic.vbproj b/47-dotnet_Microsoft.VisualBasic.vbproj
index 272fc665..3386f22e 100644
--- a/47-dotnet_Microsoft.VisualBasic.vbproj
+++ b/47-dotnet_Microsoft.VisualBasic.vbproj
@@ -91,7 +91,7 @@
true
true
true
- ..\..\..\..\GCModeller\bin\
+ bin\
FRAMEWORD_CORE=1
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
@@ -104,9 +104,9 @@
true
true
- ..\..\..\..\GCModeller\bin\
+ bin\
FRAMEWORD_CORE=1
- false
+ true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
false
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
@@ -166,7 +166,7 @@
true
true
- ..\..\..\..\GCModeller\bin\
+ ..\CLI_tools\MLkit\Apps\
FRAMEWORD_CORE=1
true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
@@ -333,9 +333,9 @@
true
true
- ..\..\..\..\..\smartnucl_integrative\biodeepDB\METLINApp\App\
+ bin\app\
FRAMEWORD_CORE=1
- false
+ true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
false
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
@@ -385,9 +385,9 @@
FRAMEWORD_CORE=1
true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
- true
+ false
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
- Full
+ full
x64
On
AllRules.ruleset
@@ -571,7 +571,7 @@
FRAMEWORD_CORE=1,UNIX=1
true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
- true
+ false
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
Full
x64
@@ -619,7 +619,7 @@
FRAMEWORD_CORE=1,UNIX=1
true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
- true
+ false
41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
Full
x64
@@ -794,7 +794,7 @@
true
true
bin\x64\Biostack\
- FRAMEWORD_CORE=1
+ FRAMEWORD_CORE=1,UNIX=True
true
Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
true
@@ -899,6 +899,78 @@
On
AllRules.ruleset
+
+ true
+ true
+ true
+ bin\node-debug\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ AnyCPU
+ AllRules.ruleset
+
+
+ true
+ true
+ true
+ bin\x64\node-debug\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ x64
+ AllRules.ruleset
+
+
+ true
+ true
+ true
+ bin\x86\node-debug\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ x86
+ AllRules.ruleset
+
+
+ true
+ true
+ true
+ bin\test\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ AnyCPU
+ AllRules.ruleset
+
+
+ true
+ true
+ true
+ bin\x64\test\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ x64
+ AllRules.ruleset
+
+
+ true
+ true
+ true
+ bin\x86\test\
+ FRAMEWORD_CORE=1
+ Microsoft.VisualBasic.Framework_v47_dotnet_8da45dcd8060cc9a.xml
+ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
+ full
+ x86
+ AllRules.ruleset
+
@@ -942,10 +1014,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -953,17 +1044,20 @@
+
+
+
-
+
@@ -971,11 +1065,12 @@
-
+
-
+
+
@@ -993,7 +1088,7 @@
-
+
@@ -1011,10 +1106,10 @@
-
-
-
-
+
+
+
+
@@ -1025,6 +1120,7 @@
+
@@ -1037,12 +1133,12 @@
-
+
-
-
-
+
+
+
@@ -1069,7 +1165,7 @@
-
+
@@ -1078,7 +1174,7 @@
-
+
@@ -1102,6 +1198,7 @@
+
@@ -1128,7 +1225,7 @@
-
+
@@ -1223,15 +1320,15 @@
-
+
-
-
+
+
@@ -1243,17 +1340,17 @@
-
-
-
-
-
+
+
+
+
+
-
+
@@ -1262,7 +1359,7 @@
-
+
@@ -1445,9 +1542,9 @@
-
+
-
+
@@ -1489,7 +1586,7 @@
-
+
@@ -1504,7 +1601,7 @@
-
+
@@ -1556,7 +1653,7 @@
-
+
diff --git a/ApplicationServices/App.vb b/ApplicationServices/App.vb
index e8987d41..71eeed9f 100644
--- a/ApplicationServices/App.vb
+++ b/ApplicationServices/App.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::11d59e8cf799bd8b63b30b390b05215b, ApplicationServices\App.vb"
+#Region "Microsoft.VisualBasic::215525b640c608ea63aa1549f3a52762, Microsoft.VisualBasic.Core\ApplicationServices\App.vb"
' Author:
'
@@ -39,23 +39,22 @@
' InputFile, IsConsoleApp, IsMicrosoftPlatform, LocalData, LocalDataTemp
' LogErrDIR, NanoTime, NextTempName, OutFile, PID
' Platform, PreviousDirectory, Process, ProductName, ProductProgramData
- ' ProductSharedDIR, ProductSharedTemp, References, Running, RunTimeDirectory
- ' StartTime, StartupDirectory, StdErr, StdOut, SysTemp
- ' UnixTimeStamp, UserHOME, Version
+ ' ProductSharedDIR, ProductSharedTemp, References, Running, RunningInGitBash
+ ' RunTimeDirectory, StartTime, StartupDirectory, StdErr, StdInput
+ ' StdOut, SysTemp, UnixTimeStamp, UserHOME, Version
'
' Constructor: (+1 Overloads) Sub New
'
- ' Function: __cli, __isMicrosoftPlatform, __listFiles, __sysTEMP, (+2 Overloads) Argument
- ' BugsFormatter, CLICode, ElapsedMilliseconds, Exit, finalizeCLI
- ' FormatTime, GenerateTemp, (+2 Overloads) GetAppLocalData, GetAppSysTempFile, GetAppVariables
- ' GetFile, GetNextUniqueName, GetProductSharedDIR, GetProductSharedTemp, GetTempFile
- ' GetVariable, (+3 Overloads) LogException, NullDevice, (+10 Overloads) RunCLI, RunCLIInternal
- ' SelfFolk, SelfFolks, Shell, tempCode, TemporaryEnvironment
- ' TraceBugs
+ ' Function: __isMicrosoftPlatform, __listFiles, __sysTEMP, (+2 Overloads) Argument, BugsFormatter
+ ' CLICode, ElapsedMilliseconds, Exit, finalizeCLI, FormatTime
+ ' GenerateTemp, (+2 Overloads) GetAppLocalData, GetAppSysTempFile, GetAppVariables, GetFile
+ ' GetNextUniqueName, GetProductSharedDIR, GetProductSharedTemp, GetTempFile, GetVariable
+ ' (+3 Overloads) LogException, NullDevice, (+10 Overloads) RunCLI, RunCLIInternal, SelfFolk
+ ' SelfFolks, Shell, tempCode, TemporaryEnvironment, TraceBugs
'
- ' Sub: __GCThreadInvoke, __removesTEMP, AddExitCleanHook, FlushMemory, Free
- ' JoinVariable, (+2 Overloads) JoinVariables, Pause, (+2 Overloads) println, RunAsAdmin
- ' SetBufferSize, StartGC, StopGC
+ ' Sub: [Stop], __GCThreadInvoke, __removesTEMP, AddExitCleanHook, FlushMemory
+ ' Free, JoinVariable, (+2 Overloads) JoinVariables, Pause, (+2 Overloads) println
+ ' RunAsAdmin, SetBufferSize, StartGC, StopGC
'
' /********************************************************************************/
@@ -175,10 +174,11 @@ Public Module App
Public ReadOnly Property StdErr As New StreamWriter(Console.OpenStandardError)
'''
- ''' as default text output device.
+ ''' as default text output device. []
'''
'''
Public ReadOnly Property StdOut As [Default](Of TextWriter) = Console.OpenStandardOutput.OpenTextWriter
+ Public ReadOnly Property StdInput As [Default](Of TextReader) = New StreamReader(Console.OpenStandardInput)
'''
''' Get the id(PID) of the current program process.
@@ -194,7 +194,7 @@ Public Module App
''' Gets the command-line arguments for this .
'''
''' Gets the command-line arguments for this process.
- Public ReadOnly Property CommandLine As CommandLine.CommandLine = __cli()
+ Public ReadOnly Property CommandLine As CommandLine.CommandLine = GitBashEnvironment.GetCLIArgs()
'''
''' Get argument value from .
@@ -223,28 +223,8 @@ Public Module App
Return CommandLine(name)
End Function
- '''
- ''' Enable .NET application running from git bash terminal
- '''
- Const gitBash$ = "C:/Program Files/Git"
-
- '''
- ''' Makes compatibility with git bash: = ``C:/Program Files/Git``
- '''
- '''
- Private Function __cli() As CommandLine.CommandLine
- ' 第一个参数为应用程序的文件路径,不需要
- Dim tokens$() =
- Environment.GetCommandLineArgs _
- .Skip(1) _
- .Select(Function(t) t.Replace(gitBash, "")) _
- .ToArray
- Dim cliString$ = tokens.JoinBy(" ")
- Dim cli = CLITools.TryParse(tokens, False, cliString)
- Return cli
- End Function
-
Public ReadOnly Property Github As String = LICENSE.githubURL
+ Public ReadOnly Property RunningInGitBash As Boolean = GitBashEnvironment.isRunningOnGitBash()
'''
''' Returns the argument portion of the used to start Visual Basic or
@@ -460,7 +440,7 @@ Public Module App
End If
Call FileIO.FileSystem.CreateDirectory(AppSystemTemp)
- Call FileIO.FileSystem.CreateDirectory(App.HOME & "/Resources/")
+ ' Call FileIO.FileSystem.CreateDirectory(App.HOME & "/Resources/")
' 2018-08-14 因为经过测试发现text encoding模块会优先于命令行参数设置模块的初始化的加载
' 所以会导致环境变量为空
@@ -494,15 +474,15 @@ Public Module App
#Region "这里的环境变量方法主要是操作从命令行之中所传递进来的额外的参数的"
- Dim __joinedVariables As New Dictionary(Of NamedValue(Of String))
+ Dim m_joinedVariables As New Dictionary(Of NamedValue(Of String))
'''
''' 添加参数到应用程序的环境变量之中
'''
- '''
+ ''' 如果给定的当前这个参数名称存在于当前框架环境中,则会更新原来的值
'''
Public Sub JoinVariable(name$, value$)
- __joinedVariables(name) =
+ m_joinedVariables(name) =
New NamedValue(Of String) With {
.Name = name,
.Value = value
@@ -515,7 +495,7 @@ Public Module App
'''
Public Sub JoinVariables(ParamArray vars As NamedValue(Of String)())
For Each v As NamedValue(Of String) In vars
- __joinedVariables(v.Name) = v
+ m_joinedVariables(v.Name) = v
Next
End Sub
@@ -541,10 +521,10 @@ Public Module App
'''
''' 当没有查找到相对应的环境变量的时候会返回空值
Public Function GetVariable( Optional name$ = Nothing) As String
- If __joinedVariables.ContainsKey(name) Then
- Return __joinedVariables(name).Value
+ If m_joinedVariables.ContainsKey(name) Then
+ Return m_joinedVariables(name).Value
Else
- For Each v As NamedValue(Of String) In __joinedVariables.Values
+ For Each v As NamedValue(Of String) In m_joinedVariables.Values
If v.Name.TextEquals(name) Then
Return v.Value
End If
@@ -561,7 +541,7 @@ Public Module App
Public Function GetAppVariables() As NamedValue(Of String)()
Dim type As Type = GetType(App)
Dim pros = type.Schema(PropertyAccess.Readable, BindingFlags.Public Or BindingFlags.Static)
- Dim out As New List(Of NamedValue(Of String))(__joinedVariables.Values)
+ Dim out As New List(Of NamedValue(Of String))(m_joinedVariables.Values)
Dim value$
Dim o
@@ -649,7 +629,7 @@ Public Module App
'''
'''
'''
-
+
Public Sub FlushMemory()
Call GC.Collect()
Call GC.WaitForPendingFinalizers()
@@ -691,7 +671,7 @@ Public Module App
'''
'''
'''
-
+
Public Sub Pause(Optional prompted$ = "Press any key to continute...")
Call My.InnerQueue.WaitQueue()
Call Console.WriteLine(prompted)
@@ -703,6 +683,14 @@ Public Module App
End If
End Sub
+ '''
+ ''' Pause and then exit the application.
+ '''
+ Public Sub [Stop]()
+ Call App.Pause()
+ Call App.Exit()
+ End Sub
+
'''
''' 使用的位置会变化的,则使用本函数则会使用获取当前的模块的文件夹,即使其不是exe程序而是一个dll文件
'''
@@ -720,10 +708,10 @@ Public Module App
End Function
'''
- ''' Get current time in unix time stamp format.
+ ''' Get current time in ``xxxxx.xxxx`` unix time stamp format.
'''
'''
- Public ReadOnly Property UnixTimeStamp As Long
+ Public ReadOnly Property UnixTimeStamp As Double
Get
Return DateTimeHelper.UnixTimeStamp(Now)
@@ -734,18 +722,21 @@ Public Module App
''' The time tag of the application started.(应用程序的启动的时间)
'''
'''
- Public ReadOnly Property StartTime As Long = UnixTimeStamp
+ Public ReadOnly Property StartTime As Double = App.UnixTimeStamp
'''
''' The distance of time that this application running from start and to current time.
''' (当前距离应用程序启动所逝去的时间)
'''
'''
- '''
+ '''
+ ''' 通过以及得到的时间都是带小数的秒数
+ ''' 所以在这里计算出当前时间点与启动时间点之间的差值之后,还需要乘以1000才可以得到毫秒数
+ '''
Public Function ElapsedMilliseconds() As Long
- Dim nowLng As Long = App.UnixTimeStamp
- Dim d As Long = nowLng - StartTime
+ Dim nowLng As Double = App.UnixTimeStamp
+ Dim d As Long = (nowLng - StartTime) * 1000
Return d
End Function
@@ -1040,6 +1031,13 @@ Public Module App
#Region "CLI interpreter"
+ '''
+ ''' 当前的应用程序是否退出运行了? 当调用方法的时候, 除了会终止程序的运行
+ ''' 还会讲这个属性设置为False
+ '''
+ ''' 在应用程序框架中, 有一些组件的线程会需要依赖于这个属性值来自动停止运行
+ '''
+ '''
Public ReadOnly Property Running As Boolean = True
'''
@@ -1069,21 +1067,21 @@ Public Module App
''' The command line arguments value, which its value can be gets from the function.
''' Returns the function execute result to the operating system.
'''
-
+
Public Function RunCLI(Interpreter As Type, args$, Optional caller$ = Nothing) As Integer
Return Interpreter.RunCLIInternal(CLITools.TryParse(args), caller, Nothing, Nothing, Nothing)
End Function
'''
- ''' Running the string as a cli command line.(请注意,在调试模式之下,命令行解释器会在运行完命令之后暂停,而Release模式之下则不会。
+ ''' Running the string as a cli command line, Running the string as cli command line and the specific type define as a interpreter.
+ ''' (请注意,在调试模式之下,命令行解释器会在运行完命令之后暂停,而Release模式之下则不会。
''' 假若在调试模式之下发现程序有很长一段时间处于cpu占用为零的静止状态,则很有可能已经运行完命令并且等待回车退出)
'''
''' The command line arguments value, which its value can be gets from the function.
''' Returns the function execute result to the operating system.
'''
-
+
Public Function RunCLI(Interpreter As Type, args As CLI, Optional caller$ = Nothing) As Integer
Return Interpreter.RunCLIInternal(args, caller, Nothing, Nothing, Nothing)
End Function
@@ -1095,8 +1093,7 @@ Public Module App
''' The command line arguments value, which its value can be gets from the function.
''' Returns the function execute result to the operating system.
'''
-
+
Public Function RunCLI(Interpreter As Type, args As CLI, executeEmpty As ExecuteEmptyCLI,
Optional caller$ = Nothing) As Integer
diff --git a/ApplicationServices/Debugger.vb b/ApplicationServices/Debugger.vb
index b30eb70e..4d3120da 100644
--- a/ApplicationServices/Debugger.vb
+++ b/ApplicationServices/Debugger.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::04369fce4edad7572df6e2634f9e59eb, ApplicationServices\Debugger.vb"
+#Region "Microsoft.VisualBasic::4815a500fffdc82dad422f680b2f3652, Microsoft.VisualBasic.Core\ApplicationServices\Debugger.vb"
' Author:
'
@@ -38,8 +38,7 @@
'
' Properties: ForceSTDError, Mute, UsingxConsole
'
- ' Function: __DEBUG_ECHO, Assert, BENCHMARK, (+2 Overloads) PrintException, this
- ' Warning
+ ' Function: __DEBUG_ECHO, Assert, BENCHMARK, (+2 Overloads) PrintException, Warning
'
' Sub: (+2 Overloads) __DEBUG_ECHO, __INFO_ECHO, (+3 Overloads) Assertion, AttachLoggingDriver, cat
' (+3 Overloads) Echo, EchoLine, WaitOutput, WriteLine
@@ -80,7 +79,7 @@ Public Module VBDebugger
Public Function die(message$, Optional failure As Assert(Of Object) = Nothing, Optional caller$ = Nothing) As ExceptionHandle
Return New ExceptionHandle With {
- .Message = message,
+ .message = message,
.failure = failure Or defaultAssert
}
End Function
@@ -259,7 +258,7 @@ Public Module VBDebugger
Public Sub WriteLine(msg$, color As ConsoleColor)
- My.Log4VB.WriteLine(msg, color)
+ My.Log4VB.Println(msg, color)
End Sub
'''
@@ -372,20 +371,9 @@ Public Module VBDebugger
End Sub
Public Sub __DEBUG_ECHO(Of T)(value As T, Optional memberName As String = "")
- Call (Scripting.InputHandler.ToString(value) & " @" & memberName).__DEBUG_ECHO
+ Call ($"<{memberName}> {Scripting.InputHandler.ToString(value)}").__DEBUG_ECHO
End Sub
- '''
- ''' Returns the current function name.
- '''
- '''
- ''' The caller function name, do not assign any value to this parameter! Just leave it blank.
- '''
- '''
- Public Function this( Optional caller As String = "") As String
- Return caller
- End Function
-
Public Sub Echo(Of T)(array As IEnumerable(Of T), Optional memberName As String = "")
Call String.Join(", ", array.Select(Function(obj) Scripting.ToString(obj)).ToArray).__DEBUG_ECHO
End Sub
diff --git a/ApplicationServices/Debugger/Config.vb b/ApplicationServices/Debugger/Config.vb
deleted file mode 100644
index 1d1dfe87..00000000
--- a/ApplicationServices/Debugger/Config.vb
+++ /dev/null
@@ -1,87 +0,0 @@
-#Region "Microsoft.VisualBasic::e4116dfe0b06870e2dcf53a489a4fb5e, ApplicationServices\Debugger\Config.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 .
-
-
-
- ' /********************************************************************************/
-
- ' Summaries:
-
- ' Class Config
- '
- ' Properties: DefaultFile, level, mute
- '
- ' Function: Load, Save, ToString
- '
- '
- ' /********************************************************************************/
-
-#End Region
-
-Imports Microsoft.VisualBasic.Serialization.JSON
-
-Namespace ApplicationServices.Debugging
-
- Public Class Config
-
- Public Property level As DebuggerLevels = DebuggerLevels.On
- Public Property mute As Boolean = False
-
- Public Shared ReadOnly Property DefaultFile As String =
- App.LocalData & "/debugger-config.json"
-
- Public Shared Function Load() As Config
- Try
- Dim cfg As Config =
- IO.File.ReadAllText(DefaultFile).LoadJSON(Of Config)
-
- If cfg Is Nothing Then
- Return New Config().Save()
- Else
- Return cfg
- End If
- Catch ex As Exception When Not DefaultFile.FileExists
- Return New Config().Save()
- Catch ex As Exception
- Call App.LogException(ex)
-
- ' 假若是多进程的并行计算任务,则可能会出现默认配置文件被占用的情况,
- ' 这个也无能为力了, 只能够放弃读取, 直接使用默认的调试器参数
- Return New Config
- End Try
- End Function
-
- Private Function Save() As Config
- Call Me.GetJson.SaveTo(DefaultFile)
- Return Me
- End Function
-
- Public Overrides Function ToString() As String
- Return Me.GetJson
- End Function
- End Class
-End Namespace
diff --git a/ApplicationServices/Debugger/DebuggerArgs.vb b/ApplicationServices/Debugger/DebuggerArgs.vb
index df6589c9..a6a97e42 100644
--- a/ApplicationServices/Debugger/DebuggerArgs.vb
+++ b/ApplicationServices/Debugger/DebuggerArgs.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::45d782ae175d587a152a19d88a206ff7, ApplicationServices\Debugger\DebuggerArgs.vb"
+#Region "Microsoft.VisualBasic::7fcd2b47d1a839220c30c326d2bb5bc1, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\DebuggerArgs.vb"
' Author:
'
@@ -43,9 +43,8 @@
#End Region
Imports System.Runtime.CompilerServices
-Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Language.UnixBash
-Imports Microsoft.VisualBasic.Language.UnixBash.FileSystem
+Imports Microsoft.VisualBasic.My.FrameworkInternal
Imports CLI = Microsoft.VisualBasic.CommandLine.CommandLine
Namespace ApplicationServices.Debugging
@@ -76,7 +75,7 @@ Namespace ApplicationServices.Debugging
'''
'''
Private Sub __logShell(args As CLI)
- Dim CLI As String = App.ExecutablePath & " " & args.CLICommandArgvs
+ Dim CLI As String = App.ExecutablePath & " " & args.cliCommandArgvs
Dim log As String = $"{PS1.Fedora12.ToString} {CLI}"
Dim logFile As String = App.LogErrDIR.ParentPath & "/.shells.log"
@@ -176,7 +175,9 @@ Namespace ApplicationServices.Debugging
''' --echo on/off/all/warn/error --err <path.log>
Public Sub InitDebuggerEnvir(args As CLI, Optional caller$ = Nothing)
If Not String.Equals(caller, "Main") Then
- Return ' 这个调用不是从Main出发的,则不设置环境了,因为这个环境可能在其他的代码上面设置过了
+ ' 这个调用不是从Main出发的,则不设置环境了
+ ' 因为这个环境可能在其他的代码上面设置过了
+ Return
Else
Try
Call __logShell(args)
@@ -197,7 +198,8 @@ Namespace ApplicationServices.Debugging
Dim config As Config = Config.Load
- If String.IsNullOrEmpty(opt) Then ' 默认的on参数
+ If String.IsNullOrEmpty(opt) Then
+ ' 默认的on参数
VBDebugger.m_level = config.level
Else
Select Case opt.ToLower
@@ -213,7 +215,7 @@ Namespace ApplicationServices.Debugging
VBDebugger.m_level = DebuggerLevels.Error
Case Else
VBDebugger.m_level = DebuggerLevels.On
- Call Console.WriteLine($"[INFO] The debugger argument value --echo:={opt} is invalid, using default settings.")
+ Call $"The debugger argument value --echo:={opt} is invalid, using default settings.".Warning
End Select
End If
@@ -225,35 +227,7 @@ Namespace ApplicationServices.Debugging
VBDebugger.Mute = config.mute
End If
- Dim envir As Dictionary(Of String, String) = args.EnvironmentVariables
- Dim disableLoadOptions As Boolean = args.GetBoolean("--load_options.disable")
-
- ' --load_options.disable 开关将会禁止所有的环境项目的设置
- ' 但是环境变量任然会进行加载设置
-
- If Not disableLoadOptions AndAlso Not envir.IsNullOrEmpty Then
- If envir.ContainsKey("Proxy") Then
- WebServiceUtils.Proxy = envir("Proxy")
- Call $"[Config] webUtils_proxy={WebServiceUtils.Proxy}".__INFO_ECHO
- End If
- If envir.ContainsKey("setwd") Then
- App.CurrentDirectory = envir("setwd")
- Call $"[Config] current_work_directory={App.CurrentDirectory}".__INFO_ECHO
- End If
- If envir.ContainsKey("buffer_size") Then
- Call App.SetBufferSize(envir!buffer_size)
- End If
- End If
-
- ' /@var=name "value"
- For Each var As NamedValue(Of String) In args.ParameterList
- With var
- If InStr(.Name, "/@var=", CompareMethod.Text) = 1 Then
- Dim name$ = .Name.GetTagValue("=").Value
- Call App.JoinVariable(name, .Value)
- End If
- End With
- Next
+ Call config.ConfigFrameworkRuntime(args)
End Sub
End Module
End Namespace
diff --git a/ApplicationServices/Debugger/DebuggerLevels.vb b/ApplicationServices/Debugger/DebuggerLevels.vb
index 9b158c14..bc525678 100644
--- a/ApplicationServices/Debugger/DebuggerLevels.vb
+++ b/ApplicationServices/Debugger/DebuggerLevels.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::70fd68fd2eafbadf80da2922e0ec0b7d, ApplicationServices\Debugger\DebuggerLevels.vb"
+#Region "Microsoft.VisualBasic::70fd68fd2eafbadf80da2922e0ec0b7d, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\DebuggerLevels.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/Exception/ExceptionData.vb b/ApplicationServices/Debugger/Exception/ExceptionData.vb
index 613d5c6b..cd3355d1 100644
--- a/ApplicationServices/Debugger/Exception/ExceptionData.vb
+++ b/ApplicationServices/Debugger/Exception/ExceptionData.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::679f37232d839b0731209665afe32b3b, ApplicationServices\Debugger\Exception\ExceptionData.vb"
+#Region "Microsoft.VisualBasic::626d2b64093e22f3527641427fdc424e, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Exception\ExceptionData.vb"
' Author:
'
@@ -35,26 +35,16 @@
'
' Properties: Message, StackTrace, TypeFullName
'
- ' Function: CreateInstance, GetCurrentStackTrace, ToString
- '
- ' Class StackFrame
- '
- ' Properties: File, Line, Method
- '
- ' Function: Parser, ToString
- '
- ' Class Method
- '
- ' Properties: [Module], [Namespace], Method
- '
- ' Constructor: (+1 Overloads) Sub New
- ' Function: ToString
+ ' Function: CreateFromObject, CreateInstance, Exception, GetCurrentStackTrace, getMessages
+ ' ParseStackTrace, ToString
'
'
' /********************************************************************************/
#End Region
+Imports Microsoft.VisualBasic.Text
+
Namespace ApplicationServices.Debugging.Diagnostics
Public Class ExceptionData
@@ -63,10 +53,40 @@ Namespace ApplicationServices.Debugging.Diagnostics
Public Property Message As String()
Public Property StackTrace As StackFrame()
+ '''
+ ''' Create exception object for throw exception expression
+ '''
+ '''
+ Public Function Exception() As Exception
+ Return New Exception(Message.Select(Function(msg, i) $"{i}. {msg}").JoinBy(ASCII.LF)) With {
+ .Source = StackTrace.JoinBy(ASCII.LF)
+ }
+ End Function
+
Public Overrides Function ToString() As String
Return TypeFullName
End Function
+ Private Shared Iterator Function getMessages(ex As Exception) As IEnumerable(Of String)
+ Do While True
+ Yield ex.Message
+
+ If Not ex.InnerException Is Nothing Then
+ ex = ex.InnerException
+ Else
+ Exit Do
+ End If
+ Loop
+ End Function
+
+ Public Shared Function CreateFromObject(ex As Exception) As ExceptionData
+ Return New ExceptionData With {
+ .Message = getMessages(ex).ToArray,
+ .TypeFullName = ex.GetType.FullName,
+ .StackTrace = ParseStackTrace(ex.StackTrace)
+ }
+ End Function
+
Public Shared Function CreateInstance(messages$(), stackTrace$(), type$) As ExceptionData
Return New ExceptionData With {
.TypeFullName = type,
@@ -77,12 +97,8 @@ Namespace ApplicationServices.Debugging.Diagnostics
}
End Function
- '''
- ''' Parsing , gets current stack trace information.
- '''
- '''
- Public Shared Function GetCurrentStackTrace() As StackFrame()
- Return Environment.StackTrace _
+ Public Shared Function ParseStackTrace(stackTrace As String) As StackFrame()
+ Return stackTrace _
.LineTokens _
.Where(Function(s) Not s.StringEmpty) _
.Skip(3) _
@@ -92,71 +108,13 @@ Namespace ApplicationServices.Debugging.Diagnostics
End Function) _
.ToArray
End Function
- End Class
-
- Public Class StackFrame
'''
- ''' Method call
+ ''' Parsing , gets current stack trace information.
'''
'''
- Public Property Method As Method
- '''
- ''' The file path of the source file
- '''
- '''
- Public Property File As String
- '''
- ''' The line number in current source .
- '''
- '''
- Public Property Line As String
-
- Public Overrides Function ToString() As String
- Return $"{Method} at {File}:line {Line}"
- End Function
-
- Public Shared Function Parser(line As String) As StackFrame
- With line.Replace("位置", "at").Replace("行号", "line")
- Dim t = .StringSplit(" at ")
- Dim method = t(0)
- Dim location = t.ElementAtOrDefault(1)
- Dim file$, lineNumber$
-
- If Not location.StringEmpty Then
- t = location.StringSplit("[:]line ")
- file = t(0)
- lineNumber = t(1)
- Else
- file = "Unknown"
- lineNumber = 0
- End If
-
- Return New StackFrame With {
- .Method = New Method(method),
- .File = file,
- .Line = lineNumber
- }
- End With
- End Function
- End Class
-
- Public Class Method
-
- Public Property [Namespace] As String
- Public Property [Module] As String
- Public Property Method As String
-
- Sub New(s As String)
- Dim t = s.Split("."c).AsList
-
- Method = t(-1)
- [Module] = t(-2)
- [Namespace] = t.Take(t.Count - 2).JoinBy(".")
- End Sub
-
- Public Overrides Function ToString() As String
- Return $"{[Namespace]}.{[Module]}.{Method}"
+ Public Shared Function GetCurrentStackTrace() As StackFrame()
+ Return ParseStackTrace(Environment.StackTrace)
End Function
End Class
End Namespace
diff --git a/ApplicationServices/Debugger/Exception/StackFrame.vb b/ApplicationServices/Debugger/Exception/StackFrame.vb
new file mode 100644
index 00000000..cef8552e
--- /dev/null
+++ b/ApplicationServices/Debugger/Exception/StackFrame.vb
@@ -0,0 +1,122 @@
+#Region "Microsoft.VisualBasic::3c448b90b2b792689b5be21774ae4637, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Exception\StackFrame.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class StackFrame
+ '
+ ' Properties: File, Line, Method
+ '
+ ' Function: Parser, ToString
+ '
+ ' Class Method
+ '
+ ' Properties: [Module], [Namespace], Method
+ '
+ ' Constructor: (+2 Overloads) Sub New
+ ' Function: ToString
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Namespace ApplicationServices.Debugging.Diagnostics
+
+ Public Class StackFrame
+
+ '''
+ ''' Method call
+ '''
+ '''
+ Public Property Method As Method
+ '''
+ ''' The file path of the source file
+ '''
+ '''
+ Public Property File As String
+ '''
+ ''' The line number in current source .
+ '''
+ '''
+ Public Property Line As String
+
+ Public Overrides Function ToString() As String
+ Return $"{Method} at {File}:line {Line}"
+ End Function
+
+ Public Shared Function Parser(line As String) As StackFrame
+ With line.Replace("位置", "in").Replace("行号", "line")
+ Dim t = .StringSplit(" in ")
+ Dim method = t(0)
+ Dim location = t.ElementAtOrDefault(1)
+ Dim file$, lineNumber$
+
+ If Not location.StringEmpty Then
+ t = location.StringSplit("[:]line ")
+ file = t(0)
+ lineNumber = t(1)
+ Else
+ file = "Unknown"
+ lineNumber = 0
+ End If
+
+ Return New StackFrame With {
+ .Method = New Method(method),
+ .File = file,
+ .Line = lineNumber
+ }
+ End With
+ End Function
+ End Class
+
+ Public Class Method
+
+ Public Property [Namespace] As String
+ Public Property [Module] As String
+ Public Property Method As String
+
+ Sub New()
+ End Sub
+
+ Sub New(s As String)
+ Dim t = s.Split("."c).AsList
+
+ Method = t(-1)
+ [Module] = t(-2)
+ [Namespace] = t.Take(t.Count - 2).JoinBy(".")
+ End Sub
+
+ Public Overrides Function ToString() As String
+ Return $"{[Namespace]}.{[Module]}.{Method}"
+ End Function
+ End Class
+End Namespace
diff --git a/ApplicationServices/Debugger/VisualBasicAppException.vb b/ApplicationServices/Debugger/Exception/VisualBasicAppException.vb
similarity index 97%
rename from ApplicationServices/Debugger/VisualBasicAppException.vb
rename to ApplicationServices/Debugger/Exception/VisualBasicAppException.vb
index 1c5a8e6c..1abebb09 100644
--- a/ApplicationServices/Debugger/VisualBasicAppException.vb
+++ b/ApplicationServices/Debugger/Exception/VisualBasicAppException.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::94ae4e0b491c5d095a6e2a53002a395b, ApplicationServices\Debugger\VisualBasicAppException.vb"
+#Region "Microsoft.VisualBasic::94ae4e0b491c5d095a6e2a53002a395b, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Exception\VisualBasicAppException.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/HeapSizeOf.vb b/ApplicationServices/Debugger/HeapSizeOf.vb
new file mode 100644
index 00000000..d4828504
--- /dev/null
+++ b/ApplicationServices/Debugger/HeapSizeOf.vb
@@ -0,0 +1,182 @@
+#Region "Microsoft.VisualBasic::7fc737e272e77ae07237e66f8bf98aab, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\HeapSizeOf.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class HeapSizeOf
+ '
+ ' Properties: sizeOf
+ '
+ ' Function: MeasureSize, SizeOfPrimitive, StringByteSize
+ '
+ ' Sub: VisitObject
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Reflection
+Imports System.Runtime.CompilerServices
+Imports System.Text
+Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
+Imports Microsoft.VisualBasic.Serialization.BinaryDumping
+
+Namespace ApplicationServices.Debugging
+
+ '''
+ ''' How to get object size in memory
+ '''
+ Public Class HeapSizeOf
+
+ Public ReadOnly Property sizeOf As Long
+ Get
+ Return byteSize
+ End Get
+ End Property
+
+ Dim byteSize& = 0
+ Dim visitor As New ObjectVisitor() With {.VisitOnlyFields = True}
+
+ Public Sub VisitObject(value As Object, type As Type, memberInfo As MemberInfo, isVisited As Boolean, isValueType As Boolean)
+ If value Is Nothing Then
+ ' sizeof + 0 bytes
+ ' exit recursive visit
+ Return
+ ElseIf isVisited Then
+ ' add sizeof current reference
+ ' 4 on 32-bit, 8 on 64-bit
+#If X86 Then
+ size += 4
+#Else
+ byteSize += 8
+#End If
+ ' exit recursive visit
+ ElseIf type Is GetType(String) Then
+ byteSize += StringByteSize(value)
+ ' exit recursive visit
+ ElseIf DataFramework.IsPrimitive(type) Then
+ ' add byte size and then exit recursive visit
+ byteSize += SizeOfPrimitive(type)
+ ElseIf isValueType Then
+ ' is structure
+ ' do recursive visit of this object
+ Call visitor.DoVisitObjectFields(value, type, AddressOf VisitObject)
+ Else
+ ' add current reference
+#If X86 Then
+ size += 4
+#Else
+ byteSize += 8
+#End If
+ ' is class
+ ' do recursive visit of this object
+ ' required additional process on array
+ If type.IsArray Then
+ Call visitor.DoVisitArray(value, AddressOf VisitObject)
+ Else
+ Call visitor.DoVisitObjectFields(
+ obj:=value,
+ type:=type,
+ visit:=AddressOf VisitObject
+ )
+ End If
+ End If
+ End Sub
+
+ '''
+ ''' Find out the size of a .net object
+ '''
+ '''
+ '''
+ Public Shared Function MeasureSize(obj As Object) As Long
+ If obj Is Nothing Then
+ Return 0
+ Else
+ Dim type As Type = obj.GetType
+
+ If (Not type Is GetType(String)) AndAlso DataFramework.IsPrimitive(type) Then
+ Return SizeOfPrimitive(type)
+ ElseIf type Is GetType(String) Then
+ ' returns the actual byte size of current string
+ ' string in VisualBasic.NET is in unicode encoding
+ Return StringByteSize(obj)
+ ElseIf type.IsArray Then
+ With New HeapSizeOf
+ Call .visitor.DoVisitArray(
+ array:=obj,
+ visit:=AddressOf .VisitObject
+ )
+
+ Return .sizeOf
+ End With
+ Else
+ With New HeapSizeOf
+ Call .visitor.DoVisitObjectFields(
+ obj:=obj,
+ type:=obj.GetType,
+ visit:=AddressOf .VisitObject
+ )
+
+ Return .sizeOf
+ End With
+ End If
+ End If
+ End Function
+
+ '''
+ ''' Returns the actual byte size of current string
+ ''' string in VisualBasic.NET is in unicode encoding
+ '''
+ '''
+ '''
+ '''
+
+ Public Shared Function StringByteSize(str As String) As Integer
+ Return Encoding.Unicode.GetByteCount(str)
+ End Function
+
+ Public Shared Function SizeOfPrimitive(type As Type) As Integer
+ Select Case type
+ Case GetType(Single), GetType(Integer), GetType(UInt32)
+ Return 4
+ Case GetType(Double), GetType(Long), GetType(UInt64)
+ Return 8
+ Case GetType(Char), GetType(Short), GetType(UInt16)
+ Return 2
+ Case GetType(Byte), GetType(SByte), GetType(Boolean)
+ Return 1
+ Case Else
+ Throw New NotImplementedException(type.FullName)
+ End Select
+ End Function
+ End Class
+End Namespace
diff --git a/ApplicationServices/Debugger/Logging/EventLog.vb b/ApplicationServices/Debugger/Logging/EventLog.vb
index de396141..b9a9694f 100644
--- a/ApplicationServices/Debugger/Logging/EventLog.vb
+++ b/ApplicationServices/Debugger/Logging/EventLog.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b0e392b76c5a7ef2f7c5dd8334eb5080, ApplicationServices\Debugger\Logging\EventLog.vb"
+#Region "Microsoft.VisualBasic::b0e392b76c5a7ef2f7c5dd8334eb5080, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Logging\EventLog.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/Logging/LogFile/LogEntry.vb b/ApplicationServices/Debugger/Logging/LogFile/LogEntry.vb
index ab926665..c165fb2d 100644
--- a/ApplicationServices/Debugger/Logging/LogFile/LogEntry.vb
+++ b/ApplicationServices/Debugger/Logging/LogFile/LogEntry.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b140e1247998449c2e44aee59c798206, ApplicationServices\Debugger\Logging\LogFile\LogEntry.vb"
+#Region "Microsoft.VisualBasic::b140e1247998449c2e44aee59c798206, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Logging\LogFile\LogEntry.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/Logging/LogFile/LogFile.vb b/ApplicationServices/Debugger/Logging/LogFile/LogFile.vb
index 60658157..89814125 100644
--- a/ApplicationServices/Debugger/Logging/LogFile/LogFile.vb
+++ b/ApplicationServices/Debugger/Logging/LogFile/LogFile.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::99634e02bd3bb723482cefb5aa8536d9, ApplicationServices\Debugger\Logging\LogFile\LogFile.vb"
+#Region "Microsoft.VisualBasic::99634e02bd3bb723482cefb5aa8536d9, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Logging\LogFile\LogFile.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/Logging/LogFile/LogReader.vb b/ApplicationServices/Debugger/Logging/LogFile/LogReader.vb
index 2749dc97..cf75aa40 100644
--- a/ApplicationServices/Debugger/Logging/LogFile/LogReader.vb
+++ b/ApplicationServices/Debugger/Logging/LogFile/LogReader.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::aeac6967faadad97a2c9eea28aa83cc1, ApplicationServices\Debugger\Logging\LogFile\LogReader.vb"
+#Region "Microsoft.VisualBasic::aeac6967faadad97a2c9eea28aa83cc1, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Logging\LogFile\LogReader.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/Logging/LogFile/MSG_TYPES.vb b/ApplicationServices/Debugger/Logging/LogFile/MSG_TYPES.vb
index 342edcc2..55ff8c4e 100644
--- a/ApplicationServices/Debugger/Logging/LogFile/MSG_TYPES.vb
+++ b/ApplicationServices/Debugger/Logging/LogFile/MSG_TYPES.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a5a87ff1247563c2eb0d404bbf3c6774, ApplicationServices\Debugger\Logging\LogFile\MSG_TYPES.vb"
+#Region "Microsoft.VisualBasic::a5a87ff1247563c2eb0d404bbf3c6774, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\Logging\LogFile\MSG_TYPES.vb"
' Author:
'
diff --git a/ApplicationServices/Debugger/NETDebugger.vb b/ApplicationServices/Debugger/NETDebugger.vb
deleted file mode 100644
index a3cee13b..00000000
--- a/ApplicationServices/Debugger/NETDebugger.vb
+++ /dev/null
@@ -1,151 +0,0 @@
-#Region "Microsoft.VisualBasic::2973138edf1beb9688e7277ff9156880, ApplicationServices\Debugger\NETDebugger.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 .
-
-
-
- ' /********************************************************************************/
-
- ' Summaries:
-
- '
- ' /********************************************************************************/
-
-#End Region
-
-'Imports System.Reflection
-
-Namespace ApplicationServices.Debugging
-
- ' '''
- ' ''' .NET程序调试器
- ' '''
- ' '''
- 'Public Class NETDebugger
-
- ' '''
- ' '''
- ' '''
- ' ''' .NET应用程序可执行文件或者包含有Main定义的dll文件
- ' ''' 调试所使用的命令行参数
- ' '''
- ' '''
- ' Public Function Start(AssemblyPath As String, argvs As String()) As Integer
-
- ' AssemblyPath = FileIO.FileSystem.GetFileInfo(AssemblyPath).FullName
-
- ' Dim Assembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile(AssemblyPath)
- ' Dim GetMainEntryLQuery = (From TypeEntry As System.Reflection.TypeInfo
- ' In Assembly.DefinedTypes
- ' Let EntryMain As MethodInfo = GetMainEntry(TypeEntry)
- ' Where EntryMain IsNot Nothing
- ' Select EntryMain).ToArray
-
- ' If GetMainEntryLQuery.IsNullOrEmpty Then
- ' Return -100
- ' End If
-
- ' Dim Main = GetMainEntryLQuery.First
- ' Return RunMain(Main, argvs)
- ' End Function
-
- ' '''
- ' ''' 函数会递归查询
- ' '''
- ' '''
- ' '''
- ' '''
- ' Public Shared Function GetMainEntry(TypeInfo As Type) As MethodInfo
- ' Dim LQuery = (From Method As System.Reflection.MethodInfo
- ' In TypeInfo.GetMethods(BindingFlags.Public Or BindingFlags.Static)
- ' Where String.Equals(Method.Name, "Main", StringComparison.OrdinalIgnoreCase) AndAlso IsStandardMainReturnType(Method.ReturnType) AndAlso IsStandardMainParameterType(Method)
- ' Select Method).ToArray
- ' Return LQuery.FirstOrDefault
- ' End Function
-
- ' Private Shared Function IsStandardMainReturnType(Type As Type) As Boolean
- ' Return System.Type.Equals(Type, GetType(Void)) OrElse System.Type.Equals(Type, GetType(Integer))
- ' End Function
-
- ' Private Shared Function IsStandardMainParameterType(MethodInfo As MethodInfo) As Boolean
- ' Dim pList = MethodInfo.GetParameters
-
- ' If pList.Count > 1 Then
- ' Return False
- ' ElseIf pList.IsNullOrEmpty Then
- ' Return True
- ' End If
-
- ' Dim pTypeInfo As System.Type = pList(0).ParameterType
- ' Return pTypeInfo.Equals(GetType(String)) OrElse pTypeInfo.Equals(GetType(String()))
- ' End Function
-
- ' '''
- ' ''' 启动Main函数
- ' '''
- ' '''
- ' '''
- ' '''
- ' '''
- ' Private Function RunMain(Main As MethodInfo, argvs As String()) As Integer
-
- ' Dim pValue As Object()
- ' Dim pInfo = Main.GetParameters
-
- ' If pInfo.IsNullOrEmpty Then
- ' pValue = New Object() {} '函数没有参数
- ' Else
- ' If pInfo(0).Equals(GetType(String)) Then
- ' pValue = {argvs(0)} '字符串
- ' Else
- ' pValue = {argvs} '字符串数组
- ' End If
- ' End If
-
- ' Dim result = InternalRunFunction(Main, pValue)
-
- ' If Main.ReturnType.Equals(GetType(Integer)) Then
- ' Return DirectCast(result, Integer)
- ' Else
- ' Return 0
- ' End If
- ' End Function
-
- ' '''
- ' ''' 在终端之上打印出每一行代码
- ' '''
- ' '''
- ' '''
- ' '''
- ' '''
- ' Private Function InternalRunFunction(EntryPoint As MethodInfo, argvs As Object()) As Object
-
-
-
- ' End Function
-
- 'End Class
-End Namespace
diff --git a/ApplicationServices/Debugger/VisualStudioPreviews.vb b/ApplicationServices/Debugger/VisualStudioPreviews.vb
index 1de44f37..17f4c0f0 100644
--- a/ApplicationServices/Debugger/VisualStudioPreviews.vb
+++ b/ApplicationServices/Debugger/VisualStudioPreviews.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::31fa0cd6ac08db181a93bd8a2614d2c9, ApplicationServices\Debugger\VisualStudioPreviews.vb"
+#Region "Microsoft.VisualBasic::31fa0cd6ac08db181a93bd8a2614d2c9, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\VisualStudioPreviews.vb"
' Author:
'
diff --git a/ApplicationServices/LanguageHelper/LanguageAttribute.vb b/ApplicationServices/LanguageHelper/LanguageAttribute.vb
index 1b299ae7..5dab032b 100644
--- a/ApplicationServices/LanguageHelper/LanguageAttribute.vb
+++ b/ApplicationServices/LanguageHelper/LanguageAttribute.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b25e743ee7591c1e71fdaa2fd2db4d63, ApplicationServices\LanguageHelper\LanguageAttribute.vb"
+#Region "Microsoft.VisualBasic::b25e743ee7591c1e71fdaa2fd2db4d63, Microsoft.VisualBasic.Core\ApplicationServices\LanguageHelper\LanguageAttribute.vb"
' Author:
'
diff --git a/ApplicationServices/LanguageHelper/LanguageHelper.vb b/ApplicationServices/LanguageHelper/LanguageHelper.vb
index 1a481452..ca1e7db8 100644
--- a/ApplicationServices/LanguageHelper/LanguageHelper.vb
+++ b/ApplicationServices/LanguageHelper/LanguageHelper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::aa2ce89be28d9bbb102c6c1ba1c87a7a, ApplicationServices\LanguageHelper\LanguageHelper.vb"
+#Region "Microsoft.VisualBasic::aa2ce89be28d9bbb102c6c1ba1c87a7a, Microsoft.VisualBasic.Core\ApplicationServices\LanguageHelper\LanguageHelper.vb"
' Author:
'
diff --git a/ApplicationServices/LanguageHelper/StringResources.vb b/ApplicationServices/LanguageHelper/StringResources.vb
index ade386d4..a67ea908 100644
--- a/ApplicationServices/LanguageHelper/StringResources.vb
+++ b/ApplicationServices/LanguageHelper/StringResources.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ba85f5e7914cccfad1a4a2adcb3d9fac, ApplicationServices\LanguageHelper\StringResources.vb"
+#Region "Microsoft.VisualBasic::ba85f5e7914cccfad1a4a2adcb3d9fac, Microsoft.VisualBasic.Core\ApplicationServices\LanguageHelper\StringResources.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/MMFChannel.vb b/ApplicationServices/Parallel/MMFProtocol/MMFChannel.vb
index 5eddfe6c..c125452c 100644
--- a/ApplicationServices/Parallel/MMFProtocol/MMFChannel.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/MMFChannel.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ab3c4c8a2c451e14dce950d548490d07, ApplicationServices\Parallel\MMFProtocol\MMFChannel.vb"
+#Region "Microsoft.VisualBasic::ab3c4c8a2c451e14dce950d548490d07, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\MMFChannel.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/MapStream/MSReader.vb b/ApplicationServices/Parallel/MMFProtocol/MapStream/MSReader.vb
index 595590bb..68ca2447 100644
--- a/ApplicationServices/Parallel/MMFProtocol/MapStream/MSReader.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/MapStream/MSReader.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2393125faf83bc9ae53a165797bdd6f1, ApplicationServices\Parallel\MMFProtocol\MapStream\MSReader.vb"
+#Region "Microsoft.VisualBasic::2393125faf83bc9ae53a165797bdd6f1, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\MapStream\MSReader.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/MapStream/MSWriter.vb b/ApplicationServices/Parallel/MMFProtocol/MapStream/MSWriter.vb
index 1aa99670..91599781 100644
--- a/ApplicationServices/Parallel/MMFProtocol/MapStream/MSWriter.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/MapStream/MSWriter.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::677cab0ad3137bc4e63a8cf7939e93ae, ApplicationServices\Parallel\MMFProtocol\MapStream\MSWriter.vb"
+#Region "Microsoft.VisualBasic::677cab0ad3137bc4e63a8cf7939e93ae, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\MapStream\MSWriter.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/Pipeline/API.vb b/ApplicationServices/Parallel/MMFProtocol/Pipeline/API.vb
index 47aedce5..ca75c7b1 100644
--- a/ApplicationServices/Parallel/MMFProtocol/Pipeline/API.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/Pipeline/API.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3cb2b985d6842151b781445429322b32, ApplicationServices\Parallel\MMFProtocol\Pipeline\API.vb"
+#Region "Microsoft.VisualBasic::3cb2b985d6842151b781445429322b32, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\Pipeline\API.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeBuffer.vb b/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeBuffer.vb
index 2cd33368..6e861e9f 100644
--- a/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeBuffer.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeBuffer.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b6eb1b86ae83ffd1e0ceab81f5ca2159, ApplicationServices\Parallel\MMFProtocol\Pipeline\PipeBuffer.vb"
+#Region "Microsoft.VisualBasic::cd750bc3d0d872fe58c7bbd4cc5ad6b9, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\Pipeline\PipeBuffer.vb"
' Author:
'
@@ -56,7 +56,7 @@ Namespace Parallel.MMFProtocol.Pipeline
Sub New(raw As Byte())
Dim nameLen As Byte() = New Byte(INT32 - 1) {}
- Dim p As VBInteger = Scan0
+ Dim p As i32 = Scan0
Call Array.ConstrainedCopy(raw, p + INT32, nameLen, Scan0, INT32)
Dim len As Integer = BitConverter.ToInt32(nameLen, Scan0)
@@ -72,7 +72,7 @@ Namespace Parallel.MMFProtocol.Pipeline
Dim nameBuf As Byte() = UTF8WithoutBOM.GetBytes(Name)
Dim buffer As Byte() = New Byte(INT32 + nameBuf.Length + byteData.Length - 1) {}
Dim nameLen As Byte() = BitConverter.GetBytes(nameBuf.Length)
- Dim p As VBInteger = Scan0
+ Dim p As i32 = Scan0
Call Array.ConstrainedCopy(nameLen, Scan0, buffer, p + nameLen.Length, nameLen.Length)
Call Array.ConstrainedCopy(nameBuf, Scan0, buffer, p + nameBuf.Length, nameBuf.Length)
diff --git a/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeStream.vb b/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeStream.vb
index 35832f9d..6bf90675 100644
--- a/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeStream.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/Pipeline/PipeStream.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9096a916051799d9c0ff6c7e69c083a9, ApplicationServices\Parallel\MMFProtocol\Pipeline\PipeStream.vb"
+#Region "Microsoft.VisualBasic::9096a916051799d9c0ff6c7e69c083a9, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\Pipeline\PipeStream.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/Pipeline/Pipeline.vb b/ApplicationServices/Parallel/MMFProtocol/Pipeline/Pipeline.vb
index e36582d3..ebacc6ad 100644
--- a/ApplicationServices/Parallel/MMFProtocol/Pipeline/Pipeline.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/Pipeline/Pipeline.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b0f12490536f283a929877085408362f, ApplicationServices\Parallel\MMFProtocol\Pipeline\Pipeline.vb"
+#Region "Microsoft.VisualBasic::d0d32908bf3f727a46036d0f6bfe8033, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\Pipeline\Pipeline.vb"
' Author:
'
@@ -63,7 +63,7 @@ Namespace Parallel.MMFProtocol.Pipeline
Sub New(Optional port As Integer = API.PeplinePort)
_protocols = New ProtocolHandler(Me)
_netSocket = New TcpServicesSocket(port)
- _netSocket.Responsehandler = AddressOf _protocols.HandleRequest
+ _netSocket.ResponseHandler = AddressOf _protocols.HandleRequest
Call Parallel.RunTask(AddressOf _netSocket.Run)
End Sub
diff --git a/ApplicationServices/Parallel/MMFProtocol/ProcessLock.vb b/ApplicationServices/Parallel/MMFProtocol/ProcessLock.vb
index d3c8c072..eaef950f 100644
--- a/ApplicationServices/Parallel/MMFProtocol/ProcessLock.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/ProcessLock.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::97968f150921e7fd613c9978de939575, ApplicationServices\Parallel\MMFProtocol\ProcessLock.vb"
+#Region "Microsoft.VisualBasic::97968f150921e7fd613c9978de939575, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\ProcessLock.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/MMFProtocol/WorkFlow.vb b/ApplicationServices/Parallel/MMFProtocol/WorkFlow.vb
index af1e0928..305598be 100644
--- a/ApplicationServices/Parallel/MMFProtocol/WorkFlow.vb
+++ b/ApplicationServices/Parallel/MMFProtocol/WorkFlow.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::aa9a6c158df2b0f6ff46e52ef7b79e28, ApplicationServices\Parallel\MMFProtocol\WorkFlow.vb"
+#Region "Microsoft.VisualBasic::aa9a6c158df2b0f6ff46e52ef7b79e28, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\MMFProtocol\WorkFlow.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/OperationTimeOut.vb b/ApplicationServices/Parallel/OperationTimeOut.vb
index 4c73e1fb..5736ce47 100644
--- a/ApplicationServices/Parallel/OperationTimeOut.vb
+++ b/ApplicationServices/Parallel/OperationTimeOut.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8692c0dfaacf8f0e842aa47da86c0416, ApplicationServices\Parallel\OperationTimeOut.vb"
+#Region "Microsoft.VisualBasic::0207a3cffa83d75a0e5040b759daa6c3, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\OperationTimeOut.vb"
' Author:
'
@@ -60,7 +60,7 @@ Namespace Parallel
'''
Public Function OperationTimeOut(Of T, TOut)(handle As Func(Of T, TOut), [In] As T, ByRef Out As TOut, TimeOut As Double) As Boolean
- Dim invoke As New __backgroundTask(Of TOut)(Function() handle([In]))
+ Dim invoke As New backgroundTask(Of TOut)(Function() handle([In]))
Dim i As Integer
TimeOut = TimeOut * 1000
diff --git a/ApplicationServices/Parallel/Tasks/Actor(Of T, V).vb b/ApplicationServices/Parallel/Tasks/Actor(Of T, V).vb
index 9730a96f..95f83e1f 100644
--- a/ApplicationServices/Parallel/Tasks/Actor(Of T, V).vb
+++ b/ApplicationServices/Parallel/Tasks/Actor(Of T, V).vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::afb02982ac0178b827bb2e0d041591f0, ApplicationServices\Parallel\Tasks\Actor(Of T, V).vb"
+#Region "Microsoft.VisualBasic::afb02982ac0178b827bb2e0d041591f0, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\Actor(Of T, V).vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/AsyncHandle.vb b/ApplicationServices/Parallel/Tasks/AsyncHandle.vb
index 55aa4aab..86410256 100644
--- a/ApplicationServices/Parallel/Tasks/AsyncHandle.vb
+++ b/ApplicationServices/Parallel/Tasks/AsyncHandle.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0ad42454b00ba27b8315decee04bc742, ApplicationServices\Parallel\Tasks\AsyncHandle.vb"
+#Region "Microsoft.VisualBasic::abe0e686dd1e1517f830f2fdbc7dd72f, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\AsyncHandle.vb"
' Author:
'
@@ -95,7 +95,8 @@ Namespace Parallel.Tasks
'''
Public Function Run() As AsyncHandle(Of TOut)
If IsCompleted Then
- _Handle = Task.BeginInvoke(Nothing, Nothing) ' 假若没有执行完毕也调用的话,会改变handle
+ ' 假若没有执行完毕也调用的话,会改变handle
+ _Handle = Task.BeginInvoke(Nothing, Nothing)
End If
Return Me
diff --git a/ApplicationServices/Parallel/Tasks/CallbackTask.vb b/ApplicationServices/Parallel/Tasks/CallbackTask.vb
index abf6f25e..3d34147b 100644
--- a/ApplicationServices/Parallel/Tasks/CallbackTask.vb
+++ b/ApplicationServices/Parallel/Tasks/CallbackTask.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0cb14b35413196d04634cbeb887b9907, ApplicationServices\Parallel\Tasks\CallbackTask.vb"
+#Region "Microsoft.VisualBasic::0cb14b35413196d04634cbeb887b9907, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\CallbackTask.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/IParallelTask.vb b/ApplicationServices/Parallel/Tasks/IParallelTask.vb
index 323dd345..68978ab6 100644
--- a/ApplicationServices/Parallel/Tasks/IParallelTask.vb
+++ b/ApplicationServices/Parallel/Tasks/IParallelTask.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f1949dc0dd55a5a4f0a9cc72039bcdbc, ApplicationServices\Parallel\Tasks\IParallelTask.vb"
+#Region "Microsoft.VisualBasic::f1949dc0dd55a5a4f0a9cc72039bcdbc, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\IParallelTask.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/Task.vb b/ApplicationServices/Parallel/Tasks/Task.vb
index 0b2eb4e3..27a56dc4 100644
--- a/ApplicationServices/Parallel/Tasks/Task.vb
+++ b/ApplicationServices/Parallel/Tasks/Task.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ace065b1c8fa32d27a4802a089772660, ApplicationServices\Parallel\Tasks\Task.vb"
+#Region "Microsoft.VisualBasic::ace065b1c8fa32d27a4802a089772660, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\Task.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/TaskQueue.vb b/ApplicationServices/Parallel/Tasks/TaskQueue.vb
index e790b762..9e37cf49 100644
--- a/ApplicationServices/Parallel/Tasks/TaskQueue.vb
+++ b/ApplicationServices/Parallel/Tasks/TaskQueue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::956ebcd8a97a2cc25b960fde016dcc9d, ApplicationServices\Parallel\Tasks\TaskQueue.vb"
+#Region "Microsoft.VisualBasic::956ebcd8a97a2cc25b960fde016dcc9d, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\TaskQueue.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/UpdateThread.vb b/ApplicationServices/Parallel/Tasks/UpdateThread.vb
index 011d761f..1263811f 100644
--- a/ApplicationServices/Parallel/Tasks/UpdateThread.vb
+++ b/ApplicationServices/Parallel/Tasks/UpdateThread.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d600fc3bc5d544d05801c901e154e033, ApplicationServices\Parallel\Tasks\UpdateThread.vb"
+#Region "Microsoft.VisualBasic::d600fc3bc5d544d05801c901e154e033, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\UpdateThread.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Tasks/__backgroundTask(Of T).vb b/ApplicationServices/Parallel/Tasks/__backgroundTask(Of T).vb
index 216263e3..dc61b797 100644
--- a/ApplicationServices/Parallel/Tasks/__backgroundTask(Of T).vb
+++ b/ApplicationServices/Parallel/Tasks/__backgroundTask(Of T).vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::869b09ad14c8f2c6c6f514616cbc3e82, ApplicationServices\Parallel\Tasks\__backgroundTask(Of T).vb"
+#Region "Microsoft.VisualBasic::c60deb7b2b37593b3ba785850c01201e, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Tasks\__backgroundTask(Of T).vb"
' Author:
'
@@ -34,7 +34,7 @@
' Delegate Function
'
'
- ' Class __backgroundTask
+ ' Class backgroundTask
'
' Properties: ExecuteException, TaskHandle, Value
'
@@ -61,7 +61,7 @@ Namespace Parallel.Tasks
'''
Public Delegate Function IBackgroundTask(Of T)() As T
- Friend Class __backgroundTask(Of T) : Inherits IParallelTask
+ Friend Class backgroundTask(Of T) : Inherits IParallelTask
'''
''' 获取得到任务线程执行的输出结果
@@ -103,7 +103,7 @@ Namespace Parallel.Tasks
_RunningTask = False
End Sub
- Public Function Start() As __backgroundTask(Of T)
+ Public Function Start() As backgroundTask(Of T)
If Not TaskRunning Then
_taskThread.Start()
_TaskComplete = False
diff --git a/ApplicationServices/Parallel/Threading.vb b/ApplicationServices/Parallel/Threading.vb
index de0642ca..5abb2c9e 100644
--- a/ApplicationServices/Parallel/Threading.vb
+++ b/ApplicationServices/Parallel/Threading.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4aab5d65673186dcf22de324c7b683d1, ApplicationServices\Parallel\Threading.vb"
+#Region "Microsoft.VisualBasic::f9683810290dc0fe5b22bfab369b6ce2, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threading.vb"
' Author:
'
@@ -34,9 +34,9 @@
' Module InvokesHelper
'
' Function: Invoke
- ' Structure __invokeHelper
+ ' Structure invokeHelper
'
- ' Function: Task
+ ' Function: RunTask
'
'
'
@@ -62,9 +62,9 @@ Namespace Parallel
'''
Public Function Invoke(tasks As Action(), numOfThreads As Integer) As Integer
Dim getTask As Func(Of Action, Func(Of Integer)) =
- Function(task) AddressOf New __invokeHelper With {
- .__task = task
- }.Task
+ Function(task) AddressOf New invokeHelper With {
+ .task = task
+ }.RunTask
Dim invokes As Func(Of Integer)() =
LinqAPI.Exec(Of Func(Of Integer)) <= From action As Action
In tasks
@@ -72,12 +72,12 @@ Namespace Parallel
Return BatchTasks.BatchTask(invokes, numOfThreads).Length
End Function
- Private Structure __invokeHelper
+ Private Structure invokeHelper
- Dim __task As Action
+ Dim task As Action
- Public Function Task() As Integer
- Call __task()
+ Public Function RunTask() As Integer
+ Call task()
Return 0
End Function
End Structure
diff --git a/ApplicationServices/Parallel/Threads/BatchTasks.vb b/ApplicationServices/Parallel/Threads/BatchTasks.vb
index 127cb7b8..eee8b8d2 100644
--- a/ApplicationServices/Parallel/Threads/BatchTasks.vb
+++ b/ApplicationServices/Parallel/Threads/BatchTasks.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d0ce60baace81f393dc0f3e4bc8ddd61, ApplicationServices\Parallel\Threads\BatchTasks.vb"
+#Region "Microsoft.VisualBasic::d0ce60baace81f393dc0f3e4bc8ddd61, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\BatchTasks.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/CodeThread.vb b/ApplicationServices/Parallel/Threads/CodeThread.vb
index eb45886c..0d65e067 100644
--- a/ApplicationServices/Parallel/Threads/CodeThread.vb
+++ b/ApplicationServices/Parallel/Threads/CodeThread.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8e100823622f774acbd1bd5233f9a410, ApplicationServices\Parallel\Threads\CodeThread.vb"
+#Region "Microsoft.VisualBasic::925f82e3918fced638676dee182b7a78, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\CodeThread.vb"
' Author:
'
@@ -53,10 +53,10 @@ Namespace Parallel.Threads
Protected ReadOnly thread As Thread
Sub New()
- thread = New Thread(AddressOf __run)
+ thread = New Thread(AddressOf run)
End Sub
- Protected MustOverride Sub __run()
+ Protected MustOverride Sub run()
Public Shared Function GetThread(x As CodeThread) As Thread
Return x.thread
diff --git a/ApplicationServices/Parallel/Threads/Groups/DataGroup.vb b/ApplicationServices/Parallel/Threads/Groups/DataGroup.vb
index aabda533..2e864243 100644
--- a/ApplicationServices/Parallel/Threads/Groups/DataGroup.vb
+++ b/ApplicationServices/Parallel/Threads/Groups/DataGroup.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::19568ecf19640f9af2343dfceba0d3f4, ApplicationServices\Parallel\Threads\Groups\DataGroup.vb"
+#Region "Microsoft.VisualBasic::19568ecf19640f9af2343dfceba0d3f4, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\Groups\DataGroup.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/Groups/GroupAPI.vb b/ApplicationServices/Parallel/Threads/Groups/GroupAPI.vb
index 77601ed9..445e76c2 100644
--- a/ApplicationServices/Parallel/Threads/Groups/GroupAPI.vb
+++ b/ApplicationServices/Parallel/Threads/Groups/GroupAPI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::91c0c7bf05f5cc78570c51304351cd2d, ApplicationServices\Parallel\Threads\Groups\GroupAPI.vb"
+#Region "Microsoft.VisualBasic::91c0c7bf05f5cc78570c51304351cd2d, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\Groups\GroupAPI.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/LQuerySchedule/LQuerySchedule.vb b/ApplicationServices/Parallel/Threads/LQuerySchedule/LQuerySchedule.vb
index 44fa8c9d..6eb28ba5 100644
--- a/ApplicationServices/Parallel/Threads/LQuerySchedule/LQuerySchedule.vb
+++ b/ApplicationServices/Parallel/Threads/LQuerySchedule/LQuerySchedule.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2d841996800b3a70e80c0d50dc98e787, ApplicationServices\Parallel\Threads\LQuerySchedule\LQuerySchedule.vb"
+#Region "Microsoft.VisualBasic::708662ae342ebb27208a8e66aa4233f7, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\LQuerySchedule\LQuerySchedule.vb"
' Author:
'
@@ -157,14 +157,14 @@ Namespace Parallel.Linq
Public Iterator Function LQuery(Of T, TOut)(inputs As IEnumerable(Of T),
task As Func(Of T, TOut),
Optional where As Func(Of T, Boolean) = Nothing,
- Optional parTokens As Integer = 20000) As IEnumerable(Of TOut)
+ Optional partitionSize As Integer = 20000) As IEnumerable(Of TOut)
Call $"Start schedule task pool for {GetType(T).FullName} --> {GetType(TOut).FullName}".__DEBUG_ECHO
Dim buf As IEnumerable(Of Func(Of TOut())) =
If(where Is Nothing,
- TaskPartitions.Partitioning(inputs, parTokens, task),
- TaskPartitions.Partitioning(inputs, parTokens, task, where))
+ TaskPartitions.Partitioning(inputs, partitionSize, task),
+ TaskPartitions.Partitioning(inputs, partitionSize, task, where))
Dim LQueryInvoke = From part As Func(Of TOut())
In buf.AsParallel
Select part()
@@ -190,11 +190,11 @@ Namespace Parallel.Linq
Public Iterator Function LQuery(Of T, TOut)(inputs As IEnumerable(Of T),
task As Func(Of T, TOut),
outWhere As Func(Of TOut, Boolean),
- Optional parTokens As Integer = 20000) As IEnumerable(Of TOut)
+ Optional partitionSize As Integer = 20000) As IEnumerable(Of TOut)
Call $"Start schedule task pool for {GetType(T).FullName} --> {GetType(TOut).FullName}".__DEBUG_ECHO
- Dim buf As IEnumerable(Of Func(Of TOut())) = TaskPartitions.Partitioning(inputs, parTokens, task)
+ Dim buf As IEnumerable(Of Func(Of TOut())) = TaskPartitions.Partitioning(inputs, partitionSize, task)
Dim LQueryInvoke = From part As Func(Of TOut())
In buf.AsParallel
Select part()
diff --git a/ApplicationServices/Parallel/Threads/LQuerySchedule/Models.vb b/ApplicationServices/Parallel/Threads/LQuerySchedule/Models.vb
index 2a9758a1..ad686236 100644
--- a/ApplicationServices/Parallel/Threads/LQuerySchedule/Models.vb
+++ b/ApplicationServices/Parallel/Threads/LQuerySchedule/Models.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3be5c17214536ce52cfb48a329ec834f, ApplicationServices\Parallel\Threads\LQuerySchedule\Models.vb"
+#Region "Microsoft.VisualBasic::3be5c17214536ce52cfb48a329ec834f, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\LQuerySchedule\Models.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/LQuerySchedule/TaskPartitions.vb b/ApplicationServices/Parallel/Threads/LQuerySchedule/TaskPartitions.vb
index 776e63f9..c0b0ea7a 100644
--- a/ApplicationServices/Parallel/Threads/LQuerySchedule/TaskPartitions.vb
+++ b/ApplicationServices/Parallel/Threads/LQuerySchedule/TaskPartitions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b2b58862d64fb542fc56e70f154d98a2, ApplicationServices\Parallel\Threads\LQuerySchedule\TaskPartitions.vb"
+#Region "Microsoft.VisualBasic::b2b58862d64fb542fc56e70f154d98a2, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\LQuerySchedule\TaskPartitions.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/ParallelExtension.vb b/ApplicationServices/Parallel/Threads/ParallelExtension.vb
index fa48121e..16ee5ded 100644
--- a/ApplicationServices/Parallel/Threads/ParallelExtension.vb
+++ b/ApplicationServices/Parallel/Threads/ParallelExtension.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::add210b8a4f87e7cf23051aaaa02d33d, ApplicationServices\Parallel\Threads\ParallelExtension.vb"
+#Region "Microsoft.VisualBasic::d644612bcbf5b4839c5ed206221a2c94, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\ParallelExtension.vb"
' Author:
'
@@ -42,7 +42,6 @@
Imports System.Runtime.CompilerServices
Imports System.Threading
-Imports Microsoft.VisualBasic.MethodsExtension
Namespace Parallel
diff --git a/ApplicationServices/Parallel/Threads/ThreadPool.vb b/ApplicationServices/Parallel/Threads/ThreadPool.vb
index 608b2700..daba924d 100644
--- a/ApplicationServices/Parallel/Threads/ThreadPool.vb
+++ b/ApplicationServices/Parallel/Threads/ThreadPool.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::428f68cffb11bf82c69327e04c881853, ApplicationServices\Parallel\Threads\ThreadPool.vb"
+#Region "Microsoft.VisualBasic::428f68cffb11bf82c69327e04c881853, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\ThreadPool.vb"
' Author:
'
diff --git a/ApplicationServices/Parallel/Threads/ThreadQueue.vb b/ApplicationServices/Parallel/Threads/ThreadQueue.vb
index 68e5ae2c..0234589e 100644
--- a/ApplicationServices/Parallel/Threads/ThreadQueue.vb
+++ b/ApplicationServices/Parallel/Threads/ThreadQueue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ee7085a89d6da3f3e69575abf655dfa5, ApplicationServices\Parallel\Threads\ThreadQueue.vb"
+#Region "Microsoft.VisualBasic::ee7085a89d6da3f3e69575abf655dfa5, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\ThreadQueue.vb"
' Author:
'
@@ -124,7 +124,7 @@ Namespace Parallel
'''
Public Sub WaitQueue()
While QSolverRunning = True
- Thread.Sleep(10)
+ Call Thread.Sleep(10)
End While
End Sub
diff --git a/ApplicationServices/ServerModule.vb b/ApplicationServices/ServerModule.vb
index b29a93fe..e08c2efa 100644
--- a/ApplicationServices/ServerModule.vb
+++ b/ApplicationServices/ServerModule.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2da983e326a439e3d78ee22104032cec, ApplicationServices\ServerModule.vb"
+#Region "Microsoft.VisualBasic::978e12e2ef6e9729f386445dd33bf5d8, Microsoft.VisualBasic.Core\ApplicationServices\ServerModule.vb"
' Author:
'
@@ -78,7 +78,7 @@ Namespace ApplicationServices
''' The listen port of the tcp socket.
Sub New(port As Integer)
socket = New TcpServicesSocket(port, AddressOf LogException) With {
- .Responsehandler = ProtocolHandler()
+ .ResponseHandler = ProtocolHandler()
}
End Sub
diff --git a/ApplicationServices/Terminal/InteractiveIODevice/HistoryStacks.vb b/ApplicationServices/Terminal/InteractiveIODevice/HistoryStacks.vb
index 00628d4a..0749b22f 100644
--- a/ApplicationServices/Terminal/InteractiveIODevice/HistoryStacks.vb
+++ b/ApplicationServices/Terminal/InteractiveIODevice/HistoryStacks.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c8f36b0edfb7202aadaeacfc27e2b874, ApplicationServices\Terminal\InteractiveIODevice\HistoryStacks.vb"
+#Region "Microsoft.VisualBasic::c8f36b0edfb7202aadaeacfc27e2b874, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\InteractiveIODevice\HistoryStacks.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/InteractiveIODevice/InteractiveDevice.vb b/ApplicationServices/Terminal/InteractiveIODevice/InteractiveDevice.vb
index 491ef448..7c3d2165 100644
--- a/ApplicationServices/Terminal/InteractiveIODevice/InteractiveDevice.vb
+++ b/ApplicationServices/Terminal/InteractiveIODevice/InteractiveDevice.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b622c2133a1e54beb409936d192a5a9c, ApplicationServices\Terminal\InteractiveIODevice\InteractiveDevice.vb"
+#Region "Microsoft.VisualBasic::b622c2133a1e54beb409936d192a5a9c, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\InteractiveIODevice\InteractiveDevice.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/InteractiveIODevice/Shell.vb b/ApplicationServices/Terminal/InteractiveIODevice/Shell.vb
index dc57e020..4553eb3c 100644
--- a/ApplicationServices/Terminal/InteractiveIODevice/Shell.vb
+++ b/ApplicationServices/Terminal/InteractiveIODevice/Shell.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a596d68f21ddfe88f4f2dacfb45376f7, ApplicationServices\Terminal\InteractiveIODevice\Shell.vb"
+#Region "Microsoft.VisualBasic::383b8feb02f6318617da073544d3b724, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\InteractiveIODevice\Shell.vb"
' Author:
'
@@ -33,7 +33,7 @@
' Class Shell
'
- ' Properties: History, Quite
+ ' Properties: dev, History, ps1, Quite, shell
'
' Constructor: (+1 Overloads) Sub New
' Sub: Run
@@ -43,36 +43,59 @@
#End Region
+Imports System.IO
+Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.UnixBash
Namespace Terminal
+ '''
+ ''' Shell model for console.
+ '''
Public Class Shell
- ReadOnly __ps1 As PS1
- ReadOnly __shell As Action(Of String)
+ Public ReadOnly Property ps1 As PS1
+ Public ReadOnly Property shell As Action(Of String)
+ Public ReadOnly Property dev As TextReader
+ '''
+ ''' Command text for exit the shell loop
+ '''
+ ''' (默认的退出文本为vim的 ``:q`` 命令)
+ '''
+ '''
Public Property Quite As String = ":q"
Public Property History As String = ":h"
- Sub New(ps1 As PS1, exec As Action(Of String))
- __ps1 = ps1
- __shell = exec
+ '''
+ '''
+ '''
+ ''' The commandline prompt prefix headers.
+ ''' How to execute the command line input.
+ Sub New(ps1 As PS1, exec As Action(Of String), Optional dev As TextReader = Nothing)
+ Me.ps1 = ps1
+ Me.shell = exec
+ Me.dev = dev Or App.StdInput
End Sub
+ '''
+ ''' 执行一个配置好的命令行模型, 代码会被一直阻塞在这里
+ '''
Public Sub Run()
- Dim cli As String
+ Dim cli As Value(Of String) = ""
Do While True
- Call Console.Write(__ps1.ToString)
+ Call Console.Write(ps1.ToString)
- cli = Console.ReadLine
-
- If String.Equals(cli, Quite) Then
- Exit Do
+ If (cli = Console.ReadLine).Trim.StringEmpty Then
+ Continue Do
End If
- Call __shell(cli)
+ If cli.Value.TextEquals(Quite) Then
+ Exit Do
+ Else
+ Call _shell(cli)
+ End If
Loop
End Sub
End Class
diff --git a/ApplicationServices/Terminal/InteractiveIODevice/Terminal.vb b/ApplicationServices/Terminal/InteractiveIODevice/Terminal.vb
index 9cbe2c00..ba307957 100644
--- a/ApplicationServices/Terminal/InteractiveIODevice/Terminal.vb
+++ b/ApplicationServices/Terminal/InteractiveIODevice/Terminal.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c08c74a1b5e60c7ce11f1c1dfbde7b00, ApplicationServices\Terminal\InteractiveIODevice\Terminal.vb"
+#Region "Microsoft.VisualBasic::c08c74a1b5e60c7ce11f1c1dfbde7b00, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\InteractiveIODevice\Terminal.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/InteractiveIODevice/TerminalExtensions.vb b/ApplicationServices/Terminal/InteractiveIODevice/TerminalExtensions.vb
index f60cbd64..17b5de9d 100644
--- a/ApplicationServices/Terminal/InteractiveIODevice/TerminalExtensions.vb
+++ b/ApplicationServices/Terminal/InteractiveIODevice/TerminalExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::10a854194c79e6e0a93f21577272dedb, ApplicationServices\Terminal\InteractiveIODevice\TerminalExtensions.vb"
+#Region "Microsoft.VisualBasic::1dc754b47a61180b1bdf10c4c1438493, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\InteractiveIODevice\TerminalExtensions.vb"
' Author:
'
@@ -38,7 +38,7 @@
'
' Properties: ConsoleHandleInvalid, CurrentSize
'
- ' Sub: __detects
+ ' Sub: doEvents
'
'
'
@@ -52,25 +52,28 @@ Imports Microsoft.VisualBasic.Language
Namespace Terminal
+ '''
+ ''' 这个终端事件会依赖于属性值来自动退出的
+ '''
Public Module TerminalEvents
Public Delegate Sub ResizeEventHandle(size As Size, oldSize As Size)
- Dim __resizeHandles As New List(Of ResizeEventHandle)
- Dim _old As Size
- Dim _eventThread As Thread
+ Dim resizeHandles As New List(Of ResizeEventHandle)
+ Dim oldSize As Size
+ Dim eventThread As Thread
Public ReadOnly Property CurrentSize As Size
Get
- Return _old
+ Return oldSize
End Get
End Property
- Private Sub __detects()
+ Private Sub doEvents()
Do While App.Running
- If Console.WindowHeight <> _old.Height Then
+ If Console.WindowHeight <> oldSize.Height Then
RaiseEvent Resize()
- ElseIf Console.WindowWidth <> _old.Width Then
+ ElseIf Console.WindowWidth <> oldSize.Width Then
RaiseEvent Resize()
End If
@@ -85,15 +88,15 @@ Namespace Terminal
'''
Public Custom Event Resize As ResizeEventHandle
AddHandler(value As ResizeEventHandle)
- If __resizeHandles.IndexOf(value) = -1 Then
- __resizeHandles += value
+ If resizeHandles.IndexOf(value) = -1 Then
+ resizeHandles += value
End If
- If _eventThread Is Nothing Then
+ If eventThread Is Nothing Then
Try
- _old = New Size(Console.WindowWidth, Console.WindowHeight)
- _eventThread = New Thread(AddressOf __detects)
- _eventThread.Start()
+ oldSize = New Size(Console.WindowWidth, Console.WindowHeight)
+ eventThread = New Thread(AddressOf doEvents)
+ eventThread.Start()
Catch ex As Exception ' 可能是WindowsForm应用,则在这里就忽略掉这个错误了
Call App.LogException(ex)
_ConsoleHandleInvalid = True
@@ -101,23 +104,23 @@ Namespace Terminal
End If
End AddHandler
RemoveHandler(value As ResizeEventHandle)
- If __resizeHandles.IndexOf(value) > -1 Then
- __resizeHandles.Remove(value)
+ If resizeHandles.IndexOf(value) > -1 Then
+ resizeHandles.Remove(value)
End If
- If __resizeHandles.Count = 0 Then
- _eventThread.Abort()
- _eventThread = Nothing
+ If resizeHandles.Count = 0 Then
+ eventThread.Abort()
+ eventThread = Nothing
End If
End RemoveHandler
RaiseEvent()
Dim [new] As New Size(Console.WindowWidth, Console.WindowHeight)
- For Each h As ResizeEventHandle In __resizeHandles
- Call h([new], _old)
+ For Each h As ResizeEventHandle In resizeHandles
+ Call h([new], oldSize)
Next
- _old = [new]
+ oldSize = [new]
End RaiseEvent
End Event
End Module
diff --git a/ApplicationServices/Terminal/MarkdownRender/MarkdownRender.vb b/ApplicationServices/Terminal/MarkdownRender/MarkdownRender.vb
new file mode 100644
index 00000000..2435552e
--- /dev/null
+++ b/ApplicationServices/Terminal/MarkdownRender/MarkdownRender.vb
@@ -0,0 +1,290 @@
+#Region "Microsoft.VisualBasic::7d62185c9ec4469f9bbebbf4abff8481, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\MarkdownRender.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 .
+
+
+
+' /********************************************************************************/
+
+' Summaries:
+
+' Class MarkdownRender
+'
+' Constructor: (+1 Overloads) Sub New
+'
+' Function: bufferAllIs, bufferIs
+'
+' Sub: DoParseSpans, DoPrint, EndSpan, Print, PrintSpans
+' restoreStyle, WalkChar
+'
+' Class MarkdownTheme
+'
+' Properties: [Global], BlockQuote, Bold, CodeBlock, InlineCodeSpan
+' Url
+'
+' Class ConsoleFontStyle
+'
+' Properties: BackgroundColor, ForeColor
+'
+' Function: Clone, CreateSpan, Equals
+'
+' Sub: SetConfig
+'
+' Class Span
+'
+' Properties: IsEndByNewLine, style, text
+'
+' Sub: Print
+'
+'
+' /********************************************************************************/
+
+#End Region
+
+Imports System.Runtime.CompilerServices
+Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Language.Default
+Imports Microsoft.VisualBasic.Text
+Imports Microsoft.VisualBasic.Text.Parser
+
+Namespace ApplicationServices.Terminal
+
+ '''
+ ''' A simple markdown render on console
+ '''
+ '''
+ ''' 主要是渲染下面的一些元素:
+ '''
+ ''' + code: 红色
+ ''' + url: 蓝色
+ ''' + blockquote: 灰色背景色
+ '''
+ Public Class MarkdownRender
+
+ Shared ReadOnly defaultTheme As [Default](Of MarkdownTheme) = New MarkdownTheme With {
+ .[Global] = (ConsoleColor.White, ConsoleColor.Black),
+ .BlockQuote = (ConsoleColor.Black, ConsoleColor.Gray),
+ .CodeBlock = (ConsoleColor.Red, ConsoleColor.Yellow),
+ .InlineCodeSpan = (ConsoleColor.Red, ConsoleColor.Black),
+ .Url = (ConsoleColor.Blue, ConsoleColor.Black),
+ .Bold = (ConsoleColor.Black, ConsoleColor.Yellow),
+ .Italy = (ConsoleColor.Yellow, ConsoleColor.DarkGray)
+ }
+
+ Dim theme As MarkdownTheme
+ Dim markdown As CharPtr
+ Dim indent As Integer
+
+ Private Sub New(theme As MarkdownTheme)
+ Me.theme = theme
+ End Sub
+
+ Public Sub DoPrint(markdown$, indent%)
+ Me.markdown = markdown.LineTokens.JoinBy(ASCII.LF)
+ Me.indent = indent
+ Me.theme.Global.SetConfig(Me)
+ Me.DoParseSpans()
+ Me.PrintSpans()
+ End Sub
+
+ Private Sub DoParseSpans()
+ Do While Not markdown.EndRead
+ Call WalkChar(++markdown)
+ Loop
+
+ If textBuf > 0 Then
+ Call EndSpan(False)
+ End If
+ End Sub
+
+ Dim boldSpan As Boolean = False
+ Dim inlineCodespan As Boolean = False
+ Dim blockquote As Boolean = False
+ Dim italySpan As Boolean = False
+ Dim lastNewLine As Boolean
+ Dim controlBuf As New List(Of Char)
+ Dim textBuf As New List(Of Char)
+
+ Friend styleStack As New Stack(Of ConsoleFontStyle)
+ Friend currentStyle As ConsoleFontStyle
+
+ Dim spans As New List(Of Span)
+
+ Public Sub Reset()
+ blockquote = False
+ boldSpan = False
+ inlineCodespan = False
+ lastNewLine = False
+ italySpan = False
+ controlBuf *= 0
+ textBuf *= 0
+ styleStack.Clear()
+ spans *= 0
+ End Sub
+
+ Private Function bufferIs(term As String) As Boolean
+ If controlBuf <> term.Length Then
+ Return False
+ Else
+ Return controlBuf.SequenceEqual(term)
+ End If
+ End Function
+
+ Private Function bufferAllIs(c As Char) As Boolean
+ If controlBuf = 0 Then
+ Return False
+ Else
+ Return controlBuf.All(Function(b) b = c)
+ End If
+ End Function
+
+ Private Sub restoreStyle()
+ styleStack.Pop()
+
+ If styleStack.Count = 0 Then
+ Call theme.Global.SetConfig(Me)
+ Else
+ Call styleStack.Peek.SetConfig(Me)
+ End If
+ End Sub
+
+ Private Sub PrintSpans()
+ Dim isNewLine As Boolean = True
+
+ For Each span As Span In spans
+ If isNewLine Then
+ Console.CursorLeft = indent
+ End If
+
+ span.Print()
+ isNewLine = span.IsEndByNewLine
+ Next
+ End Sub
+
+ Private Sub EndSpan(byNewLine As Boolean)
+ Dim text As String = textBuf.CharString
+ Dim style As ConsoleFontStyle = currentStyle.Clone
+
+ If text.StartsWith("((http(s)?)|(ftp))[:]//", RegexICSng) Then
+ style = theme.Url
+ End If
+
+ If styleStack.Peek.Equals(theme.CodeBlock) Then
+ style.BackgroundColor = theme.CodeBlock.BackgroundColor
+ End If
+
+ spans += New Span With {
+ .style = style,
+ .text = text,
+ .IsEndByNewLine = byNewLine
+ }
+ textBuf *= 0
+ End Sub
+
+ Private Sub WalkChar(c As Char)
+ Select Case c
+ Case "`"c
+ controlBuf += c
+ lastNewLine = False
+ Case "*"c
+ controlBuf += c
+ lastNewLine = False
+ Case ASCII.LF
+ lastNewLine = True
+ blockquote = False
+ textBuf += ASCII.LF
+ EndSpan(True)
+ restoreStyle()
+ Case ">"c
+ If lastNewLine AndAlso controlBuf = 0 Then
+ controlBuf += c
+ ElseIf lastNewLine AndAlso bufferIs(">") Then
+ ' 空白的blockquote行
+ Else
+ textBuf += c
+ End If
+ lastNewLine = False
+ Case " "c
+ lastNewLine = False
+
+ If controlBuf = 1 AndAlso controlBuf(Scan0) = ">"c Then
+ blockquote = True
+ controlBuf *= 0
+ theme.BlockQuote.SetConfig(Me)
+ textBuf += " "c
+ textBuf += " "c
+ Else
+ EndSpan(False)
+ textBuf += c
+ EndSpan(False)
+ End If
+ Case Else
+ lastNewLine = False
+
+ If bufferIs("``") Then
+ If inlineCodespan Then
+ ' 结束栈
+ EndSpan(False)
+ inlineCodespan = False
+ restoreStyle()
+ Else
+ EndSpan(False)
+ inlineCodespan = True
+ theme.InlineCodeSpan.SetConfig(Me)
+ End If
+
+ controlBuf *= 0
+ textBuf += c
+ ElseIf bufferIs("**") Then
+ If boldSpan Then
+ EndSpan(False)
+ boldSpan = False
+ restoreStyle()
+ Else
+ EndSpan(False)
+ boldSpan = True
+ theme.Bold.SetConfig(Me)
+ End If
+
+ controlBuf *= 0
+ textBuf += c
+ Else
+ textBuf += c
+ End If
+ End Select
+ End Sub
+
+
+ Public Shared Sub Print(markdown As String, Optional theme As MarkdownTheme = Nothing, Optional indent% = 0)
+ Call New MarkdownRender(theme Or defaultTheme).DoPrint(markdown, indent)
+ End Sub
+
+
+ Public Shared Function DefaultStyleRender() As MarkdownRender
+ Return New MarkdownRender(defaultTheme)
+ End Function
+ End Class
+End Namespace
diff --git a/ApplicationServices/Terminal/MarkdownRender/Theme.vb b/ApplicationServices/Terminal/MarkdownRender/Theme.vb
new file mode 100644
index 00000000..341bcb5a
--- /dev/null
+++ b/ApplicationServices/Terminal/MarkdownRender/Theme.vb
@@ -0,0 +1,92 @@
+Imports System.Runtime.CompilerServices
+Imports Microsoft.VisualBasic.Imaging
+Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Serialization
+
+Namespace ApplicationServices.Terminal
+
+ Public Class MarkdownTheme
+
+ Public Property Url As ConsoleFontStyle
+ Public Property InlineCodeSpan As ConsoleFontStyle
+ Public Property CodeBlock As ConsoleFontStyle
+ Public Property BlockQuote As ConsoleFontStyle
+ Public Property [Global] As ConsoleFontStyle
+ Public Property Bold As ConsoleFontStyle
+ Public Property Italy As ConsoleFontStyle
+
+ End Class
+
+ Public Class ConsoleFontStyle
+ Implements IEquatable(Of ConsoleFontStyle)
+ Implements ICloneable(Of ConsoleFontStyle)
+
+ Public Property ForeColor As ConsoleColor = ConsoleColor.White
+ Public Property BackgroundColor As ConsoleColor = ConsoleColor.Black
+
+ Public Sub SetConfig(render As MarkdownRender)
+ Console.ForegroundColor = ForeColor
+ Console.BackgroundColor = BackgroundColor
+
+ render.currentStyle = Me
+ render.styleStack.Push(Me)
+ End Sub
+
+ Public Function CreateSpan(text As String) As Span
+ Return New Span With {
+ .style = Me,
+ .text = text
+ }
+ End Function
+
+ Public Function Clone() As ConsoleFontStyle Implements ICloneable(Of ConsoleFontStyle).Clone
+ Return New ConsoleFontStyle With {
+ .BackgroundColor = BackgroundColor,
+ .ForeColor = ForeColor
+ }
+ End Function
+
+ Public Overloads Function Equals(other As ConsoleFontStyle) As Boolean Implements IEquatable(Of ConsoleFontStyle).Equals
+ If other Is Nothing Then
+ Return False
+ Else
+ Return BackgroundColor = other.BackgroundColor AndAlso ForeColor = other.ForeColor
+ End If
+ End Function
+
+ Public Shared Widening Operator CType(colors As (fore As ConsoleColor, back As ConsoleColor)) As ConsoleFontStyle
+ Return New ConsoleFontStyle With {
+ .ForeColor = colors.fore,
+ .BackgroundColor = colors.back
+ }
+ End Operator
+
+ Public Shared Function HtmlColorCode(color As ConsoleColor) As String
+ Return Drawing.Color.FromName(color.ToString).ToHtmlColor
+ End Function
+ End Class
+
+ Public Class Span
+
+ Public Property text As String
+ Public Property style As ConsoleFontStyle
+ Public Property IsEndByNewLine As Boolean
+
+
+ Public Sub Print()
+ Call My.Log4VB.Print(Me)
+ End Sub
+
+ Public Overrides Function ToString() As String
+ Dim text$ = Me.text
+
+ If text.StringEmpty Then
+ text = ""
+ Else
+ text = $"""{text}"""
+ End If
+
+ Return style.ForeColor.DoCall(AddressOf ConsoleFontStyle.HtmlColorCode) & " " & text
+ End Function
+ End Class
+End Namespace
\ No newline at end of file
diff --git a/ApplicationServices/Terminal/PipelineCLI.vb b/ApplicationServices/Terminal/PipelineCLI.vb
index 53cd7e73..24badf43 100644
--- a/ApplicationServices/Terminal/PipelineCLI.vb
+++ b/ApplicationServices/Terminal/PipelineCLI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2c82045a56ccf9a6611a6f19d9df9155, ApplicationServices\Terminal\PipelineCLI.vb"
+#Region "Microsoft.VisualBasic::2c82045a56ccf9a6611a6f19d9df9155, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\PipelineCLI.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/PrintAsTable.vb b/ApplicationServices/Terminal/PrintAsTable.vb
index 99732197..5a53d503 100644
--- a/ApplicationServices/Terminal/PrintAsTable.vb
+++ b/ApplicationServices/Terminal/PrintAsTable.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::87ff800f84a01faadeeb402ebf125a11, ApplicationServices\Terminal\PrintAsTable.vb"
+#Region "Microsoft.VisualBasic::a275c83c8bc14c6ae8ba6fdc99769986, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\PrintAsTable.vb"
' Author:
'
@@ -115,10 +115,11 @@ Namespace ApplicationServices.Terminal
Select p,
s = p.GetValue(x)) _
.ToDictionary(Function(o) o.p.Identity,
- Function(o) Scripting.ToString(o.s))
+ Function(o)
+ Return Scripting.ToString(o.s)
+ End Function)
- Dim table As List(Of String()) =
- contents _
+ Dim table As List(Of String()) = contents _
.Select(Function(line)
Return titles.Select(Function(name) line(name)).ToArray
End Function) _
@@ -134,7 +135,7 @@ Namespace ApplicationServices.Terminal
'''
''' 与函数所不同的是,这个函数还会添加边框
'''
- '''
+ ''' Each element is a row in table matrix
'''
'''
diff --git a/ApplicationServices/Terminal/STDIO__/I_ConsoleDeviceHandle.vb b/ApplicationServices/Terminal/STDIO__/I_ConsoleDeviceHandle.vb
index 8af7bda5..cf8da902 100644
--- a/ApplicationServices/Terminal/STDIO__/I_ConsoleDeviceHandle.vb
+++ b/ApplicationServices/Terminal/STDIO__/I_ConsoleDeviceHandle.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2aa3a0e8fd3451b671d76bef6a1c3bbc, ApplicationServices\Terminal\STDIO__\I_ConsoleDeviceHandle.vb"
+#Region "Microsoft.VisualBasic::2aa3a0e8fd3451b671d76bef6a1c3bbc, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\STDIO__\I_ConsoleDeviceHandle.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/STDIO__/STDIO.vb b/ApplicationServices/Terminal/STDIO__/STDIO.vb
index 8d7f7e6c..10a041cf 100644
--- a/ApplicationServices/Terminal/STDIO__/STDIO.vb
+++ b/ApplicationServices/Terminal/STDIO__/STDIO.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0ecd7b473e0dc43dfa7dec39c98e5467, ApplicationServices\Terminal\STDIO__\STDIO.vb"
+#Region "Microsoft.VisualBasic::746397a3e498941b6c5ecaa188fa1fb3, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\STDIO__\STDIO.vb"
' Author:
'
@@ -33,7 +33,7 @@
' Module STDIO
'
- ' Function: __testEquals, MsgBox, scanf, ZeroFill
+ ' Function: charTestEquals, MsgBox, scanf, ZeroFill
'
' Sub: cat, fprintf, print, printf
' Delegate Function
@@ -217,20 +217,20 @@ Namespace Terminal
End If
If style = MsgBoxStyle.AbortRetryIgnore Then
- If __testEquals(input, "A"c) Then
+ If charTestEquals(input, "A"c) Then
Return MsgBoxResult.Abort
- ElseIf __testEquals(input, "R"c) Then
+ ElseIf charTestEquals(input, "R"c) Then
Return MsgBoxResult.Retry
- ElseIf __testEquals(input, "I"c) Then
+ ElseIf charTestEquals(input, "I"c) Then
Return MsgBoxResult.Ignore
Else
Return MsgBoxResult.Retry
End If
ElseIf style = MsgBoxStyle.OkCancel Then
- If __testEquals(input, "O"c) Then
+ If charTestEquals(input, "O"c) Then
Return MsgBoxResult.Ok
- ElseIf __testEquals(input, "C"c) Then
+ ElseIf charTestEquals(input, "C"c) Then
Return MsgBoxResult.Cancel
Else
Return MsgBoxResult.Ok
@@ -239,29 +239,29 @@ Namespace Terminal
Return MsgBoxResult.Ok
ElseIf style = MsgBoxStyle.RetryCancel Then
- If __testEquals(input, "R"c) Then
+ If charTestEquals(input, "R"c) Then
Return MsgBoxResult.Retry
- ElseIf __testEquals(input, "C"c) Then
+ ElseIf charTestEquals(input, "C"c) Then
Return MsgBoxResult.Cancel
Else
Return MsgBoxResult.Retry
End If
ElseIf style = MsgBoxStyle.YesNo Then
- If __testEquals(input, "Y"c) Then
+ If charTestEquals(input, "Y"c) Then
Return MsgBoxResult.Yes
- ElseIf __testEquals(input, "N"c) Then
+ ElseIf charTestEquals(input, "N"c) Then
Return MsgBoxResult.No
Else
Return MsgBoxResult.Yes
End If
ElseIf style = MsgBoxStyle.YesNoCancel Then
- If __testEquals(input, "Y"c) Then
+ If charTestEquals(input, "Y"c) Then
Return MsgBoxResult.Yes
- ElseIf __testEquals(input, "N"c) Then
+ ElseIf charTestEquals(input, "N"c) Then
Return MsgBoxResult.No
- ElseIf __testEquals(input, "C"c) Then
+ ElseIf charTestEquals(input, "C"c) Then
Return MsgBoxResult.Cancel
Else
Return MsgBoxResult.Yes
@@ -277,11 +277,12 @@ Namespace Terminal
'''
''' 大写的
'''
- Private Function __testEquals(input As String, compare As Char) As Boolean
+ Private Function charTestEquals(input As String, compare As Char) As Boolean
If String.IsNullOrEmpty(input) Then
Return False
+ Else
+ Return Asc(input.First) = Asc(compare)
End If
- Return Asc(input.First) = Asc(compare)
End Function
Public Delegate Function TryParseDelegate(Of T)(str$, ByRef val As T) As Boolean
@@ -303,6 +304,7 @@ Namespace Terminal
Public Function Read(Of T)(msg$, parser As TryParseDelegate(Of T), Optional _default$ = Nothing) As T
Dim line As String
Dim value As T
+
Do
Call Console.Write(msg)
@@ -318,6 +320,7 @@ Namespace Terminal
line = _default?.ToString()
End If
Loop While Not parser(line, value)
+
Return value
End Function
diff --git a/ApplicationServices/Terminal/STDIO__/Shell.vb b/ApplicationServices/Terminal/STDIO__/Shell.vb
index 6536fb3d..21c54787 100644
--- a/ApplicationServices/Terminal/STDIO__/Shell.vb
+++ b/ApplicationServices/Terminal/STDIO__/Shell.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9739a2dfdefc02b9fe20ca81f03b878d, ApplicationServices\Terminal\STDIO__\Shell.vb"
+#Region "Microsoft.VisualBasic::0ea13648757d596ce2efe0336862a71f, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\STDIO__\Shell.vb"
' Author:
'
@@ -108,8 +108,8 @@ Namespace Terminal.STDIO__
Dim Tokens = Regex.Split(CommandLine, Global.Microsoft.VisualBasic.CommandLine.SPLIT_REGX_EXPRESSION)
Dim EXE As String = Tokens.First
Dim Arguments As String = Mid$(CommandLine, Len(EXE) + 1)
- Dim Process As System.Diagnostics.Process = New Process
- Dim pInfo As System.Diagnostics.ProcessStartInfo = New ProcessStartInfo(EXE, Arguments)
+ Dim Process As New Process
+ Dim pInfo As New ProcessStartInfo(EXE, Arguments)
Process.StartInfo = pInfo
Process.StartInfo.WindowStyle = WindowStyle
diff --git a/ApplicationServices/Terminal/Utility/CBusyIndicator.vb b/ApplicationServices/Terminal/Utility/CBusyIndicator.vb
index e748c4cf..d2529b23 100644
--- a/ApplicationServices/Terminal/Utility/CBusyIndicator.vb
+++ b/ApplicationServices/Terminal/Utility/CBusyIndicator.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6e8b09e7218d99da99b8ace3223a2777, ApplicationServices\Terminal\Utility\CBusyIndicator.vb"
+#Region "Microsoft.VisualBasic::aa267559a941d77296fe1975ee1b590b, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\CBusyIndicator.vb"
' Author:
'
@@ -41,7 +41,6 @@
#End Region
-Imports System.Runtime.CompilerServices
Imports System.Threading
Imports Microsoft.VisualBasic.Parallel
@@ -53,25 +52,28 @@ Namespace Terminal.Utility
Public Class CBusyIndicator : Implements IDisposable
Dim _indicatorStyle As Char
- Dim _OnRunningState As Boolean = False
- Dim _TicksCount As Integer
+ Dim _onRunningState As Boolean = False
+ Dim _ticksCount As Integer
- Sub New(Optional IndicatorStyle As Char = "."c, Optional _start As Boolean = False, Optional Ticks As Integer = -1)
- _indicatorStyle = IndicatorStyle
- If _start Then Call Start(Ticks)
+ Sub New(Optional indicatorStyle As Char = "."c, Optional start As Boolean = False, Optional ticks As Integer = -1)
+ _indicatorStyle = indicatorStyle
+
+ If start Then
+ Call Me.Start(ticks)
+ End If
End Sub
Private Sub DoEvents()
- Do While _OnRunningState = True
+ Do While _onRunningState = True
Call Thread.Sleep(1000)
Call STDIO.Write(_indicatorStyle)
- If _TicksCount > 0 Then
- _TicksCount -= 1
+ If _ticksCount > 0 Then
+ _ticksCount -= 1
Else
- If _TicksCount <> -1 Then
- _OnRunningState = False
+ If _ticksCount <> -1 Then
+ _onRunningState = False
End If
End If
Loop
@@ -83,18 +85,18 @@ Namespace Terminal.Utility
''' The total ticking counts of the indicator, Unit is [second].
'''
Public Sub Start(Optional Ticks As Integer = -1)
- If _OnRunningState = True Then
+ If _onRunningState = True Then
Return
End If
- _TicksCount = Ticks
- _OnRunningState = True
+ _ticksCount = Ticks
+ _onRunningState = True
Call RunTask(AddressOf DoEvents)
End Sub
Public Sub [Stop]()
- _OnRunningState = False
+ _onRunningState = False
End Sub
#Region "IDisposable Support"
@@ -105,7 +107,7 @@ Namespace Terminal.Utility
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
- _OnRunningState = False
+ _onRunningState = False
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
diff --git a/ApplicationServices/Terminal/Utility/ConsolePasswordInput.vb b/ApplicationServices/Terminal/Utility/ConsolePasswordInput.vb
index 6e8d6bd9..c16ccd2d 100644
--- a/ApplicationServices/Terminal/Utility/ConsolePasswordInput.vb
+++ b/ApplicationServices/Terminal/Utility/ConsolePasswordInput.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a327073d8c1912fb6d47e38285e938b0, ApplicationServices\Terminal\Utility\ConsolePasswordInput.vb"
+#Region "Microsoft.VisualBasic::a327073d8c1912fb6d47e38285e938b0, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ConsolePasswordInput.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/Utility/EventProc.vb b/ApplicationServices/Terminal/Utility/EventProc.vb
index 5746a61c..b52a448a 100644
--- a/ApplicationServices/Terminal/Utility/EventProc.vb
+++ b/ApplicationServices/Terminal/Utility/EventProc.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a55db275422fac8c7cd30fc5b1d99117, ApplicationServices\Terminal\Utility\EventProc.vb"
+#Region "Microsoft.VisualBasic::c8b2331b708aeb685fc608df50947246, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\EventProc.vb"
' Author:
'
@@ -74,7 +74,7 @@ Namespace Terminal.Utility
Dim delta As Integer
Dim tag As String
Dim out As StreamWriter
- Dim current As VBInteger = 0
+ Dim current As i32 = 0
'''
'''
@@ -85,9 +85,7 @@ Namespace Terminal.Utility
Sub New(n As Integer, Optional tag As String = "", Optional out As StreamWriter = Nothing)
Me.Capacity = n
Me.tag = tag
- Me.out = If(out Is Nothing,
- New StreamWriter(Console.OpenStandardOutput),
- out)
+ Me.out = out Or App.StdOut
If String.IsNullOrEmpty(Me.tag) Then
Me.tag = vbTab
diff --git a/ApplicationServices/Terminal/Utility/ManualPages.vb b/ApplicationServices/Terminal/Utility/ManualPages.vb
index 61d0e226..785fe3ce 100644
--- a/ApplicationServices/Terminal/Utility/ManualPages.vb
+++ b/ApplicationServices/Terminal/Utility/ManualPages.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::022c48ff60aa11fbd66b2c657c58ba1c, ApplicationServices\Terminal\Utility\ManualPages.vb"
+#Region "Microsoft.VisualBasic::022c48ff60aa11fbd66b2c657c58ba1c, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ManualPages.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/ProgressBar/AbstractBar.vb b/ApplicationServices/Terminal/Utility/ProgressBar/AbstractBar.vb
similarity index 94%
rename from ApplicationServices/Terminal/ProgressBar/AbstractBar.vb
rename to ApplicationServices/Terminal/Utility/ProgressBar/AbstractBar.vb
index cee23935..8ccc65bb 100644
--- a/ApplicationServices/Terminal/ProgressBar/AbstractBar.vb
+++ b/ApplicationServices/Terminal/Utility/ProgressBar/AbstractBar.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cb989a65864302229727d204bec99e19, ApplicationServices\Terminal\ProgressBar\AbstractBar.vb"
+#Region "Microsoft.VisualBasic::cb989a65864302229727d204bec99e19, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ProgressBar\AbstractBar.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/ProgressBar/AnimatedBar.vb b/ApplicationServices/Terminal/Utility/ProgressBar/AnimatedBar.vb
similarity index 95%
rename from ApplicationServices/Terminal/ProgressBar/AnimatedBar.vb
rename to ApplicationServices/Terminal/Utility/ProgressBar/AnimatedBar.vb
index fe61690e..1142c951 100644
--- a/ApplicationServices/Terminal/ProgressBar/AnimatedBar.vb
+++ b/ApplicationServices/Terminal/Utility/ProgressBar/AnimatedBar.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::add5e7662691a588b501cb9803aff443, ApplicationServices\Terminal\ProgressBar\AnimatedBar.vb"
+#Region "Microsoft.VisualBasic::add5e7662691a588b501cb9803aff443, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ProgressBar\AnimatedBar.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/ProgressBar/Program.vb b/ApplicationServices/Terminal/Utility/ProgressBar/Program.vb
similarity index 95%
rename from ApplicationServices/Terminal/ProgressBar/Program.vb
rename to ApplicationServices/Terminal/Utility/ProgressBar/Program.vb
index 8f8a7fba..f46c04de 100644
--- a/ApplicationServices/Terminal/ProgressBar/Program.vb
+++ b/ApplicationServices/Terminal/Utility/ProgressBar/Program.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ed83e7b7feb6cc4ee61e7cc071105a28, ApplicationServices\Terminal\ProgressBar\Program.vb"
+#Region "Microsoft.VisualBasic::ed83e7b7feb6cc4ee61e7cc071105a28, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ProgressBar\Program.vb"
' Author:
'
diff --git a/ApplicationServices/Terminal/ProgressBar/ProgressBar.png b/ApplicationServices/Terminal/Utility/ProgressBar/ProgressBar.png
similarity index 100%
rename from ApplicationServices/Terminal/ProgressBar/ProgressBar.png
rename to ApplicationServices/Terminal/Utility/ProgressBar/ProgressBar.png
diff --git a/ApplicationServices/Terminal/ProgressBar/ProgressBar.vb b/ApplicationServices/Terminal/Utility/ProgressBar/ProgressBar.vb
similarity index 90%
rename from ApplicationServices/Terminal/ProgressBar/ProgressBar.vb
rename to ApplicationServices/Terminal/Utility/ProgressBar/ProgressBar.vb
index 4bd3c70f..35a11fc3 100644
--- a/ApplicationServices/Terminal/ProgressBar/ProgressBar.vb
+++ b/ApplicationServices/Terminal/Utility/ProgressBar/ProgressBar.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::62654a088843804f9eb38fd9f0772359, ApplicationServices\Terminal\ProgressBar\ProgressBar.vb"
+#Region "Microsoft.VisualBasic::70e68318cf1bdf1b9675d9786ea4858e, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ProgressBar\ProgressBar.vb"
' Author:
'
@@ -60,6 +60,7 @@
Imports System.Drawing
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Language.Default
+Imports Microsoft.VisualBasic.My.FrameworkInternal
Imports Microsoft.VisualBasic.Serialization.JSON
Namespace Terminal.ProgressBar
@@ -124,7 +125,7 @@ Namespace Terminal.ProgressBar
'''
Public Shared Function DefaultTheme() As [Default](Of ColorTheme)
Return New [Default](Of ColorTheme) With {
- .Value = [Default](),
+ .value = [Default](),
.assert = Function(t)
Return DirectCast(t, ColorTheme).IsEmpty
End Function
@@ -150,6 +151,8 @@ Namespace Terminal.ProgressBar
'''
''' http://www.cnblogs.com/masonlu/p/4668232.html
'''
+ '''
+
Public Class ProgressBar : Inherits AbstractBar
Implements IDisposable
@@ -165,6 +168,11 @@ Namespace Terminal.ProgressBar
Shared disabled As Boolean
+ '''
+ ''' If this global value is not null, then set y value in constructor will be disabled.
+ '''
+ Shared pinnedTop As Integer?
+
Public Shared Property Enable As Boolean
Get
Return Not disabled
@@ -174,8 +182,15 @@ Namespace Terminal.ProgressBar
End Set
End Property
+ Friend Const TerminalProgressBarEnvironmentConfigName$ = "progress_bar"
+
Shared Sub New()
- disabled = App.GetVariable("progress_bar").TextEquals(NameOf(disabled))
+ disabled = App.GetVariable(TerminalProgressBarEnvironmentConfigName).TextEquals(NameOf(disabled))
+
+ ' The progress bar is also be disable in internal pipeline mode
+ If App.GetVariable(name:=FlagInternalPipeline).ParseBoolean = True Then
+ disabled = True
+ End If
End Sub
'''
@@ -194,6 +209,10 @@ Namespace Terminal.ProgressBar
Me.theme = theme Or ColorTheme.DefaultTheme
Me.y = Y
+ If Not pinnedTop Is Nothing Then
+ Me.y = pinnedTop
+ End If
+
If Not disabled Then
AddHandler TerminalEvents.Resize, AddressOf consoleWindowResize
@@ -310,6 +329,18 @@ Namespace Terminal.ProgressBar
End If
End Sub
+ Public Shared Sub ClearPinnedTop()
+ pinnedTop = Nothing
+ End Sub
+
+ Public Shared Sub PinTop(top As Integer)
+ pinnedTop = top
+ End Sub
+
+ Public Shared Function GetCurrentConsoleTop() As Integer
+ Return Console.CursorTop
+ End Function
+
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
@@ -411,6 +442,14 @@ Namespace Terminal.ProgressBar
Return Me.GetJson
End Function
+ Shared ReadOnly NaN As Double = New TimeSpan(
+ days:=9999999,' 10658576,
+ hours:=23,
+ minutes:=59,
+ seconds:=59,
+ milliseconds:=59
+ ).TotalMilliseconds
+
'''
'''
'''
@@ -427,6 +466,12 @@ Namespace Terminal.ProgressBar
Dim lefts = (1 - cur) / d ' lefts = 100% - currents
Dim time = lefts * Elapsed
+
+ ' System.OverflowException: TimeSpan overflowed because the duration is too long.
+ If time > NaN Then
+ time = NaN
+ End If
+
Dim estimates = TimeSpan.FromMilliseconds(time)
Return estimates
End Function
diff --git a/ApplicationServices/Terminal/ProgressBar/SwayBar.vb b/ApplicationServices/Terminal/Utility/ProgressBar/SwayBar.vb
similarity index 87%
rename from ApplicationServices/Terminal/ProgressBar/SwayBar.vb
rename to ApplicationServices/Terminal/Utility/ProgressBar/SwayBar.vb
index 4ea606e8..494e1621 100644
--- a/ApplicationServices/Terminal/ProgressBar/SwayBar.vb
+++ b/ApplicationServices/Terminal/Utility/ProgressBar/SwayBar.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e93d47961896d9fcaad122fc7e9c01ed, ApplicationServices\Terminal\ProgressBar\SwayBar.vb"
+#Region "Microsoft.VisualBasic::048f32846f78aa68beea6ea3aad8aab0, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\Utility\ProgressBar\SwayBar.vb"
' Author:
'
@@ -46,7 +46,7 @@
'
' Function: buildBlankPointer
'
- ' Sub: [Step], ClearBar, PlacePointer
+ ' Sub: (+2 Overloads) [Step], ClearBar, PlacePointer
'
'
' /********************************************************************************/
@@ -126,6 +126,10 @@ Namespace Terminal.ProgressBar
''' prints the progress bar acorrding to pointers and current direction
'''
Public Overrides Sub [Step]()
+ Call [Step](message:="")
+ End Sub
+
+ Public Overloads Sub [Step](message As String)
If currdir = direction.right Then
PlacePointer(counter, pointer.Length)
counter += 1
@@ -142,7 +146,13 @@ Namespace Terminal.ProgressBar
End If
End If
- Call Console.Write(bar & vbCr)
+ message = bar & message
+
+ If message.Length > Console.WindowWidth Then
+ message = Mid(message, 1, Console.WindowWidth - 15) & "..."
+ End If
+
+ Call Console.Write(message & vbCr)
End Sub
End Class
End Namespace
diff --git a/ApplicationServices/Terminal/xConsole/Comparer.vb b/ApplicationServices/Terminal/xConsole/Comparer.vb
new file mode 100644
index 00000000..cdfce9bc
--- /dev/null
+++ b/ApplicationServices/Terminal/xConsole/Comparer.vb
@@ -0,0 +1,149 @@
+#Region "Microsoft.VisualBasic::ba5a42b26cebb753302fe07afddec2fb, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\xConsole\Comparer.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class Comparer
+ '
+ ' Constructor: (+3 Overloads) Sub New
+ ' Function: Find
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Namespace Terminal.xConsole
+
+#Region "COMPARER 💻"
+
+ '''
+ ''' This can compute the input then return back the most appropriate word.
+ '''
+ Public Class Comparer
+
+ '''
+ ''' This is the word to find
+ '''
+ Public Word As String = String.Empty
+
+ '''
+ ''' Descrizione
+ '''
+ Public Description As String = String.Empty
+
+ '''
+ ''' Init to 0!
+ '''
+ Private Points As Integer = 0
+
+ '''
+ ''' Initliaze a new instance
+ '''
+ ''' The word to find
+ ''' It's should be 0
+ Public Sub New(w As String, p As Integer)
+ Word = w
+ Points = p
+ End Sub
+
+ '''
+ ''' Initliaze a new instance
+ '''
+ ''' The word to find
+ Public Sub New(w As String)
+ Word = w
+ Points = 0
+ End Sub
+
+ '''
+ ''' Initliaze a new instance
+ '''
+ ''' The word to find
+ ''' Description (do nothing)
+ Public Sub New(w As String, desc As String)
+ Word = w
+ Description = desc
+ End Sub
+
+ '''
+ ''' Find a word from an input abbreviation (es n > name)
+ '''
+ '''
+ Public Overloads Shared Function Find(abbr As String, ByRef Words As List(Of Comparer)) As String
+ Dim Result As String = String.Empty
+ Dim Best As Integer = 0
+ Dim c As Integer = 0
+
+ While Words.Count > c AndAlso Words(c) IsNot Nothing
+ Dim word = Words(c)
+
+ If abbr = word.Word Then
+ Result = abbr
+ Exit While
+ End If
+
+ For i As Integer = 0 To abbr.Length - 1
+ If abbr.Length < word.Word.Length AndAlso abbr(i) = word.Word(i) Then
+ word.Points += 1
+ Else
+ word.Points = 0
+ Exit For
+ End If
+ Next
+
+ If word.Points > Best Then
+ Best = word.Points
+ End If
+
+
+ c += 1
+ End While
+ ' End while
+ Dim n As Integer = 0
+ For Each word As Comparer In Words
+ If word.Points = Best AndAlso word.Points > 0 Then
+ Result = word.Word
+ If System.Threading.Interlocked.Increment(n) > 1 Then
+ Result = String.Empty
+ End If
+ End If
+ Next
+
+ Return Result
+ End Function
+ End Class
+
+ '////////////////////////////////////////////////////////////////////////////////////////////////
+ '////////////////////////////////////////////////////////////////////////////////////////////////
+ '////////////////////////////////////////////////////////////////////////////////////////////////
+#End Region
+End Namespace
diff --git a/ApplicationServices/Terminal/xConsole/CoolWriteSettings.vb b/ApplicationServices/Terminal/xConsole/CoolWriteSettings.vb
new file mode 100644
index 00000000..5d3e4002
--- /dev/null
+++ b/ApplicationServices/Terminal/xConsole/CoolWriteSettings.vb
@@ -0,0 +1,68 @@
+#Region "Microsoft.VisualBasic::08920a87692c09624918fe290bdd11a1, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\xConsole\CoolWriteSettings.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class CoolWriteSettings
+ '
+ ' Properties: CoolWriting, CoolWritingDelay, CWRDDelay
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Namespace Terminal.xConsole
+
+ Public NotInheritable Class CoolWriteSettings
+
+ '''
+ ''' Gradual typing the output into console
+ '''
+ Public Shared Property CoolWriting As Boolean = False
+
+ '''
+ ''' Write speed
+ '''
+ Public Shared Property CoolWritingDelay As Integer = 8
+
+ '''
+ ''' Set the delay when write a new line or dots. (Default = 200).
+ '''
+ Public Shared Property CWRDDelay As Integer = 280
+
+ Private Sub New()
+ End Sub
+ End Class
+
+End Namespace
diff --git a/ApplicationServices/Terminal/xConsole/Helpers.vb b/ApplicationServices/Terminal/xConsole/Helpers.vb
index ae8d96a0..6422c280 100644
--- a/ApplicationServices/Terminal/xConsole/Helpers.vb
+++ b/ApplicationServices/Terminal/xConsole/Helpers.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4efecaebf76db9799527811db18dd578, ApplicationServices\Terminal\xConsole\Helpers.vb"
+#Region "Microsoft.VisualBasic::48ab17311b3ed47c9fd117423a9c1d25, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\xConsole\Helpers.vb"
' Author:
'
@@ -57,7 +57,7 @@
Imports System.Drawing
Imports System.Runtime.InteropServices
-Namespace Terminal
+Namespace Terminal.xConsole
'''
''' Console helper. http://blogs.microsoft.co.il/blogs/pavely/archive/2009/07/23/changing-console-fonts.aspx
diff --git a/ApplicationServices/Terminal/xConsole/Spinner.vb b/ApplicationServices/Terminal/xConsole/Spinner.vb
new file mode 100644
index 00000000..d145c883
--- /dev/null
+++ b/ApplicationServices/Terminal/xConsole/Spinner.vb
@@ -0,0 +1,159 @@
+#Region "Microsoft.VisualBasic::6b2a995592ac29c3908c6d5929d38511, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\xConsole\Spinner.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class Spinner
+ '
+ ' Constructor: (+2 Overloads) Sub New
+ '
+ ' Function: Turn
+ '
+ ' Sub: Break, Run, RunTask
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Drawing
+Imports System.Threading
+
+Namespace Terminal.xConsole
+
+#Region "SPINNER ⌛"
+
+ '''
+ ''' A list of spinners for your console ❤
+ '''
+ Public Class Spinner
+ Private counter As Integer = 0
+ Private c As Char()
+
+ '''
+ ''' List of available spinners (you can add new)
+ '''
+ Public Spinners As New List(Of Char())() From {
+ New Char() {"-"c, "\"c, "|"c, "/"c},
+ New Char() {"▄"c, "■"c, "▀"c, "■"c},
+ New Char() {"╔"c, "╗"c, "╝"c, "╚"c},
+ New Char() {"."c, "·"c, "`"c, "·"c},
+ New Char() {"1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "0"c}
+ }
+
+ '''
+ ''' looplooplooplooplooplooplooplooplooploop[...]
+ '''
+ Private inLoop As Boolean = True
+
+ '''
+ ''' The base string for spinning. {0} will display the spinner. COLOR is SUPPORTED! 🆒
+ '''
+ Public SpinText As String = "{0} ^gLoading^!..."
+
+ '''
+ ''' Initialize the spinner
+ '''
+ ''' Index of the spinner to use
+ ''' Base string. `{0} show the spinner`
+ Public Sub New(Optional i As Integer = 0, Optional txt As String = Nothing)
+ If Not String.IsNullOrWhiteSpace(txt) Then
+ SpinText = txt
+ End If
+ c = If((Spinners.Count > i), Spinners(i), Spinners(0))
+ End Sub
+
+ '''
+ ''' Initialize a custom spinner
+ '''
+ ''' Set a custom spinner, no size limit.
+ Public Sub New(spinner As Char())
+ c = spinner
+ End Sub
+
+ '''
+ ''' Breaks the spinner
+ '''
+ Public Sub Break()
+ inLoop = False
+ End Sub
+
+ Private StringSize As Integer = 0
+
+ '''
+ ''' Turn the spin!
+ '''
+ ''' Waiting time. Default 130 ms
+ ''' False if it has been stopped
+ ''' while(spinner.Turn());
+ Public Function Turn(Optional time As Integer = 130) As Boolean
+ Dim [loop] = inLoop
+
+ If [loop] Then
+ counter += 1
+ Dim wr As String = String.Format(SpinText, c(counter Mod c.Length), "wtf?")
+ My.InnerQueue.AddToQueue(Sub()
+ StringSize = xConsole.Print(wr)
+ Dim left As Integer = Console.CursorLeft - StringSize
+ If left < 0 Then
+ left = 0
+ End If
+ Console.SetCursorPosition(left, Console.CursorTop)
+ End Sub)
+
+ Thread.Sleep(time)
+ Else
+ My.InnerQueue.AddToQueue(Sub()
+ Dim pos As New Point(Console.CursorLeft, Console.CursorTop)
+ Console.Write(New String(" "c, StringSize))
+ Console.SetCursorPosition(pos.X, pos.Y)
+ End Sub)
+ End If
+
+ Console.CursorVisible = Not [loop]
+
+ Return [loop]
+ End Function
+
+ Public Sub Run(Optional speed As Integer = 130)
+ Do While inLoop
+ Call Turn(speed)
+ Call Thread.Sleep(10)
+ Loop
+ End Sub
+
+ Public Sub RunTask(Optional speed As Integer = 130)
+ Call Parallel.RunTask(Sub() Call Run(speed))
+ End Sub
+ End Class
+
+#End Region
+End Namespace
diff --git a/ApplicationServices/Terminal/xConsole/xConsole.vb b/ApplicationServices/Terminal/xConsole/xConsole.vb
index cde10872..b2325429 100644
--- a/ApplicationServices/Terminal/xConsole/xConsole.vb
+++ b/ApplicationServices/Terminal/xConsole/xConsole.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a8251d66048cbc47fdba172bdaeb7f54, ApplicationServices\Terminal\xConsole\xConsole.vb"
+#Region "Microsoft.VisualBasic::5195ecc2349d77440a701e938d09fbdf, Microsoft.VisualBasic.Core\ApplicationServices\Terminal\xConsole\xConsole.vb"
' Author:
'
@@ -33,35 +33,13 @@
' Module xConsole
'
- ' Constructor: (+1 Overloads) Sub New
- '
- ' Function: CheckNewVersion, ClearInput, ClosestConsoleColor, ConvertHexStringToByteArray, getColor
- ' GetConsoleWindow, (+2 Overloads) Implode, ParseLine, Print, ReadKeys
- ' ReadLine, RetrieveLinkerTimestamp, SetWindowPos
- '
- ' Sub: __checkUpdates, CheckforUpdates, ClearInput, (+2 Overloads) CoolWrite, CoolWriteLine
- ' Credits, ListFonts, RestoreColors, SetFont, SetIcon
- ' SetWindowPos, Wait, Write, (+3 Overloads) WriteLine
- ' Class CoolWriteSettings
- '
- ' Properties: CoolWriting, CoolWritingDelay, CWRDDelay
- '
- ' Constructor: (+1 Overloads) Sub New
- '
- ' Class Comparer
- '
- ' Constructor: (+3 Overloads) Sub New
- ' Function: Find
- '
- ' Class Spinner
- '
- ' Constructor: (+2 Overloads) Sub New
- '
- ' Function: Turn
- '
- ' Sub: Break, Run, RunTask
- '
+ ' Function: ClearInput, ClosestConsoleColor, ConvertHexStringToByteArray, getColor, GetConsoleWindow
+ ' (+2 Overloads) Implode, ParseLine, Print, ReadKeys, ReadLine
+ ' SetWindowPos
'
+ ' Sub: ClearInput, (+2 Overloads) CoolWrite, CoolWriteLine, Credits, ListFonts
+ ' RestoreColors, SetFont, SetIcon, SetWindowPos, Wait
+ ' Write, (+3 Overloads) WriteLine
'
'
' /********************************************************************************/
@@ -80,71 +58,20 @@ Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
Imports System.Threading
-Imports System.Xml
+Imports Microsoft.VisualBasic.ApplicationServices.Development
Imports Microsoft.VisualBasic.Language
-Imports sys = System.Math
+Imports randf = Microsoft.VisualBasic.Math.RandomExtensions
+Imports stdNum = System.Math
-Namespace Terminal
+Namespace Terminal.xConsole
'''
''' Allows you to color and animate the console. ~ overpowered.it ~ TheTrigger - 💸
'''
''' http://www.codeproject.com/Tips/626856/xConsole-Project
- Public Module xConsole
-
-#Region "STATIC COSTRUCTOR .."
-
- Sub New()
- If System.Diagnostics.Debugger.IsAttached Then
- Try
- If CheckForUpdatesEnabled = True Then
- Call __checkUpdates()
- End If
- Catch generatedExceptionName As Exception
- Call App.LogException(generatedExceptionName)
- End Try
- End If
- End Sub
-
- Private Sub __checkUpdates()
- Dim key As Microsoft.Win32.RegistryKey =
- Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True).CreateSubKey("OverPowered")
-
- If key.GetValue("UpdateLastCheck") Is Nothing Then
- key.SetValue("UpdateLastCheck", 0)
- End If
-
- If CInt(key.GetValue("UpdateLastCheck")) < DateTime.Now.DayOfYear - 30 Then
- key.SetValue("UpdateLastCheck", DateTime.Now.DayOfYear)
- xConsole.CheckforUpdates()
- End If
-
- Call key.Close()
- End Sub
-
-#End Region
+ Public Module xConsole
#Region "COOL WRITING ✌"
-
- Public NotInheritable Class CoolWriteSettings
- Private Sub New()
- End Sub
- '''
- ''' Gradual typing the output into console
- '''
- Public Shared Property CoolWriting As Boolean = False
-
- '''
- ''' Write speed
- '''
- Public Shared Property CoolWritingDelay As Integer = 8
-
- '''
- ''' Set the delay when write a new line or dots. (Default = 200).
- '''
- Public Shared Property CWRDDelay As Integer = 280
- End Class
-
'''
''' Gradual output animation 👍👍
'''
@@ -274,7 +201,7 @@ Namespace Terminal
WriteLine(vbCr & vbTab & vbTab & "^y│" & vbTab & "^3Created by^!:" & vbTab & "^8TheTrigger^!" & vbTab & vbTab & "^y│")
WriteLine(vbCr & vbTab & vbTab & "^y│" & vbTab & "^3WebSite^!:" & vbTab & "^8overpowered.it^!" & vbTab & vbTab & "^y│")
WriteLine(vbCr & vbTab & vbTab & "^y│" & vbTab & "^3Version^!:" & vbTab & "^g{0} ^!" & vbTab & vbTab & "^y│", MyASM.Version)
- WriteLine(vbCr & vbTab & vbTab & "^y│" & vbTab & "^3Build Date^!:" & vbTab & "^y{0}" & vbTab & vbTab & "^y│^!.", RetrieveLinkerTimestamp().ToShortDateString())
+ WriteLine(vbCr & vbTab & vbTab & "^y│" & vbTab & "^3Build Date^!:" & vbTab & "^y{0}" & vbTab & vbTab & "^y│^!.", Assembly.GetCallingAssembly().RetrieveLinkerTimestamp().ToShortDateString())
WriteLine(vbCr & vbTab & vbTab & "^8╘^r■^7=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=═=^r■^8╛^!``")
WriteLine(vbCr & vbLf)
End Sub
@@ -364,7 +291,7 @@ Namespace Terminal
Dim result As New List(Of Char)()
While AscW(key = Console.ReadKey(True).KeyChar) >= 0 AndAlso
AscW(+key) <> 13
- Call result.Add(key.value)
+ Call result.Add(key.Value)
End While
Return String.Join("", result)
@@ -419,7 +346,7 @@ Namespace Terminal
Dim c As Integer = 0
Dim cList = [Enum].GetNames(GetType(ConsoleColor))
Do
- c = (RDN.[Next](0, cList.Length - 1))
+ c = (randf.seeds.Next(0, cList.Length - 1))
Loop While c = CInt(If((Type = "*"c), Console.ForegroundColor, Console.BackgroundColor))
Return CType(c, ConsoleColor)
@@ -455,7 +382,7 @@ Namespace Terminal
''' The Parser
'''
''' Input string
- Private Function Print(input As String) As Integer
+ Friend Function Print(input As String) As Integer
If String.IsNullOrWhiteSpace(input) Then
Return 0
End If
@@ -513,218 +440,6 @@ Namespace Terminal
'////////////////////////////////////////////////////////////////////////////////////////////////
#End Region
-#Region "COMPARER 💻"
-
- '''
- ''' This can compute the input then return back the most appropriate word.
- '''
- Public Class Comparer
-
- '''
- ''' This is the word to find
- '''
- Public Word As String = String.Empty
-
- '''
- ''' Descrizione
- '''
- Public Description As String = String.Empty
-
- '''
- ''' Init to 0!
- '''
- Private Points As Integer = 0
-
- '''
- ''' Initliaze a new instance
- '''
- ''' The word to find
- ''' It's should be 0
- Public Sub New(w As String, p As Integer)
- Word = w
- Points = p
- End Sub
-
- '''
- ''' Initliaze a new instance
- '''
- ''' The word to find
- Public Sub New(w As String)
- Word = w
- Points = 0
- End Sub
-
- '''
- ''' Initliaze a new instance
- '''
- ''' The word to find
- ''' Description (do nothing)
- Public Sub New(w As String, desc As String)
- Word = w
- Description = desc
- End Sub
-
- '''
- ''' Find a word from an input abbreviation (es n > name)
- '''
- '''
- Public Overloads Shared Function Find(abbr As String, ByRef Words As List(Of Comparer)) As String
- Dim Result As String = String.Empty
- Dim Best As Integer = 0
- Dim c As Integer = 0
-
- While Words.Count > c AndAlso Words(c) IsNot Nothing
- Dim word = Words(c)
-
- If abbr = word.Word Then
- Result = abbr
- Exit While
- End If
-
- For i As Integer = 0 To abbr.Length - 1
- If abbr.Length < word.Word.Length AndAlso abbr(i) = word.Word(i) Then
- word.Points += 1
- Else
- word.Points = 0
- Exit For
- End If
- Next
-
- If word.Points > Best Then
- Best = word.Points
- End If
-
-
- c += 1
- End While
- ' End while
- Dim n As Integer = 0
- For Each word As Comparer In Words
- If word.Points = Best AndAlso word.Points > 0 Then
- Result = word.Word
- If System.Threading.Interlocked.Increment(n) > 1 Then
- Result = String.Empty
- End If
- End If
- Next
-
- Return Result
- End Function
- End Class
-
- '////////////////////////////////////////////////////////////////////////////////////////////////
- '////////////////////////////////////////////////////////////////////////////////////////////////
- '////////////////////////////////////////////////////////////////////////////////////////////////
-#End Region
-
-#Region "SPINNER ⌛"
-
- '''
- ''' A list of spinners for your console ❤
- '''
- Public Class Spinner
- Private counter As Integer = 0
- Private c As Char()
-
- '''
- ''' List of available spinners (you can add new)
- '''
- Public Spinners As New List(Of Char())() From {
- New Char() {"-"c, "\"c, "|"c, "/"c},
- New Char() {"▄"c, "■"c, "▀"c, "■"c},
- New Char() {"╔"c, "╗"c, "╝"c, "╚"c},
- New Char() {"."c, "·"c, "`"c, "·"c},
- New Char() {"1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "0"c}
- }
-
- '''
- ''' looplooplooplooplooplooplooplooplooploop[...]
- '''
- Private inLoop As Boolean = True
-
- '''
- ''' The base string for spinning. {0} will display the spinner. COLOR is SUPPORTED! 🆒
- '''
- Public SpinText As String = "{0} ^gLoading^!..."
-
- '''
- ''' Initialize the spinner
- '''
- ''' Index of the spinner to use
- ''' Base string. `{0} show the spinner`
- Public Sub New(Optional i As Integer = 0, Optional txt As String = Nothing)
- If Not String.IsNullOrWhiteSpace(txt) Then
- SpinText = txt
- End If
- c = If((Spinners.Count > i), Spinners(i), Spinners(0))
- End Sub
-
- '''
- ''' Initialize a custom spinner
- '''
- ''' Set a custom spinner, no size limit.
- Public Sub New(spinner As Char())
- c = spinner
- End Sub
-
- '''
- ''' Breaks the spinner
- '''
- Public Sub Break()
- inLoop = False
- End Sub
-
- Private StringSize As Integer = 0
-
- '''
- ''' Turn the spin!
- '''
- ''' Waiting time. Default 130 ms
- ''' False if it has been stopped
- ''' while(spinner.Turn());
- Public Function Turn(Optional time As Integer = 130) As Boolean
- Dim [loop] = inLoop
-
- If [loop] Then
- counter += 1
- Dim wr As String = String.Format(SpinText, c(counter Mod c.Length), "wtf?")
- My.InnerQueue.AddToQueue(Sub()
- StringSize = Print(wr)
- Dim left As Integer = Console.CursorLeft - StringSize
- If left < 0 Then
- left = 0
- End If
- Console.SetCursorPosition(left, Console.CursorTop)
- End Sub)
-
- Thread.Sleep(time)
- Else
- My.InnerQueue.AddToQueue(Sub()
- Dim pos As New Point(Console.CursorLeft, Console.CursorTop)
- Console.Write(New String(" "c, StringSize))
- Console.SetCursorPosition(pos.X, pos.Y)
- End Sub)
- End If
-
- Console.CursorVisible = Not [loop]
-
- Return [loop]
- End Function
-
- Public Sub Run(Optional speed As Integer = 130)
- Do While inLoop
- Call Turn(speed)
- Call Thread.Sleep(10)
- Loop
- End Sub
-
- Public Sub RunTask(Optional speed As Integer = 130)
- Call Parallel.RunTask(Sub() Call Run(speed))
- End Sub
- End Class
-
-#End Region
-
#Region "SET FONT / ICON ⚠"
'''
@@ -781,12 +496,6 @@ Namespace Terminal
''' My ASM FILE
'''
Dim MyASM As AssemblyName = Assembly.GetAssembly(GetType(xConsole)).GetName()
-
- '''
- ''' Random number Generator
- '''
- Dim RDN As New Random()
-
'''
''' This value is used when restoring the colors of the console.
'''
@@ -811,21 +520,21 @@ Namespace Terminal
'''
Public ClearColorsAtEnd As Boolean = False
-
#End Region
#Region "THIRD PART ✅"
+
'''
''' Convert rgb color to ConsoleColor. From stackoverflow
'''
- Private Function ClosestConsoleColor(r As Byte, g As Byte, b As Byte) As ConsoleColor
+ Public Function ClosestConsoleColor(r As Byte, g As Byte, b As Byte) As ConsoleColor
Dim ret As ConsoleColor = 0
Dim rr As Double = r, gg As Double = g, bb As Double = b, delta As Double = Double.MaxValue
For Each cc As ConsoleColor In [Enum].GetValues(GetType(ConsoleColor))
Dim n = [Enum].GetName(GetType(ConsoleColor), cc)
Dim c = Color.FromName(If(n = "DarkYellow", "Orange", n))
- Dim t = sys.Pow(c.R - rr, 2.0) + sys.Pow(c.G - gg, 2.0) + sys.Pow(c.B - bb, 2.0)
+ Dim t = stdNum.Pow(c.R - rr, 2.0) + stdNum.Pow(c.G - gg, 2.0) + stdNum.Pow(c.B - bb, 2.0)
If t = 0.0 Then
Return cc
End If
@@ -837,36 +546,6 @@ Namespace Terminal
Return ret
End Function
-
- '''
- ''' Linker Timestamp
- '''
- Private Function RetrieveLinkerTimestamp() As DateTime
- ' from stackoverflow
- Dim filePath As String = System.Reflection.Assembly.GetCallingAssembly().Location
- Const c_PeHeaderOffset As Integer = 60
- Const c_LinkerTimestampOffset As Integer = 8
- Dim b As Byte() = New Byte(2047) {}
- Dim s As System.IO.Stream = Nothing
-
- Try
- s = New System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
- s.Read(b, 0, 2048)
- Finally
- If s IsNot Nothing Then
- s.Close()
- End If
- End Try
-
- Dim i As Integer = System.BitConverter.ToInt32(b, c_PeHeaderOffset)
- Dim secondsSince1970 As Integer = System.BitConverter.ToInt32(b, i + c_LinkerTimestampOffset)
- Dim dt As New DateTime(1970, 1, 1, 0, 0, 0)
- dt = dt.AddSeconds(secondsSince1970)
- dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours)
- Return dt
- End Function
-
-
'''
''' Convert String to byte array
'''
@@ -887,82 +566,6 @@ Namespace Terminal
Return HexAsBytes
End Function
-#End Region
-
-#Region "CHECK FOR NEW VERSION ♻"
-
- Public Sub CheckforUpdates()
- CheckForUpdatesEnabled = False
-
- ' New version
- ' BACK TO THE FUTURE!? wooooooooo
- ' up to date
- Call New Thread(Sub()
- Thread.Sleep(10)
- Dim data = CheckNewVersion()
- If Not String.IsNullOrWhiteSpace(data("url").ToString()) Then
- xConsole.WriteLine("[^mxConsole^!] ^6Current Ver: ^y{0}^! / ^6Latest: ^y{1}^!", MyASM.Version, data("ver"))
- Dim compared As Integer = MyASM.Version.CompareTo(data("ver"))
- If compared = -1 Then
- xConsole.WriteLine("[^mxConsole^!] ^gNew version available!^!")
- xConsole.WriteLine("[^mxConsole^!]^11 Download/info page: ^w{0}^!", data("url"))
- ElseIf compared = 1 Then
- xConsole.WriteLine("[^mxConsole^!] *y^r>>>^6" & vbNullChar & "BACK TO THE ^rFUTURE!^!*!")
- Else
- xConsole.WriteLine("[^mxConsole^!] ^gUp to date! :)^!")
- End If
- Else
- xConsole.WriteLine("[^mxConsole^!] ^rCan not check for updates :/^!")
- End If
-
- End Sub).Start()
- End Sub
-
- Private Function CheckNewVersion() As Dictionary(Of String, Object)
- Dim reader As XmlTextReader = Nothing
- Dim data As New Dictionary(Of String, Object)()
- data.Add("ver", New Version())
- data.Add("url", String.Empty)
-
- Try
- Dim xmlURL As String = "http://trigger.overpowered.it/xConsole/curr_version.xml"
- reader = New XmlTextReader(xmlURL)
- xConsole.WriteLine("[^mxConsole^!] ^6Checking for newer version...^!")
-
- reader.MoveToContent()
-
- Dim elementName As String = ""
-
- If (reader.NodeType = XmlNodeType.Element) AndAlso (reader.Name = "data") Then
- While reader.Read()
- If reader.NodeType = XmlNodeType.Element Then
- elementName = reader.Name
- Else
- If (reader.NodeType = XmlNodeType.Text) AndAlso (reader.HasValue) Then
- Select Case elementName
- Case "version"
- data("ver") = New Version(reader.Value)
-
-
- Case "url"
- data("url") = reader.Value
-
-
- End Select
- End If
- End If
- End While
- End If
-
- Catch generatedExceptionName As Exception
- Finally
- If reader IsNot Nothing Then
- reader.Close()
- End If
- End Try
-
- Return data
- End Function
#End Region
End Module
End Namespace
diff --git a/ApplicationServices/Tools/GMailClient.vb b/ApplicationServices/Tools/GMailClient.vb
index 04f2f31b..4ed8d6ae 100644
--- a/ApplicationServices/Tools/GMailClient.vb
+++ b/ApplicationServices/Tools/GMailClient.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::079bb93832659dcad79f67bc008fa45b, ApplicationServices\Tools\GMailClient.vb"
+#Region "Microsoft.VisualBasic::079bb93832659dcad79f67bc008fa45b, Microsoft.VisualBasic.Core\ApplicationServices\Tools\GMailClient.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/OSVersionInfo.vb b/ApplicationServices/Tools/OSVersionInfo.vb
index d570eff6..fe699541 100644
--- a/ApplicationServices/Tools/OSVersionInfo.vb
+++ b/ApplicationServices/Tools/OSVersionInfo.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3c118018626760676a3fc9601c964582, ApplicationServices\Tools\OSVersionInfo.vb"
+#Region "Microsoft.VisualBasic::3c118018626760676a3fc9601c964582, Microsoft.VisualBasic.Core\ApplicationServices\Tools\OSVersionInfo.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Plugin/Loader.vb b/ApplicationServices/Tools/Plugin/Loader.vb
new file mode 100644
index 00000000..49adb8af
--- /dev/null
+++ b/ApplicationServices/Tools/Plugin/Loader.vb
@@ -0,0 +1,81 @@
+#Region "Microsoft.VisualBasic::63c9989b77b6b1b04de901c0e5f438ac, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Plugin\Loader.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Module Loader
+ '
+ ' Function: GetPluginMethod
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Reflection
+
+Namespace ApplicationServices.Plugin
+
+ Public Module Loader
+
+ '''
+ ''' 只会查找静态方法
+ '''
+ '''
+ '''
+ '''
+ Public Function GetPluginMethod(assembly$, guid As String) As MethodInfo
+ Dim assm As Assembly = System.Reflection.Assembly.UnsafeLoadFrom(assembly.GetFullPath)
+ Dim types = assm.DefinedTypes.ToArray
+
+ For Each type As TypeInfo In types
+ Dim methods As MethodInfo() = type.GetMethods(BindingFlags.Public Or BindingFlags.Static)
+ Dim pluginMethod As MethodInfo = methods _
+ .Where(Function(m)
+ Return Not m.GetCustomAttribute(Of PluginAttribute) Is Nothing
+ End Function) _
+ .FirstOrDefault(Function(m)
+ Return m _
+ .GetCustomAttributes(Of PluginAttribute) _
+ .Any(Function(a)
+ Return a.UniqueKey.TextEquals(guid)
+ End Function)
+ End Function)
+
+ If Not pluginMethod Is Nothing Then
+ Return pluginMethod
+ End If
+ Next
+
+ Return Nothing
+ End Function
+ End Module
+End Namespace
diff --git a/ApplicationServices/Tools/Plugin/PluginAttribute.vb b/ApplicationServices/Tools/Plugin/PluginAttribute.vb
new file mode 100644
index 00000000..cd8a4b60
--- /dev/null
+++ b/ApplicationServices/Tools/Plugin/PluginAttribute.vb
@@ -0,0 +1,61 @@
+#Region "Microsoft.VisualBasic::de6cfa0c844217dfe9ea5a05146b4413, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Plugin\PluginAttribute.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class PluginAttribute
+ '
+ ' Properties: UniqueKey
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ ' Function: ToString
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Namespace ApplicationServices.Plugin
+
+
+ Public Class PluginAttribute : Inherits Attribute
+
+ Public ReadOnly Property UniqueKey As String
+
+ Sub New(guid As String)
+ UniqueKey = guid
+ End Sub
+
+ Public Overrides Function ToString() As String
+ Return UniqueKey
+ End Function
+ End Class
+End Namespace
diff --git a/ApplicationServices/Tools/Resources.vb b/ApplicationServices/Tools/Resources.vb
index 0dea1d2b..14bca4a2 100644
--- a/ApplicationServices/Tools/Resources.vb
+++ b/ApplicationServices/Tools/Resources.vb
@@ -1,48 +1,48 @@
-#Region "Microsoft.VisualBasic::342a6de1f7bc3c807986dc5a2d76b044, ApplicationServices\Tools\Resources.vb"
+#Region "Microsoft.VisualBasic::342a6de1f7bc3c807986dc5a2d76b044, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Resources.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Class ResourcesSatellite
- '
- ' Properties: FileName, MyResource, Resources
- '
- ' Constructor: (+5 Overloads) Sub New
- '
- ' Function: DirectLoadFrom, (+2 Overloads) GetObject, (+2 Overloads) GetStream, (+3 Overloads) GetString, LoadMy
- '
- ' Sub: __load, __resParser
- '
- '
- ' /********************************************************************************/
+' Class ResourcesSatellite
+'
+' Properties: FileName, MyResource, Resources
+'
+' Constructor: (+5 Overloads) Sub New
+'
+' Function: DirectLoadFrom, (+2 Overloads) GetObject, (+2 Overloads) GetStream, (+3 Overloads) GetString, LoadMy
+'
+' Sub: __load, __resParser
+'
+'
+' /********************************************************************************/
#End Region
@@ -54,6 +54,7 @@ Imports System.Resources
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Text
Namespace ApplicationServices
@@ -296,14 +297,14 @@ Namespace ApplicationServices
Sub New(dll As String)
FileName = FileIO.FileSystem.GetFileInfo(dll).FullName
- Call __resParser()
+ Call resourceAssemblyParser()
End Sub
- Private Sub __resParser()
- Call __load(Assembly.LoadFile(FileName))
+ Private Sub resourceAssemblyParser()
+ Call Assembly.LoadFile(FileName).DoCall(AddressOf doLoad)
End Sub
- Private Sub __load(assm As Assembly)
+ Private Sub doLoad(assm As Assembly)
#If NET_40 = 0 Then
Dim resource As Type = GetType(ExportAttribute)
Dim resourceMgr As Type = LinqAPI.DefaultFirst(Of Type) _
@@ -340,7 +341,7 @@ Namespace ApplicationServices
''' null
'''
Private Sub New(my As Type, assm As Assembly)
- Call __load(assm)
+ Call doLoad(assm)
End Sub
'''
diff --git a/ApplicationServices/Tools/Win32/GetLastErrorAPI.vb b/ApplicationServices/Tools/Win32/GetLastErrorAPI.vb
index 24d2d997..b84a7beb 100644
--- a/ApplicationServices/Tools/Win32/GetLastErrorAPI.vb
+++ b/ApplicationServices/Tools/Win32/GetLastErrorAPI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dd20f5bcd1d85cfbb30980c437ecdbb1, ApplicationServices\Tools\Win32\GetLastErrorAPI.vb"
+#Region "Microsoft.VisualBasic::dd20f5bcd1d85cfbb30980c437ecdbb1, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\GetLastErrorAPI.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/HardwareInfo.vb b/ApplicationServices/Tools/Win32/HardwareInfo.vb
index 9d41ac03..490bffa1 100644
--- a/ApplicationServices/Tools/Win32/HardwareInfo.vb
+++ b/ApplicationServices/Tools/Win32/HardwareInfo.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::569e94a0eee2f4b49b160f19eb302c50, ApplicationServices\Tools\Win32\HardwareInfo.vb"
+#Region "Microsoft.VisualBasic::569e94a0eee2f4b49b160f19eb302c50, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\HardwareInfo.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/PriorityClass.vb b/ApplicationServices/Tools/Win32/PriorityClass.vb
index 506828c4..a4f1ba91 100644
--- a/ApplicationServices/Tools/Win32/PriorityClass.vb
+++ b/ApplicationServices/Tools/Win32/PriorityClass.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d2fb9c656753077274a4c14b6c3ef9d6, ApplicationServices\Tools\Win32\PriorityClass.vb"
+#Region "Microsoft.VisualBasic::d2fb9c656753077274a4c14b6c3ef9d6, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\PriorityClass.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/TaskManager.vb b/ApplicationServices/Tools/Win32/TaskManager.vb
index c47a8928..27215db0 100644
--- a/ApplicationServices/Tools/Win32/TaskManager.vb
+++ b/ApplicationServices/Tools/Win32/TaskManager.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6dac82a5a59fa93194bba41263b84e65, ApplicationServices\Tools\Win32\TaskManager.vb"
+#Region "Microsoft.VisualBasic::6dac82a5a59fa93194bba41263b84e65, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\TaskManager.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/Win32API.vb b/ApplicationServices/Tools/Win32/Win32API.vb
index f89634ae..708cfc52 100644
--- a/ApplicationServices/Tools/Win32/Win32API.vb
+++ b/ApplicationServices/Tools/Win32/Win32API.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a8249973c8caf43e37764fb9bbd8e1f2, ApplicationServices\Tools\Win32\Win32API.vb"
+#Region "Microsoft.VisualBasic::a8249973c8caf43e37764fb9bbd8e1f2, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\Win32API.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/Win32File.vb b/ApplicationServices/Tools/Win32/Win32File.vb
index c6e1fbbe..5e137ddf 100644
--- a/ApplicationServices/Tools/Win32/Win32File.vb
+++ b/ApplicationServices/Tools/Win32/Win32File.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5fabdcf92fe163a9b8eff4cd5bd91ce1, ApplicationServices\Tools\Win32\Win32File.vb"
+#Region "Microsoft.VisualBasic::5fabdcf92fe163a9b8eff4cd5bd91ce1, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\Win32File.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Win32/WindowsServices.vb b/ApplicationServices/Tools/Win32/WindowsServices.vb
index 5b2d3e8e..88d98208 100644
--- a/ApplicationServices/Tools/Win32/WindowsServices.vb
+++ b/ApplicationServices/Tools/Win32/WindowsServices.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b43dd450ac1875ebd780ed6c399af063, ApplicationServices\Tools\Win32\WindowsServices.vb"
+#Region "Microsoft.VisualBasic::b43dd450ac1875ebd780ed6c399af063, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Win32\WindowsServices.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/WinForm/ChromeUIRender.vb b/ApplicationServices/Tools/WinForm/ChromeUIRender.vb
index 376a8515..25728462 100644
--- a/ApplicationServices/Tools/WinForm/ChromeUIRender.vb
+++ b/ApplicationServices/Tools/WinForm/ChromeUIRender.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a52f224044e46fb7dcafc4ecf1739dbf, ApplicationServices\Tools\WinForm\ChromeUIRender.vb"
+#Region "Microsoft.VisualBasic::a52f224044e46fb7dcafc4ecf1739dbf, Microsoft.VisualBasic.Core\ApplicationServices\Tools\WinForm\ChromeUIRender.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/WinForm/Extensions.vb b/ApplicationServices/Tools/WinForm/Extensions.vb
index bc3eb85c..6a13ed9d 100644
--- a/ApplicationServices/Tools/WinForm/Extensions.vb
+++ b/ApplicationServices/Tools/WinForm/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::29a9366500996532fe82cc1072f8675c, ApplicationServices\Tools\WinForm\Extensions.vb"
+#Region "Microsoft.VisualBasic::29a9366500996532fe82cc1072f8675c, Microsoft.VisualBasic.Core\ApplicationServices\Tools\WinForm\Extensions.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/WinForm/MockForm.vb b/ApplicationServices/Tools/WinForm/MockForm.vb
index 47ef538d..b10bf636 100644
--- a/ApplicationServices/Tools/WinForm/MockForm.vb
+++ b/ApplicationServices/Tools/WinForm/MockForm.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4bb180cca46a978033e3eabfbdcbe73e, ApplicationServices\Tools\WinForm\MockForm.vb"
+#Region "Microsoft.VisualBasic::4bb180cca46a978033e3eabfbdcbe73e, Microsoft.VisualBasic.Core\ApplicationServices\Tools\WinForm\MockForm.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/WinForm/SingleInstanceFormEntry.vb b/ApplicationServices/Tools/WinForm/SingleInstanceFormEntry.vb
index efb1f20f..04dd90c9 100644
--- a/ApplicationServices/Tools/WinForm/SingleInstanceFormEntry.vb
+++ b/ApplicationServices/Tools/WinForm/SingleInstanceFormEntry.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4e83cbcb6c757991f46eb5759cd104d0, ApplicationServices\Tools\WinForm\SingleInstanceFormEntry.vb"
+#Region "Microsoft.VisualBasic::4e83cbcb6c757991f46eb5759cd104d0, Microsoft.VisualBasic.Core\ApplicationServices\Tools\WinForm\SingleInstanceFormEntry.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/WinForm/VistaSecurity.vb b/ApplicationServices/Tools/WinForm/VistaSecurity.vb
index 3c323907..5d97b23e 100644
--- a/ApplicationServices/Tools/WinForm/VistaSecurity.vb
+++ b/ApplicationServices/Tools/WinForm/VistaSecurity.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7e3b7e103b4668634dc99b2fde490ce0, ApplicationServices\Tools\WinForm\VistaSecurity.vb"
+#Region "Microsoft.VisualBasic::7e3b7e103b4668634dc99b2fde490ce0, Microsoft.VisualBasic.Core\ApplicationServices\Tools\WinForm\VistaSecurity.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Zip/Options.vb b/ApplicationServices/Tools/Zip/Options.vb
index cc374526..a6e481cd 100644
--- a/ApplicationServices/Tools/Zip/Options.vb
+++ b/ApplicationServices/Tools/Zip/Options.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ebdf46fff322a8fbaf22989b286305b2, ApplicationServices\Tools\Zip\Options.vb"
+#Region "Microsoft.VisualBasic::ebdf46fff322a8fbaf22989b286305b2, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Zip\Options.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Zip/StreamReader.vb b/ApplicationServices/Tools/Zip/StreamReader.vb
index 70d9a90e..5a08eed1 100644
--- a/ApplicationServices/Tools/Zip/StreamReader.vb
+++ b/ApplicationServices/Tools/Zip/StreamReader.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a7764170bb2462a44609972063c01f91, ApplicationServices\Tools\Zip\StreamReader.vb"
+#Region "Microsoft.VisualBasic::0efa97547e395b217c0807504d57441f, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Zip\StreamReader.vb"
' Author:
'
@@ -33,7 +33,7 @@
' Module ZipStreamReader
'
- ' Function: LoadZipArchive
+ ' Function: GetZipSubStream, LoadZipArchive
'
'
' /********************************************************************************/
@@ -42,6 +42,7 @@
Imports System.IO
Imports System.IO.Compression
+Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ComponentModel.Collection
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Linq
@@ -50,6 +51,12 @@ Namespace ApplicationServices.Zip
Public Module ZipStreamReader
+ '''
+ ''' 将zip文件中的所有数据包一次性的返回给上层调用代码
+ '''
+ '''
+ '''
+ '''
Public Iterator Function LoadZipArchive(zipFile As String, Optional takes As IEnumerable(Of String) = Nothing) As IEnumerable(Of NamedValue(Of MemoryStream))
Dim takeIndex As Index(Of String) = takes.SafeQuery.ToArray
Dim entries As IEnumerable(Of ZipArchiveEntry)
@@ -87,5 +94,17 @@ Namespace ApplicationServices.Zip
Next
End Using
End Function
+
+ '''
+ ''' 如果这个函数返回的是空值,说明zip压缩文件中没有该目标
+ '''
+ '''
+ '''
+ '''
+ '''
+
+ Public Function GetZipSubStream(zipFile$, name$) As MemoryStream
+ Return LoadZipArchive(zipFile, {name}).FirstOrDefault
+ End Function
End Module
End Namespace
diff --git a/ApplicationServices/Tools/Zip/UnZip.vb b/ApplicationServices/Tools/Zip/UnZip.vb
index 8fc7e47e..ff9b8c48 100644
--- a/ApplicationServices/Tools/Zip/UnZip.vb
+++ b/ApplicationServices/Tools/Zip/UnZip.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c75882c2ae2d3f489422ea4953d52775, ApplicationServices\Tools\Zip\UnZip.vb"
+#Region "Microsoft.VisualBasic::c75882c2ae2d3f489422ea4953d52775, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Zip\UnZip.vb"
' Author:
'
diff --git a/ApplicationServices/Tools/Zip/ZipLib.vb b/ApplicationServices/Tools/Zip/ZipLib.vb
index 24046f9d..6ecf8a6b 100644
--- a/ApplicationServices/Tools/Zip/ZipLib.vb
+++ b/ApplicationServices/Tools/Zip/ZipLib.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d1c59b3d414151d828ccee637dc6b49d, ApplicationServices\Tools\Zip\ZipLib.vb"
+#Region "Microsoft.VisualBasic::9786fc773c8c2e947aeb3f58b211a294, Microsoft.VisualBasic.Core\ApplicationServices\Tools\Zip\ZipLib.vb"
' Author:
'
@@ -35,7 +35,7 @@
'
' Function: IsADirectoryEntry, IsSourceFolderZip
'
- ' Sub: AddToArchive, AppendZip, DirectoryArchive, FileArchive
+ ' Sub: AddToArchive, AppendZip, DeleteItems, DirectoryArchive, FileArchive
'
'
' /********************************************************************************/
@@ -47,6 +47,7 @@ Imports System.IO.Compression
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ApplicationServices
Imports Microsoft.VisualBasic.CommandLine.Reflection
+Imports Microsoft.VisualBasic.ComponentModel.Collection
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.UnixBash
Imports Microsoft.VisualBasic.Scripting.MetaData
@@ -195,10 +196,11 @@ Namespace ApplicationServices.Zip
'Identifies the mode we will be using - the default is Create
Dim mode As ZipArchiveMode = ZipArchiveMode.Create
-
'Determines if the zip file even exists
Dim archiveExists As Boolean = IO.File.Exists(archiveFullName)
+ Call archiveFullName.ParentPath.MkDIR
+
'Figures out what to do based upon our specified overwrite method
Select Case action
Case ArchiveAction.Merge
@@ -260,10 +262,20 @@ Namespace ApplicationServices.Zip
End Using
End Sub
+
+ Public Sub DeleteItems(zip As ZipArchive, itemNames As Index(Of String))
+ For Each file As ZipArchiveEntry In zip.Entries.ToArray
+ If file.Name Like itemNames Then
+ Call file.Delete()
+ End If
+ Next
+ End Sub
+
Private Sub AppendZip(zipFile As ZipArchive, files As IEnumerable(Of String), fileOverwrite As Overwrite, compression As CompressionLevel)
For Each path As String In files
- Dim fileInZip = (From f In zipFile.Entries Where f.Name = IO.Path.GetFileName(path)).FirstOrDefault()
+ Dim pathFileName = IO.Path.GetFileName(path)
+ Dim fileInZip = (From f In zipFile.Entries Where f.Name = pathFileName).FirstOrDefault()
Select Case fileOverwrite
Case Overwrite.Always
@@ -274,7 +286,7 @@ Namespace ApplicationServices.Zip
End If
'Adds the file to the archive
- zipFile.CreateEntryFromFile(path, IO.Path.GetFileName(path), compression)
+ zipFile.CreateEntryFromFile(path, pathFileName, compression)
Case Overwrite.IfNewer
diff --git a/ApplicationServices/Utils.vb b/ApplicationServices/Utils.vb
index bea55c15..a4d7fb55 100644
--- a/ApplicationServices/Utils.vb
+++ b/ApplicationServices/Utils.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5a7f6e6c12029e7e628810bd183163fe, ApplicationServices\Utils.vb"
+#Region "Microsoft.VisualBasic::5a7f6e6c12029e7e628810bd183163fe, Microsoft.VisualBasic.Core\ApplicationServices\Utils.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/ApplicationInfoUtils.vb b/ApplicationServices/VBDev/ApplicationInfoUtils.vb
index d99f107e..58922946 100644
--- a/ApplicationServices/VBDev/ApplicationInfoUtils.vb
+++ b/ApplicationServices/VBDev/ApplicationInfoUtils.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2123247c2dbf0e64ee9e4932a216e17b, ApplicationServices\VBDev\ApplicationInfoUtils.vb"
+#Region "Microsoft.VisualBasic::cf8455df341b24dd64c369f064f14400, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\ApplicationInfoUtils.vb"
' Author:
'
@@ -33,18 +33,20 @@
' Module ApplicationInfoUtils
'
- ' Function: CurrentExe, FromAssembly, FromTypeModule, GetCompanyName, GetCopyRightsDetail
- ' GetGuid, GetProductDescription, GetProductName, GetProductTitle, GetProductVersion
- ' VBCore
+ ' Function: CalculateCompileTime, CurrentExe, FromAssembly, FromTypeModule, GetCompanyName
+ ' GetCopyRightsDetail, GetGuid, GetProductDescription, GetProductName, GetProductTitle
+ ' GetProductVersion, RetrieveLinkerTimestamp, tryGetVersion, VBCore
'
'
' /********************************************************************************/
#End Region
+Imports System.IO
Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
+Imports Microsoft.VisualBasic.Linq
Namespace ApplicationServices.Development
@@ -56,6 +58,81 @@ Namespace ApplicationServices.Development
'''
Public Module ApplicationInfoUtils
+ '''
+ ''' Linker Timestamp
+ '''
+ '''
+
+ Public Function RetrieveLinkerTimestamp(assembly As Assembly) As DateTime
+ ' from stackoverflow
+ Dim filePath As String = assembly.Location
+
+ Const c_PeHeaderOffset As Integer = 60
+ Const c_LinkerTimestampOffset As Integer = 8
+
+ Dim b As Byte() = New Byte(2047) {}
+ Dim s As Stream = Nothing
+
+ Try
+ s = New FileStream(filePath, FileMode.Open, FileAccess.Read)
+ s.Read(b, 0, 2048)
+ Finally
+ If s IsNot Nothing Then
+ s.Close()
+ End If
+ End Try
+
+ Dim i As Integer = BitConverter.ToInt32(b, c_PeHeaderOffset)
+ Dim secondsSince1970 As Integer = BitConverter.ToInt32(b, i + c_LinkerTimestampOffset)
+ Dim dt As New DateTime(1970, 1, 1, 0, 0, 0)
+
+ dt = dt.AddSeconds(secondsSince1970)
+ dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours)
+
+ Return dt
+ End Function
+
+ '''
+ ''' 计算出模块文件的编译时间.(在编译项目之前应该手动修改vbproj文件中的``Deterministic``配置项的值为False来允许自动递增版本号的特性)
+ '''
+ '''
+ '''
+ '''
+ ''' ### Get Compile date and time in application
+ '''
+ ''' > https://social.msdn.microsoft.com/forums/en-US/172201e0-c47b-40a8-a5d7-0a052cb42532/get-compile-date-and-time-in-application
+ '''
+ ''' Set up your Build and MinorRevision numbers to auto-increment, pull out the date created for
+ ''' by using the Version numbers from the version on the class.
+ '''
+ ''' 1. Open ``AssemblyInfo.vb``. You'll find it under the Properties folder in your solution.
+ ''' Find the two lines that say "AssemblyVersion" and "AssemblyFileVersion" in them.
+ ''' Change them to:
+ '''
+ ''' ```vbnet
+ ''' <assembly AssemblyVersion("1.0.*")>
+ ''' <assembly AssemblyFileVersion("1.0.*")>
+ ''' ```
+ '''
+ ''' Once you Do this, Visual Studio will automatically increment the last two values In the version.
+ '''
+ ''' 2. The creation date can be found at runtime using the following algorithm:
+ '''
+ ''' ```vbnet
+ ''' Dim version = Assembly.GetExecutingAssembly().GetName().Version
+ ''' Dim creationDate = New DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.MinorRevision * 2)
+ ''' ```
+ '''
+
+ Public Function CalculateCompileTime(assm As Assembly) As Date
+ Dim version As Version = assm.GetName.Version
+ Dim builtTime = New DateTime(2000, 1, 1) _
+ .AddDays(version.Build) _
+ .AddSeconds(version.MinorRevision * 2)
+
+ Return builtTime
+ End Function
+
Public Function FromAssembly(assm As Assembly) As AssemblyInfo
Return New AssemblyInfo With {
@@ -66,10 +143,26 @@ Namespace ApplicationServices.Development
.AssemblyTitle = GetProductTitle(assm),
.AssemblyDescription = GetProductDescription(assm),
.Guid = GetGuid(assm),
- .AssemblyVersion = assm.GetVersion().ToString
+ .AssemblyVersion = assm.tryGetVersion.ToString,
+ .BuiltTime = assm.CalculateCompileTime,
+ .AssemblyFullName = assm.GetName.ToString
}
End Function
+
+ Private Function tryGetVersion(assm As Assembly) As Version
+ Try
+ Return assm.FullName _
+ .Match("Version[=]\s*\S+,") _
+ .Trim(",") _
+ .GetTagValue("="c) _
+ .Value _
+ .DoCall(Function(ver) Version.Parse(ver))
+ Catch ex As Exception
+ Return New Version
+ End Try
+ End Function
+
'''
''' 获取对当前运行时环境的描述
'''
diff --git a/ApplicationServices/VBDev/AssemblyInfo.vb b/ApplicationServices/VBDev/AssemblyInfo.vb
index 9d19c6ce..c5665281 100644
--- a/ApplicationServices/VBDev/AssemblyInfo.vb
+++ b/ApplicationServices/VBDev/AssemblyInfo.vb
@@ -1,4 +1,6 @@
-Namespace ApplicationServices.Development
+Imports System.Xml.Serialization
+
+Namespace ApplicationServices.Development
'''
''' ``My Project\AssemblyInfo.vb``
@@ -40,11 +42,22 @@
Public Property AssemblyVersion As String
Public Property AssemblyFileVersion As String
+
+ Public Property AssemblyFullName As String
+
+ '''
+ ''' The compile date and time of the assembly file.
+ '''
+ '''
+ Public Property BuiltTime As Date
+
Public Const ProjectFile As String = "My Project\AssemblyInfo.vb"
+ Sub New()
+ End Sub
+
Public Overrides Function ToString() As String
Return AssemblyTitle
End Function
-
End Class
End Namespace
\ No newline at end of file
diff --git a/ApplicationServices/VBDev/NamespaceDoc.vb b/ApplicationServices/VBDev/NamespaceDoc.vb
index c1309a0d..dae0d6da 100644
--- a/ApplicationServices/VBDev/NamespaceDoc.vb
+++ b/ApplicationServices/VBDev/NamespaceDoc.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d326f1cea6f71bb0f99f44fb78e24b3c, ApplicationServices\VBDev\NamespaceDoc.vb"
+#Region "Microsoft.VisualBasic::d326f1cea6f71bb0f99f44fb78e24b3c, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\NamespaceDoc.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/Ngen/Ngen.vb b/ApplicationServices/VBDev/Ngen/Ngen.vb
index 7fd20fcf..92210adc 100644
--- a/ApplicationServices/VBDev/Ngen/Ngen.vb
+++ b/ApplicationServices/VBDev/Ngen/Ngen.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6b310ee0f8bdbd4e9321dc03255d2197, ApplicationServices\VBDev\Ngen\Ngen.vb"
+#Region "Microsoft.VisualBasic::6b310ee0f8bdbd4e9321dc03255d2197, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Ngen\Ngen.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/Ngen/Registry.vb b/ApplicationServices/VBDev/Ngen/Registry.vb
index f6f93e44..6a9abc6b 100644
--- a/ApplicationServices/VBDev/Ngen/Registry.vb
+++ b/ApplicationServices/VBDev/Ngen/Registry.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::64625ae6702b8f28df8c85a6224313e0, ApplicationServices\VBDev\Ngen\Registry.vb"
+#Region "Microsoft.VisualBasic::64625ae6702b8f28df8c85a6224313e0, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Ngen\Registry.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/Signature/CodeSign.vb b/ApplicationServices/VBDev/Signature/CodeSign.vb
index 08f8153f..04db91be 100644
--- a/ApplicationServices/VBDev/Signature/CodeSign.vb
+++ b/ApplicationServices/VBDev/Signature/CodeSign.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::54168908a8a088c83e19233d15cbb460, ApplicationServices\VBDev\Signature\CodeSign.vb"
+#Region "Microsoft.VisualBasic::dd2889b664c11a2f7e649fa774042171, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Signature\CodeSign.vb"
' Author:
'
@@ -33,16 +33,7 @@
' Module CodeSign
'
- '
- ' Enum Languages
- '
- ' PHP, R, TypeScript, VisualBasic
- '
- '
- '
- '
- '
- ' Function: ParseHeaderRegion, SignCode
+ ' Function: ParseHeaderRegion, SignCode
'
'
' /********************************************************************************/
@@ -59,13 +50,6 @@ Namespace ApplicationServices.Development
'''
Public Module CodeSign
- Public Enum Languages
- VisualBasic
- R
- PHP
- TypeScript
- End Enum
-
Const PhpHeaderRegion$ = "#region ""PHP\\Foundation[:]{2}.*"".+?#endregion"
Const TypeScriptHeaderRegion$ = "//#region ""Microsoft.TypeScript[:]{2}.*"".+?//#endregion"
Const ROpenHeaderRegion$ = "#Region ""Microsoft.ROpen[:]{2}.*"".+?#End Region"
diff --git a/ApplicationServices/VBDev/Signature/LicenseInfo.vb b/ApplicationServices/VBDev/Signature/LicenseInfo.vb
index 62730b52..3c0edd21 100644
--- a/ApplicationServices/VBDev/Signature/LicenseInfo.vb
+++ b/ApplicationServices/VBDev/Signature/LicenseInfo.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6e209f6e9b16a9f7d548e3d0e98f638f, ApplicationServices\VBDev\Signature\LicenseInfo.vb"
+#Region "Microsoft.VisualBasic::6e209f6e9b16a9f7d548e3d0e98f638f, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Signature\LicenseInfo.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/Signature/LicenseMgr.vb b/ApplicationServices/VBDev/Signature/LicenseMgr.vb
index 1ea9ef0c..6073e81d 100644
--- a/ApplicationServices/VBDev/Signature/LicenseMgr.vb
+++ b/ApplicationServices/VBDev/Signature/LicenseMgr.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a1c14c20f2acf914567e924bd797f5b1, ApplicationServices\VBDev\Signature\LicenseMgr.vb"
+#Region "Microsoft.VisualBasic::a1c14c20f2acf914567e924bd797f5b1, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Signature\LicenseMgr.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/Signature/SupportedLanguages.vb b/ApplicationServices/VBDev/Signature/SupportedLanguages.vb
new file mode 100644
index 00000000..029110bc
--- /dev/null
+++ b/ApplicationServices/VBDev/Signature/SupportedLanguages.vb
@@ -0,0 +1,55 @@
+#Region "Microsoft.VisualBasic::fa192dc8778c6bcd4976992fe2af7087, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Signature\SupportedLanguages.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Enum Languages
+ '
+ ' PHP, R, TypeScript, VisualBasic
+ '
+ '
+ '
+ '
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Namespace ApplicationServices.Development
+
+ Public Enum Languages
+ VisualBasic
+ R
+ PHP
+ TypeScript
+ End Enum
+End Namespace
diff --git a/ApplicationServices/VBDev/Signature/VBCodeSignature.vb b/ApplicationServices/VBDev/Signature/VBCodeSignature.vb
index 2dcf4250..1903c757 100644
--- a/ApplicationServices/VBDev/Signature/VBCodeSignature.vb
+++ b/ApplicationServices/VBDev/Signature/VBCodeSignature.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1b37f25638311a163beee708b6f8bb00, ApplicationServices\VBDev\Signature\VBCodeSignature.vb"
+#Region "Microsoft.VisualBasic::1b37f25638311a163beee708b6f8bb00, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\Signature\VBCodeSignature.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Extensions/APIExtensions2.vb b/ApplicationServices/VBDev/XmlDoc/Extensions/APIExtensions2.vb
index 109e5180..c5e05a9d 100644
--- a/ApplicationServices/VBDev/XmlDoc/Extensions/APIExtensions2.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Extensions/APIExtensions2.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4825eb0012b5c1f3ebc20d5daefdc2b7, ApplicationServices\VBDev\XmlDoc\Extensions\APIExtensions2.vb"
+#Region "Microsoft.VisualBasic::4825eb0012b5c1f3ebc20d5daefdc2b7, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Extensions\APIExtensions2.vb"
' Author:
'
@@ -61,7 +61,7 @@ Namespace ApplicationServices.Development.XmlDoc.Serialization
Dim skip As Boolean = False
For Each nsName As String In excludeNamespace
- If InStr(ns.Path, nsName) = 1 Then
+ If InStr(ns.fullName, nsName) = 1 Then
skip = True
Exit For
End If
@@ -72,7 +72,7 @@ Namespace ApplicationServices.Development.XmlDoc.Serialization
End If
End If
- With ns.Path.ToLower
+ With ns.fullName.ToLower
If namespaces.ContainsKey(.ByRef) Then
namespaces(.ByRef) = namespaces(.ByRef).Add(ns, proj:=out)
Else
@@ -100,7 +100,7 @@ Namespace ApplicationServices.Development.XmlDoc.Serialization
Private Function Add(ns1 As ProjectNamespace, ns2 As ProjectNamespace, proj As Project) As ProjectNamespace
- Dim path$ = ns1.Path
+ Dim path$ = ns1.fullName
Dim types As New Dictionary(Of String, ProjectType)
For Each type As ProjectType In ns1.Types + ns2.Types.AsList
@@ -114,7 +114,7 @@ Namespace ApplicationServices.Development.XmlDoc.Serialization
Next
Return New ProjectNamespace(proj, types) With {
- .Path = path
+ .fullName = path
}
End Function
diff --git a/ApplicationServices/VBDev/XmlDoc/Extensions/VBSpecific.vb b/ApplicationServices/VBDev/XmlDoc/Extensions/VBSpecific.vb
index 9cb7b455..7a26df09 100644
--- a/ApplicationServices/VBDev/XmlDoc/Extensions/VBSpecific.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Extensions/VBSpecific.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c2762ad3badc4447e689aa531abc5415, ApplicationServices\VBDev\XmlDoc\Extensions\VBSpecific.vb"
+#Region "Microsoft.VisualBasic::c2762ad3badc4447e689aa531abc5415, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Extensions\VBSpecific.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Project.vb b/ApplicationServices/VBDev/XmlDoc/Project.vb
index 933fce3e..51c75e74 100644
--- a/ApplicationServices/VBDev/XmlDoc/Project.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Project.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::14685b62362d8b6d4e76108e94b7b3b5, ApplicationServices\VBDev\XmlDoc\Project.vb"
+#Region "Microsoft.VisualBasic::14685b62362d8b6d4e76108e94b7b3b5, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Project.vb"
' Author:
'
@@ -64,7 +64,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Dim _namespaces As Dictionary(Of String, ProjectNamespace)
- Public Property Name() As String
+ Public Property Name As String
Public ReadOnly Property Namespaces() As IEnumerable(Of ProjectNamespace)
@@ -95,12 +95,32 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return Nothing
End Function
- Public Function EnsureNamespace(namespacePath As String) As ProjectNamespace
+ '''
+ ''' 当目标对象没有xml注释的时候,这个函数返回的是空值
+ '''
+ '''
+ '''
+ Public Overloads Function [GetType](fullName As String) As ProjectType
+ Dim tokens = fullName.Split("."c)
+ Dim typeName As String = tokens.Last
+ Dim namespaceRef As String = tokens.Take(tokens.Length - 1).JoinBy(".")
+ Dim namespaceDoc As ProjectNamespace = GetNamespace(namespaceRef)
+
+ ' if no xml comment docs,
+ ' then namespaceDoc object will be nothing
+ If namespaceDoc Is Nothing Then
+ Return Nothing
+ Else
+ Return namespaceDoc.GetType(typeName)
+ End If
+ End Function
+
+ Friend Function EnsureNamespace(namespacePath As String) As ProjectNamespace
Dim pn As ProjectNamespace = GetNamespace(namespacePath)
If pn Is Nothing Then
pn = New ProjectNamespace(Me) With {
- .Path = namespacePath
+ .fullName = namespacePath
}
_namespaces.Add(namespacePath.ToLower(), pn)
End If
diff --git a/ApplicationServices/VBDev/XmlDoc/ProjectMember.vb b/ApplicationServices/VBDev/XmlDoc/ProjectMember.vb
index e1d29e3c..07b1020f 100644
--- a/ApplicationServices/VBDev/XmlDoc/ProjectMember.vb
+++ b/ApplicationServices/VBDev/XmlDoc/ProjectMember.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::97c5b5808964bc177799fc805f9eb683, ApplicationServices\VBDev\XmlDoc\ProjectMember.vb"
+#Region "Microsoft.VisualBasic::97c5b5808964bc177799fc805f9eb683, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectMember.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/ProjectNamespace.vb b/ApplicationServices/VBDev/XmlDoc/ProjectNamespace.vb
index 6797c52d..7f05b217 100644
--- a/ApplicationServices/VBDev/XmlDoc/ProjectNamespace.vb
+++ b/ApplicationServices/VBDev/XmlDoc/ProjectNamespace.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::aa742310460cc18ff1701b360d567bc7, ApplicationServices\VBDev\XmlDoc\ProjectNamespace.vb"
+#Region "Microsoft.VisualBasic::aa742310460cc18ff1701b360d567bc7, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectNamespace.vb"
' Author:
'
@@ -58,7 +58,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Protected project As Project
Protected _types As Dictionary(Of String, ProjectType)
- Public Property Path() As String
+ Public Property fullName As String
Public ReadOnly Property Types() As IEnumerable(Of ProjectType)
@@ -82,7 +82,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
End Sub
Public Overrides Function ToString() As String
- Return Path
+ Return fullName
End Function
Public Overloads Function [GetType](typeName As String) As ProjectType
@@ -93,7 +93,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return Nothing
End Function
- Public Function EnsureType(typeName As String) As ProjectType
+ Friend Function EnsureType(typeName As String) As ProjectType
Dim pt As ProjectType = Me.[GetType](typeName)
If pt Is Nothing Then
diff --git a/ApplicationServices/VBDev/XmlDoc/ProjectSpace.vb b/ApplicationServices/VBDev/XmlDoc/ProjectSpace.vb
index 6eccd146..60c80991 100644
--- a/ApplicationServices/VBDev/XmlDoc/ProjectSpace.vb
+++ b/ApplicationServices/VBDev/XmlDoc/ProjectSpace.vb
@@ -1,46 +1,46 @@
-#Region "Microsoft.VisualBasic::72583ecbe0ad701ec1f8fbc8c7be7a1c, ApplicationServices\VBDev\XmlDoc\ProjectSpace.vb"
+#Region "Microsoft.VisualBasic::72583ecbe0ad701ec1f8fbc8c7be7a1c, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectSpace.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Class ProjectSpace
- '
- ' Constructor: (+1 Overloads) Sub New
- '
- ' Function: EnsureProject, GetEnumerator, GetProject, IEnumerable_GetEnumerator, ToString
- '
- ' Sub: ImportFromXmlDocFile, ImportFromXmlDocFolder, LoadFile
- '
- '
- ' /********************************************************************************/
+' Class ProjectSpace
+'
+' Constructor: (+1 Overloads) Sub New
+'
+' Function: EnsureProject, GetEnumerator, GetProject, IEnumerable_GetEnumerator, ToString
+'
+' Sub: ImportFromXmlDocFile, ImportFromXmlDocFolder, LoadFile
+'
+'
+' /********************************************************************************/
#End Region
@@ -49,6 +49,7 @@
Imports System.IO
+Imports System.Runtime.CompilerServices
Imports System.Xml
Imports Microsoft.VisualBasic.ApplicationServices.Development.XmlDoc.Serialization
Imports Microsoft.VisualBasic.FileIO.FileSystem
@@ -134,8 +135,26 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
End If
End Sub
+
Private Sub LoadFile(fi As FileInfo)
- Using fs As New FileStream(fi.FullName, FileMode.Open)
+ Call CreateDocProject(fi, excludeVBSpecific, AddressOf EnsureProject)
+ End Sub
+
+ Public Shared Function CreateDocProject(xmlfile As [Variant](Of String, FileInfo),
+ Optional excludeVBSpecific As Boolean = True,
+ Optional projActivator As Func(Of String, Project) = Nothing) As Project
+
+ If xmlfile Like GetType(FileInfo) Then
+ xmlfile = xmlfile.TryCast(Of FileInfo).FullName
+ Else
+ xmlfile = xmlfile.TryCast(Of String).GetFullPath
+ End If
+
+ If projActivator Is Nothing Then
+ projActivator = Function(name) New Project(name)
+ End If
+
+ Using fs As New FileStream(xmlfile, FileMode.Open)
Dim streamWriter As New StreamReader(fs)
Dim xml$ = streamWriter.ReadToEnd.TrimAssemblyDoc()
Dim s As New StringReader(xml)
@@ -148,15 +167,21 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Dim nameNode As XmlNode = xd _
.DocumentElement _
.SelectSingleNode("assembly/name")
+ Dim proj As Project
If nameNode IsNot Nothing Then
xml = nameNode.InnerText
- Call EnsureProject(xml) _
- .ProcessXmlDoc(xd, excludeVBSpecific)
+ proj = projActivator(xml)
+
+ Call proj.ProcessXmlDoc(xd, excludeVBSpecific)
+
+ Return proj
+ Else
+ Return Nothing
End If
End Using
End Using
- End Sub
+ End Function
Public Iterator Function GetEnumerator() As IEnumerator(Of Project) Implements IEnumerable(Of Project).GetEnumerator
For Each proj As Project In projects
diff --git a/ApplicationServices/VBDev/XmlDoc/ProjectType.vb b/ApplicationServices/VBDev/XmlDoc/ProjectType.vb
index b42c3007..7a41967d 100644
--- a/ApplicationServices/VBDev/XmlDoc/ProjectType.vb
+++ b/ApplicationServices/VBDev/XmlDoc/ProjectType.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c252ce7e2743d86c472f5af9a6b501e1, ApplicationServices\VBDev\XmlDoc\ProjectType.vb"
+#Region "Microsoft.VisualBasic::c252ce7e2743d86c472f5af9a6b501e1, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectType.vb"
' Author:
'
@@ -54,8 +54,8 @@
Imports System.Runtime.CompilerServices
Imports System.Xml
Imports Microsoft.VisualBasic.ApplicationServices.Development.XmlDoc.Serialization
-Imports Microsoft.VisualBasic.Text
Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Text
Namespace ApplicationServices.Development.XmlDoc.Assembly
@@ -81,6 +81,10 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
'''
Protected Friend methods As Dictionary(Of String, List(Of ProjectMember))
+ '''
+ ''' The namespace container of this type
+ '''
+ '''
Public ReadOnly Property [Namespace]() As ProjectNamespace
Get
@@ -134,7 +138,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return getInternal(methods, methodName.ToLower)
End Function
- Public Function EnsureMethod(methodName As String) As ProjectMember
+ Friend Function EnsureMethod(methodName As String) As ProjectMember
Dim pmlist As List(Of ProjectMember) = Me.GetMethods(methodName)
Dim pm As New ProjectMember(Me) With {
.Name = methodName
@@ -160,7 +164,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return getInternal(properties, propertyName.ToLower)
End Function
- Public Function EnsureProperty(propertyName As String) As ProjectMember
+ Friend Function EnsureProperty(propertyName As String) As ProjectMember
Dim pmlist As List(Of ProjectMember) = Me.GetProperties(propertyName)
Dim pm As New ProjectMember(Me) With {
.Name = propertyName
@@ -179,7 +183,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return Nothing
End Function
- Public Function EnsureField(fieldName As String) As ProjectMember
+ Friend Function EnsureField(fieldName As String) As ProjectMember
Dim pm As ProjectMember = Me.GetField(fieldName)
If pm Is Nothing Then
@@ -201,7 +205,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return Nothing
End Function
- Public Function EnsureEvent(eventName As String) As ProjectMember
+ Friend Function EnsureEvent(eventName As String) As ProjectMember
Dim pm As ProjectMember = Me.GetField(eventName)
If pm Is Nothing Then
@@ -215,7 +219,7 @@ Namespace ApplicationServices.Development.XmlDoc.Assembly
Return pm
End Function
- Public Sub LoadFromNode(xn As XmlNode)
+ Friend Sub LoadFromNode(xn As XmlNode)
Dim summaryNode As XmlNode = xn.SelectSingleNode("summary")
If summaryNode IsNot Nothing Then
diff --git a/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions.vb b/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions.vb
index 8b3560d5..aa416269 100644
--- a/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7298a9a30a05a1c83524147a5d214f5c, ApplicationServices\VBDev\XmlDoc\Serialization\APIExtensions.vb"
+#Region "Microsoft.VisualBasic::7298a9a30a05a1c83524147a5d214f5c, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\APIExtensions.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions2.vb b/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions2.vb
index 4ff3c6cf..5eea4368 100644
--- a/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions2.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Serialization/APIExtensions2.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c9e138543849a97e4d555996abd710cf, ApplicationServices\VBDev\XmlDoc\Serialization\APIExtensions2.vb"
+#Region "Microsoft.VisualBasic::c9e138543849a97e4d555996abd710cf, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\APIExtensions2.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Doc.vb b/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Doc.vb
index 34619866..608ec844 100644
--- a/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Doc.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Doc.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5d3d1d04a1aa244b9b8318273a109441, ApplicationServices\VBDev\XmlDoc\Serialization\Models\Doc.vb"
+#Region "Microsoft.VisualBasic::5d3d1d04a1aa244b9b8318273a109441, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\Models\Doc.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Member.vb b/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Member.vb
index 8c2e1890..d9a98503 100644
--- a/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Member.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Serialization/Models/Member.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7349ed8a280f9c2257cbc7d637d3d2dc, ApplicationServices\VBDev\XmlDoc\Serialization\Models\Member.vb"
+#Region "Microsoft.VisualBasic::7349ed8a280f9c2257cbc7d637d3d2dc, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\Models\Member.vb"
' Author:
'
diff --git a/ApplicationServices/VBDev/XmlDoc/Serialization/NamespaceDoc.vb b/ApplicationServices/VBDev/XmlDoc/Serialization/NamespaceDoc.vb
index 13bedcde..950ed9d7 100644
--- a/ApplicationServices/VBDev/XmlDoc/Serialization/NamespaceDoc.vb
+++ b/ApplicationServices/VBDev/XmlDoc/Serialization/NamespaceDoc.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5e5c81b520ee5bc426622c3be0d8268e, ApplicationServices\VBDev\XmlDoc\Serialization\NamespaceDoc.vb"
+#Region "Microsoft.VisualBasic::5e5c81b520ee5bc426622c3be0d8268e, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\NamespaceDoc.vb"
' Author:
'
@@ -69,7 +69,7 @@ Namespace ApplicationServices.Development.XmlDoc.Serialization
.Select(Function(ns) ns.Types) _
.IteratesALL _
.Where(AddressOf IsNamespaceDoc) _
- .GroupBy(Function(doc) doc.Namespace.Path) _
+ .GroupBy(Function(doc) doc.Namespace.fullName) _
.ToDictionary(Function(ns) ns.Key,
Function(nsGroup)
Return nsGroup _
diff --git a/CommandLine/CLI/IIORedirectAbstract.vb b/CommandLine/CLI/IIORedirectAbstract.vb
index 11f0cd87..41eddb19 100644
--- a/CommandLine/CLI/IIORedirectAbstract.vb
+++ b/CommandLine/CLI/IIORedirectAbstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::243559093d758b5dce647e9e05713362, CommandLine\CLI\IIORedirectAbstract.vb"
+#Region "Microsoft.VisualBasic::243559093d758b5dce647e9e05713362, Microsoft.VisualBasic.Core\CommandLine\CLI\IIORedirectAbstract.vb"
' Author:
'
diff --git a/CommandLine/CLI/IORedirect.vb b/CommandLine/CLI/IORedirect.vb
index 6c278785..fcc07f6b 100644
--- a/CommandLine/CLI/IORedirect.vb
+++ b/CommandLine/CLI/IORedirect.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a3471837b8895154ee1106f6135a2fed, CommandLine\CLI\IORedirect.vb"
+#Region "Microsoft.VisualBasic::a3471837b8895154ee1106f6135a2fed, Microsoft.VisualBasic.Core\CommandLine\CLI\IORedirect.vb"
' Author:
'
diff --git a/CommandLine/CLI/IORedirectFile.vb b/CommandLine/CLI/IORedirectFile.vb
index 2f0d60dc..320b6dda 100644
--- a/CommandLine/CLI/IORedirectFile.vb
+++ b/CommandLine/CLI/IORedirectFile.vb
@@ -1,48 +1,48 @@
-#Region "Microsoft.VisualBasic::c2622e56797782ff7ecee40e1c895766, CommandLine\CLI\IORedirectFile.vb"
+#Region "Microsoft.VisualBasic::c2622e56797782ff7ecee40e1c895766, Microsoft.VisualBasic.Core\CommandLine\CLI\IORedirectFile.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Class IORedirectFile
- '
- ' Properties: Bin, CLIArguments, StandardOutput
- '
- ' Constructor: (+1 Overloads) Sub New
- '
- ' Function: CopyRedirect, Run, (+2 Overloads) Start, ToString, writeScript
- '
- ' Sub: __processExitHandle, (+2 Overloads) Dispose, Start
- '
- '
- ' /********************************************************************************/
+' Class IORedirectFile
+'
+' Properties: Bin, CLIArguments, StandardOutput
+'
+' Constructor: (+1 Overloads) Sub New
+'
+' Function: CopyRedirect, Run, (+2 Overloads) Start, ToString, writeScript
+'
+' Sub: __processExitHandle, (+2 Overloads) Dispose, Start
+'
+'
+' /********************************************************************************/
#End Region
@@ -50,6 +50,7 @@ Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ApplicationServices
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Parallel
+Imports Microsoft.VisualBasic.Text
Imports ValueTuple = System.Collections.Generic.KeyValuePair(Of String, String)
Namespace CommandLine
@@ -141,7 +142,8 @@ Namespace CommandLine
Optional FolkNew As Boolean = False,
Optional stdRedirect$ = "",
Optional stdin$ = Nothing,
- Optional debug As Boolean = True)
+ Optional debug As Boolean = True,
+ Optional isShellCommand As Boolean = False)
If Not String.IsNullOrEmpty(stdRedirect) Then
_TempRedirect = stdRedirect.CLIPath
@@ -150,7 +152,7 @@ Namespace CommandLine
' 没有小数点,说明可能只是一个命令,而不是具体的可执行程序文件名
If InStr(file, ".") = 0 Then
' do nothing
- Else
+ ElseIf Not isShellCommand Then
' 对于具体的程序文件的调用,在这里获取其完整路径
Try
file = FileIO.FileSystem.GetFileInfo(file).FullName
@@ -171,13 +173,17 @@ Namespace CommandLine
Call "".SaveTo(_TempRedirect)
If App.IsMicrosoftPlatform Then
- shellScript = ScriptingExtensions.Cmd(file, argv, environment, FolkNew, stdin)
+ shellScript = ScriptingExtensions.Cmd(file, argv, environment, FolkNew, stdin, isShellCommand)
Else
- shellScript = ScriptingExtensions.Bash(file, argv, environment, FolkNew, stdin)
+ shellScript = ScriptingExtensions.Bash(file, argv, environment, FolkNew, stdin, isShellCommand)
End If
If debug Then
- Call $"""{file.ToFileURL}"" {argv}".__DEBUG_ECHO
+ If isShellCommand Then
+ Call $"""{file}"" {argv}".__DEBUG_ECHO
+ Else
+ Call $"""{file.ToFileURL}"" {argv}".__DEBUG_ECHO
+ End If
End If
End Sub
@@ -234,7 +240,7 @@ Namespace CommandLine
Private Function writeScript() As String
Dim ext$ = If(App.IsMicrosoftPlatform, ".bat", ".sh")
Dim path$ = App.GetAppSysTempFile(ext, App.PID)
- Call shellScript.SaveTo(path)
+ Call shellScript.SaveTo(path, Encodings.UTF8WithoutBOM.CodePage)
Return path
End Function
diff --git a/CommandLine/CLI/ProcExtensions.vb b/CommandLine/CLI/ProcExtensions.vb
index 7817130c..379d03f4 100644
--- a/CommandLine/CLI/ProcExtensions.vb
+++ b/CommandLine/CLI/ProcExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0c5d4db15b39642422e000842d5f6b9b, CommandLine\CLI\ProcExtensions.vb"
+#Region "Microsoft.VisualBasic::0c5d4db15b39642422e000842d5f6b9b, Microsoft.VisualBasic.Core\CommandLine\CLI\ProcExtensions.vb"
' Author:
'
diff --git a/CommandLine/CLI/Scripting.vb b/CommandLine/CLI/Scripting.vb
index 6d72c48c..b1d66e12 100644
--- a/CommandLine/CLI/Scripting.vb
+++ b/CommandLine/CLI/Scripting.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::43f3eea17d8ad201c092583195b3e1ed, CommandLine\CLI\Scripting.vb"
+#Region "Microsoft.VisualBasic::43f3eea17d8ad201c092583195b3e1ed, Microsoft.VisualBasic.Core\CommandLine\CLI\Scripting.vb"
' Author:
'
@@ -51,7 +51,7 @@ Namespace CommandLine
Module ScriptingExtensions
- Public Function Cmd(program$, argv$, environment As IEnumerable(Of ValueTuple), folkNew As Boolean, stdin$) As String
+ Public Function Cmd(program$, argv$, environment As IEnumerable(Of ValueTuple), folkNew As Boolean, stdin$, isShellCommand As Boolean) As String
Dim bat As New StringBuilder(1024)
' 切换工作目录至当前的进程所处的文件夹
@@ -82,7 +82,7 @@ Namespace CommandLine
' 生成IO重定向的命令行
' https://stackoverflow.com/questions/3680977/can-a-batch-file-capture-the-exit-codes-of-the-commands-it-is-invoking
Call bat.AppendLine("set errorlevel=")
- Call bat.start(program, argv, stdin)
+ Call bat.start(program, argv, stdin, isShellCommand)
Call bat.AppendLine("exit /b %errorlevel%")
End If
@@ -90,15 +90,23 @@ Namespace CommandLine
End Function
- Private Sub start(script As StringBuilder, program$, argv$, stdin$)
+ Private Sub start(script As StringBuilder, program$, argv$, stdin$, isShellCommand As Boolean)
If stdin.StringEmpty Then
- Call script.AppendLine($"""{program}"" {argv}")
+ If isShellCommand Then
+ Call script.AppendLine($"{program} {argv}")
+ Else
+ Call script.AppendLine($"""{program}"" {argv}")
+ End If
Else
- Call script.AppendLine($"echo {stdin} | ""{program}"" {argv}")
+ If isShellCommand Then
+ Call script.AppendLine($"echo {stdin} | {program} {argv}")
+ Else
+ Call script.AppendLine($"echo {stdin} | ""{program}"" {argv}")
+ End If
End If
End Sub
- Public Function Bash(program$, argv$, environment As IEnumerable(Of ValueTuple), folkNew As Boolean, stdin$) As String
+ Public Function Bash(program$, argv$, environment As IEnumerable(Of ValueTuple), folkNew As Boolean, stdin$, isShellCommand As Boolean) As String
Dim shell As New StringBuilder("#!/bin/bash")
Call shell.AppendLine()
@@ -114,7 +122,7 @@ Namespace CommandLine
End If
Call shell.AppendLine($"cd {App.CurrentDirectory.CLIPath}")
- Call shell.start(program, argv, stdin)
+ Call shell.start(program, argv, stdin, isShellCommand)
Return shell.ToString
End Function
diff --git a/CommandLine/CLIMapper.vb b/CommandLine/CLIMapper.vb
index 6b41a5be..f8e44b92 100644
--- a/CommandLine/CLIMapper.vb
+++ b/CommandLine/CLIMapper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d0bd8ff98c817e8b3ab04032760e6d74, CommandLine\CLIMapper.vb"
+#Region "Microsoft.VisualBasic::d0bd8ff98c817e8b3ab04032760e6d74, Microsoft.VisualBasic.Core\CommandLine\CLIMapper.vb"
' Author:
'
diff --git a/CommandLine/CLITools.vb b/CommandLine/CLITools.vb
index 2c31a46e..1919858e 100644
--- a/CommandLine/CLITools.vb
+++ b/CommandLine/CLITools.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::50dde47202ca31fb123169568f81031d, CommandLine\CLITools.vb"
+#Region "Microsoft.VisualBasic::2e374be0f7a6492d316353282f4ea409, Microsoft.VisualBasic.Core\CommandLine\CLITools.vb"
' Author:
'
@@ -34,10 +34,11 @@
' Module CLITools
'
' Function: __checkKeyDuplicated, Args, CreateObject, CreateParameterValues, Equals
- ' GetLogicalFlags, GetTokens, IsPossibleLogicFlag, Join, makesureQuot
- ' Print, ShellExec, SingleValueOrStdIn, TrimParamPrefix, (+3 Overloads) TryParse
+ ' GetFileList, GetLogicalFlags, GetTokens, IsPossibleLogicFlag, Join
+ ' makesureQuot, Print, ShellExec, SingleValueOrStdIn, TrimParamPrefix
+ ' (+3 Overloads) TryParse
'
- ' Sub: tupleParser
+ ' Sub: AppSummary, tupleParser
'
'
' /********************************************************************************/
@@ -48,7 +49,9 @@ Imports System.IO
Imports System.Runtime.CompilerServices
Imports System.Text
Imports System.Text.RegularExpressions
+Imports Microsoft.VisualBasic.ApplicationServices.Development
Imports Microsoft.VisualBasic.ApplicationServices.Terminal
+Imports Microsoft.VisualBasic.CommandLine.ManView
Imports Microsoft.VisualBasic.CommandLine.Reflection
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Language
@@ -70,6 +73,33 @@ Namespace CommandLine
Revision:=52)>
Public Module CLITools
+ '''
+ ''' 在命令行之中使用逗号作为分隔符分隔多个文件
+ '''
+ '''
+ '''
+ Public Function GetFileList(input As String) As IEnumerable(Of String)
+ If input.FileExists Then
+ Return {input}
+ Else
+ Return input.Split(","c)
+ End If
+ End Function
+
+ '''
+ '''
+ '''
+ '''
+ ''' 命令行的使用功能描述信息文本
+ ''' 命令行的使用语法
+ '''
+ '''
+
+
+ Public Sub AppSummary(assem As AssemblyInfo, description$, SYNOPSIS$, write As TextWriter)
+ Call SDKManual.AppSummary(assem, description, SYNOPSIS, write)
+ End Sub
+
Public Function ShellExec(cli As IIORedirectAbstract) As String
Call cli.Run()
@@ -106,6 +136,7 @@ Namespace CommandLine
'''
Public Function CreateParameterValues(tokens$(), includeLogicals As Boolean, Optional note$ = Nothing) As List(Of NamedValue(Of String))
Dim list As New List(Of NamedValue(Of String))
+ Dim key As String
If tokens.IsNullOrEmpty Then
Return list
@@ -138,7 +169,7 @@ Namespace CommandLine
Dim s As String = tokens([next])
' 当前的这个元素是开关,下一个也是开关开头,则本元素肯定是一个开关
- If IsPossibleLogicFlag(s) Then
+ If tokens(i).ToLower <> "/@set" AndAlso IsPossibleLogicFlag(s) Then
If includeLogicals Then
list += New NamedValue(Of String)(tokens(i), True, note)
End If
@@ -146,7 +177,7 @@ Namespace CommandLine
Continue For
Else
' 下一个元素不是开关,则当前元素为一个参数名,则跳过下一个元素
- Dim key As String = tokens(i).ToLower
+ key = tokens(i).ToLower
list += New NamedValue(Of String)(key, s, note)
i += 1
@@ -225,6 +256,8 @@ Namespace CommandLine
If tokens.Length = 0 Then
Return New CommandLine
+ Else
+ tokens = tokens.fixWindowsNetworkDirectory.ToArray
End If
Dim bools$() = tokens _
@@ -247,9 +280,9 @@ Namespace CommandLine
End If
If tokens.Length > 1 Then
- cli.__arguments = tokens.Skip(1).ToArray.CreateParameterValues(False)
+ cli.arguments = tokens.Skip(1).ToArray.CreateParameterValues(False)
- Dim Dk As String() = __checkKeyDuplicated(cli.__arguments)
+ Dim Dk As String() = __checkKeyDuplicated(cli.arguments)
If Not duplicatedAllows AndAlso Not Dk.IsNullOrEmpty Then
Dim Key$ = String.Join(", ", Dk)
@@ -529,7 +562,7 @@ Namespace CommandLine
Return New CommandLine With {
.Name = name,
- .__arguments = parameters,
+ .arguments = parameters,
.Tokens = tokens.Join(bFlags).ToArray,
.BoolFlags = bFlags.SafeQuery.ToArray
}
@@ -572,7 +605,7 @@ Namespace CommandLine
End If
Next
- For Each arg As NamedValue(Of String) In args1.__arguments
+ For Each arg As NamedValue(Of String) In args1.arguments
Dim value2 As String = args2(arg.Name)
If Not String.Equals(value2, arg.Value, StringComparison.OrdinalIgnoreCase) Then
diff --git a/CommandLine/CliResCommon.vb b/CommandLine/CliResCommon.vb
index bca71d3a..e41966ef 100644
--- a/CommandLine/CliResCommon.vb
+++ b/CommandLine/CliResCommon.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4997b427ff7828d26117155c6bab2511, CommandLine\CliResCommon.vb"
+#Region "Microsoft.VisualBasic::4997b427ff7828d26117155c6bab2511, Microsoft.VisualBasic.Core\CommandLine\CliResCommon.vb"
' Author:
'
diff --git a/CommandLine/CommandLine.vb b/CommandLine/CommandLine.vb
index f502666f..823df571 100644
--- a/CommandLine/CommandLine.vb
+++ b/CommandLine/CommandLine.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d60e9df563cbc7d7961cac24ae628634, CommandLine\CommandLine.vb"
+#Region "Microsoft.VisualBasic::1e266ef3707ea88ae89c7bfbc8d789b4, Microsoft.VisualBasic.Core\CommandLine\CommandLine.vb"
' Author:
'
@@ -88,7 +88,7 @@ Namespace CommandLine
Implements ICollection(Of NamedValue(Of String))
Implements INamedValue
- Friend __arguments As New List(Of NamedValue(Of String))
+ Friend arguments As New List(Of NamedValue(Of String))
'''
''' 原始的命令行字符串
'''
@@ -129,7 +129,7 @@ Namespace CommandLine
Public ReadOnly Property ParameterList As NamedValue(Of String)()
Get
- Return __arguments.ToArray
+ Return arguments.ToArray
End Get
End Property
@@ -140,7 +140,7 @@ Namespace CommandLine
Public ReadOnly Property Keys As String()
Get
- Return __arguments.Select(Function(v) v.Name).ToArray
+ Return arguments.Select(Function(v) v.Name).ToArray
End Get
End Property
@@ -212,13 +212,14 @@ Namespace CommandLine
'''
Default Public ReadOnly Property Item(paramName As String) As DefaultString
Get
- Dim LQuery As NamedValue(Of String) =
- __arguments _
- .Where(Function(x)
- Return String.Equals(x.Name, paramName, StringComparison.OrdinalIgnoreCase) OrElse
- String.Equals(x.Name.Trim("\", "/", "-"), paramName, StringComparison.OrdinalIgnoreCase)
- End Function) _
- .FirstOrDefault
+ Dim LQuery As NamedValue(Of String) = arguments _
+ .Where(Function(a)
+ Return a.Name.TextEquals(paramName) OrElse
+ a.Name.DoCall(AddressOf TrimNamePrefix) _
+ .TextEquals(paramName)
+ End Function) _
+ .FirstOrDefault
+
' 是值类型,不会出现空引用的情况
Dim value As String = LQuery.Value
@@ -241,14 +242,14 @@ Namespace CommandLine
' 对于Windows文件路径而言, 不推荐转义
' 因为Windows的文件路径分隔符为\,很容易引起误解,例如C:\tsv会被误转义为C:sv而导致错误
' 所以在这里关闭escape参数选项
- value = value.Interpolate(__envir, escape:=False)
+ value = value.Interpolate(environment, escape:=False)
End If
Return New DefaultString(value)
End Get
End Property
- ReadOnly __envir As Func(Of String, String) = AddressOf App.GetVariable
+ ReadOnly environment As Func(Of String, String) = AddressOf App.GetVariable
Public Property SingleValue As String
@@ -278,6 +279,11 @@ Namespace CommandLine
Return cliCommandArgvs
End Function
+
+ Public Shared Function TrimNamePrefix(argName As String) As String
+ Return argName.Trim("\", "/", "-")
+ End Function
+
'''
''' Get specific argument value as full directory path.
'''
@@ -313,15 +319,15 @@ Namespace CommandLine
Call sb.AppendLine("---------------------------------------------------------")
Call sb.AppendLine()
- If __arguments.Count = 0 Then
+ If arguments.Count = 0 Then
Call sb.AppendLine("No parameter was define in this commandline.")
Return sb.ToString
End If
Dim MaxSwitchName As Integer = (From item As NamedValue(Of String)
- In __arguments
+ In arguments
Select Len(item.Name)).Max
- For Each sw As NamedValue(Of String) In __arguments
+ For Each sw As NamedValue(Of String) In arguments
Call sb.AppendLine($" {sw.Name} {New String(" "c, MaxSwitchName - Len(sw.Name))}= ""{sw.Value}"";")
Next
@@ -394,7 +400,7 @@ Namespace CommandLine
Dim LQuery = LinqAPI.DefaultFirst(Of Integer) _
_
() <= From para As NamedValue(Of String)
- In Me.__arguments ' 名称都是没有处理过的
+ In Me.arguments ' 名称都是没有处理过的
Where String.Equals(namer, para.Name, StringComparison.OrdinalIgnoreCase)
Select 100
@@ -501,13 +507,13 @@ Namespace CommandLine
'''
'''
'''
- Public Function OpenStreamOutput(param$, Optional encoding As Encodings = Encodings.UTF8) As StreamWriter
+ Public Function OpenStreamOutput(param$, Optional encoding As Encodings = Encodings.UTF8, Optional size& = 512 * 1024 * 1024) As StreamWriter
Dim path$ = Me(param)
Dim type As FileTypes = StreamExtensions.FileType(path)
Select Case type
Case FileTypes.MemoryFile, FileTypes.PipelineFile
- Return New StreamWriter(StreamExtensions.OpenForWrite(path))
+ Return New StreamWriter(StreamExtensions.OpenForWrite(path, size))
Case Else
If path.StringEmpty Then
Return New StreamWriter(Console.OpenStandardOutput, encoding.CodePage)
@@ -685,9 +691,9 @@ Namespace CommandLine
Dim i% = LinqAPI.DefaultFirst(Of Integer)(-1) _
_
<= From entry As NamedValue(Of String)
- In Me.__arguments
+ In Me.arguments
Where String.Equals(parameter, entry.Name, StringComparison.OrdinalIgnoreCase)
- Select __arguments.IndexOf(entry)
+ Select arguments.IndexOf(entry)
Return i
End Function
@@ -763,7 +769,7 @@ Namespace CommandLine
'''
'''
- Public Function OpenHandle(name$, Optional default$ = "", Optional encoding As Encodings = Encodings.UTF8) As VBInteger
+ Public Function OpenHandle(name$, Optional default$ = "", Optional encoding As Encodings = Encodings.UTF8) As i32
Return My.File.OpenHandle(Me(name) Or [default].AsDefault, encoding)
End Function
#End Region
@@ -775,7 +781,7 @@ Namespace CommandLine
'''
'''
Public Iterator Function GetEnumerator() As IEnumerator(Of NamedValue(Of String)) Implements IEnumerable(Of NamedValue(Of String)).GetEnumerator
- Dim source As New List(Of NamedValue(Of String))(Me.__arguments)
+ Dim source As New List(Of NamedValue(Of String))(Me.arguments)
If Not Me.BoolFlags.IsNullOrEmpty Then
source += From name As String
@@ -799,7 +805,7 @@ Namespace CommandLine
'''
Public Sub Add(item As NamedValue(Of String)) Implements ICollection(Of NamedValue(Of String)).Add
- Call __arguments.Add(item)
+ Call arguments.Add(item)
End Sub
'''
@@ -818,10 +824,10 @@ Namespace CommandLine
}
If Not allowDuplicated Then
- For i As Integer = 0 To __arguments.Count - 1
- With __arguments(i)
+ For i As Integer = 0 To arguments.Count - 1
+ With arguments(i)
If .Name.TextEquals(key) Then
- __arguments(i) = item
+ arguments(i) = item
Return
End If
End With
@@ -830,7 +836,7 @@ Namespace CommandLine
' 没有查找到需要被替换掉的下标,则直接在下面的代码之中进行添加
End If
- __arguments += item
+ arguments += item
End Sub
'''
@@ -839,7 +845,7 @@ Namespace CommandLine
'''
Public Sub Clear() Implements ICollection(Of NamedValue(Of String)).Clear
- Call __arguments.Clear()
+ Call arguments.Clear()
End Sub
'''
@@ -851,7 +857,7 @@ Namespace CommandLine
Dim LQuery% = LinqAPI.DefaultFirst(-1) _
_
<= From obj As NamedValue(Of String)
- In Me.__arguments
+ In Me.arguments
Where String.Equals(obj.Name, item.Name, StringComparison.OrdinalIgnoreCase)
Select 100
@@ -860,7 +866,7 @@ Namespace CommandLine
Public Sub CopyTo(array() As NamedValue(Of String), arrayIndex As Integer) Implements ICollection(Of NamedValue(Of String)).CopyTo
- Call __arguments.ToArray.CopyTo(array, arrayIndex)
+ Call arguments.ToArray.CopyTo(array, arrayIndex)
End Sub
'''
@@ -872,7 +878,7 @@ Namespace CommandLine
Public ReadOnly Property Count As Integer Implements ICollection(Of NamedValue(Of String)).Count
Get
- Return Me.__arguments.Count
+ Return Me.arguments.Count
End Get
End Property
@@ -892,14 +898,14 @@ Namespace CommandLine
Dim LQuery = LinqAPI.DefaultFirst(Of NamedValue(Of String)) _
_
() <= From obj As NamedValue(Of String)
- In Me.__arguments
+ In Me.arguments
Where String.Equals(obj.Name, paramName, StringComparison.OrdinalIgnoreCase)
Select obj
If LQuery.IsEmpty Then
Return False
Else
- Call __arguments.Remove(LQuery)
+ Call arguments.Remove(LQuery)
Return True
End If
End Function
@@ -926,7 +932,7 @@ Namespace CommandLine
Dim list As New List(Of NamedValue(Of String))
list += From arg As NamedValue(Of String)
- In __arguments.SafeQuery
+ In arguments.SafeQuery
Select New NamedValue(Of String) With {
.Name = arg.Name,
.Value = arg.Value
diff --git a/CommandLine/GitBashEnvironment.vb b/CommandLine/GitBashEnvironment.vb
new file mode 100644
index 00000000..6df3da67
--- /dev/null
+++ b/CommandLine/GitBashEnvironment.vb
@@ -0,0 +1,129 @@
+#Region "Microsoft.VisualBasic::2d1efa6a209cd7ffaec8999c2a3e45f3, Microsoft.VisualBasic.Core\CommandLine\GitBashEnvironment.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Module GitBashEnvironment
+ '
+ ' Properties: isRunningOnGitBash
+ '
+ ' Function: fixWindowsNetworkDirectory, GetCLIArgs
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Runtime.CompilerServices
+Imports System.Text.RegularExpressions
+
+Namespace CommandLine
+
+ '''
+ ''' Git bash environment helper module
+ '''
+ Module GitBashEnvironment
+
+ '''
+ ''' Enable .NET application running from git bash terminal
+ '''
+ Const gitBash$ = "C:/Program Files/Git"
+
+ '''
+ ''' Makes compatibility with git bash: = ``C:/Program Files/Git``
+ '''
+ '''
+ Public Function GetCLIArgs() As CommandLine
+ ' 第一个参数为应用程序的文件路径,不需要
+ Dim args$() = Environment.GetCommandLineArgs
+ Dim tokens$() = args _
+ .Skip(1) _
+ .Select(Function(t) t.Replace(gitBash, "")) _
+ .ToArray
+ Dim cliString$ = tokens.JoinBy(" ")
+ Dim cli = CLITools.TryParse(tokens, False, cliString)
+
+ Return cli
+ End Function
+
+ '''
+ ''' Is current application running in gitbash environment on windows?
+ '''
+ '''
+ Friend ReadOnly Property isRunningOnGitBash() As Boolean
+ Get
+ Return Environment.GetCommandLineArgs.Any(Function(a) InStr(a, gitBash) > 0)
+ End Get
+ End Property
+
+ '''
+ ''' (\\)192.168.1.239\blablabla
+ ''' 前面的两个斜杠可能被预处理的时候被清除掉了
+ ''' 所以在这里只匹配IP地址和后面的路径部分
+ '''
+ Const BrokenWindowsNetworkDirectoryPattern = "\d+(\.\d+){3}\.+"
+ Const WindowsNetworkDirectoryPattern = "\\{2}" & BrokenWindowsNetworkDirectoryPattern
+
+
+ Public Iterator Function fixWindowsNetworkDirectory(tokens As String()) As IEnumerable(Of String)
+ Dim trim$
+ Dim matchBroken$
+
+ For Each token As String In tokens
+ If App.IsMicrosoftPlatform AndAlso App.RunningInGitBash Then
+ ' 只针对Windows环境中的git bash环境进行修复
+ ' 因为gitbash会对\进行转义
+ ' 所以 \\192.168.1.239 之类的网络路径会被强制转义为 \192.168.1.239 即当前驱动器的某一个文件夹
+ If token.IsPattern(WindowsNetworkDirectoryPattern) Then
+ ' 已经是一个完整的路径了,直接返回
+ Yield token
+ Else
+ trim = token.TrimStart("\"c)
+ matchBroken = trim.Match(BrokenWindowsNetworkDirectoryPattern, RegexOptions.Singleline)
+
+ If trim <> token AndAlso InStr(trim, matchBroken) = 1 Then
+ Yield "\\" & trim
+ Else
+ ' 这不是一个网络路径
+ ' 则不需要进行修复
+ ' 直接返回原始的字符串即可
+ Yield token
+ End If
+ End If
+ Else
+ ' 不是运行于gitbash之上的
+ ' 不需要修补,直接返回
+ Yield token
+ End If
+ Next
+ End Function
+ End Module
+End Namespace
diff --git a/CommandLine/InteropService/Abstract.vb b/CommandLine/InteropService/Abstract.vb
index 1b0eb33d..af1b2401 100644
--- a/CommandLine/InteropService/Abstract.vb
+++ b/CommandLine/InteropService/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d7497de54115f6639b4080343f28b85c, CommandLine\InteropService\Abstract.vb"
+#Region "Microsoft.VisualBasic::d7497de54115f6639b4080343f28b85c, Microsoft.VisualBasic.Core\CommandLine\InteropService\Abstract.vb"
' Author:
'
diff --git a/CommandLine/InteropService/CLIAbstractor.vb b/CommandLine/InteropService/CLIAbstractor.vb
index 2430c820..e1f02139 100644
--- a/CommandLine/InteropService/CLIAbstractor.vb
+++ b/CommandLine/InteropService/CLIAbstractor.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::620a74df1490b707ca723085e2996b2e, CommandLine\InteropService\CLIAbstractor.vb"
+#Region "Microsoft.VisualBasic::620a74df1490b707ca723085e2996b2e, Microsoft.VisualBasic.Core\CommandLine\InteropService\CLIAbstractor.vb"
' Author:
'
diff --git a/CommandLine/InteropService/CLIBuilder.vb b/CommandLine/InteropService/CLIBuilder.vb
index c03c7d27..c8832357 100644
--- a/CommandLine/InteropService/CLIBuilder.vb
+++ b/CommandLine/InteropService/CLIBuilder.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::148d340e1974785080809fd0f39de3df, CommandLine\InteropService\CLIBuilder.vb"
+#Region "Microsoft.VisualBasic::148d340e1974785080809fd0f39de3df, Microsoft.VisualBasic.Core\CommandLine\InteropService\CLIBuilder.vb"
' Author:
'
diff --git a/CommandLine/InteropService/InCompatible.vb b/CommandLine/InteropService/InCompatible.vb
index e774579b..4b64af89 100644
--- a/CommandLine/InteropService/InCompatible.vb
+++ b/CommandLine/InteropService/InCompatible.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d3381a220021d85959f81ad7dab17afc, CommandLine\InteropService\InCompatible.vb"
+#Region "Microsoft.VisualBasic::d3381a220021d85959f81ad7dab17afc, Microsoft.VisualBasic.Core\CommandLine\InteropService\InCompatible.vb"
' Author:
'
diff --git a/CommandLine/InteropService/SharedORM/API.vb b/CommandLine/InteropService/SharedORM/API.vb
index d87fa1ab..9fa64993 100644
--- a/CommandLine/InteropService/SharedORM/API.vb
+++ b/CommandLine/InteropService/SharedORM/API.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6016951a6b4aae9d931bc139a1a4cd19, CommandLine\InteropService\SharedORM\API.vb"
+#Region "Microsoft.VisualBasic::5cd88ee07e972e5bb1a7c6ea90754f54, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\API.vb"
' Author:
'
@@ -107,7 +107,7 @@ Namespace CommandLine.InteropService.SharedORM
Dim model As New CommandLine With {
.Name = name,
- .__arguments = params.AsList,
+ .arguments = params.AsList,
.BoolFlags = booleans _
.SafeQuery _
.Select(AddressOf LCase) _
diff --git a/CommandLine/InteropService/SharedORM/CLI.vb b/CommandLine/InteropService/SharedORM/CLI.vb
index eefef70d..3c0ca58b 100644
--- a/CommandLine/InteropService/SharedORM/CLI.vb
+++ b/CommandLine/InteropService/SharedORM/CLI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fbedf0252652f4d03e94a8db319af729, CommandLine\InteropService\SharedORM\CLI.vb"
+#Region "Microsoft.VisualBasic::fbedf0252652f4d03e94a8db319af729, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\CLI.vb"
' Author:
'
diff --git a/CommandLine/InteropService/SharedORM/CodeGenerator.vb b/CommandLine/InteropService/SharedORM/CodeGenerator.vb
index 53992a80..ab9bfc77 100644
--- a/CommandLine/InteropService/SharedORM/CodeGenerator.vb
+++ b/CommandLine/InteropService/SharedORM/CodeGenerator.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dee18c385910bba9c50b797ed61de515, CommandLine\InteropService\SharedORM\CodeGenerator.vb"
+#Region "Microsoft.VisualBasic::dd77343e150b055962b20367cbc85c37, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\CodeGenerator.vb"
' Author:
'
@@ -51,6 +51,8 @@ Imports Microsoft.VisualBasic.CommandLine.ManView
Imports Microsoft.VisualBasic.CommandLine.Reflection.EntryPoints
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Text.Xml
Namespace CommandLine.InteropService.SharedORM
@@ -99,7 +101,7 @@ Namespace CommandLine.InteropService.SharedORM
.cliCommandArgvs = api.Name,
.SingleValue = api.Name,
.Tokens = {api.Name},
- .__arguments = New List(Of NamedValue(Of String))
+ .arguments = New List(Of NamedValue(Of String))
}
Call $"{api.EntryPointFullName(relativePath:=True)} is nothing!".Warning
Else
@@ -108,9 +110,9 @@ Namespace CommandLine.InteropService.SharedORM
Try
help =
-$"```
-{apiUsage.Replace("<", "<")}
-```" & vbCrLf & api.Info
+$"```bash
+{apiUsage.DoCall(AddressOf XmlEntity.EscapingXmlEntity)}
+```" & vbCrLf & api.Info.DoCall(AddressOf XmlEntity.EscapingXmlEntity)
CLI = New NamedValue(Of CommandLine) With {
.Name = api.EntryPoint.Name,
diff --git a/CommandLine/InteropService/SharedORM/PHP.vb b/CommandLine/InteropService/SharedORM/Languages/PHP.vb
similarity index 95%
rename from CommandLine/InteropService/SharedORM/PHP.vb
rename to CommandLine/InteropService/SharedORM/Languages/PHP.vb
index b5432d45..8437cdfe 100644
--- a/CommandLine/InteropService/SharedORM/PHP.vb
+++ b/CommandLine/InteropService/SharedORM/Languages/PHP.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0288d0bb5b1e1276578f59b45c3a32af, CommandLine\InteropService\SharedORM\PHP.vb"
+#Region "Microsoft.VisualBasic::0288d0bb5b1e1276578f59b45c3a32af, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\Languages\PHP.vb"
' Author:
'
diff --git a/CommandLine/InteropService/SharedORM/Perl.vb b/CommandLine/InteropService/SharedORM/Languages/Perl.vb
similarity index 97%
rename from CommandLine/InteropService/SharedORM/Perl.vb
rename to CommandLine/InteropService/SharedORM/Languages/Perl.vb
index 32409080..9967c6ad 100644
--- a/CommandLine/InteropService/SharedORM/Perl.vb
+++ b/CommandLine/InteropService/SharedORM/Languages/Perl.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b52830da536b47a8c6e0f27c10d6a98b, CommandLine\InteropService\SharedORM\Perl.vb"
+#Region "Microsoft.VisualBasic::b52830da536b47a8c6e0f27c10d6a98b, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\Languages\Perl.vb"
' Author:
'
diff --git a/CommandLine/InteropService/SharedORM/R.vb b/CommandLine/InteropService/SharedORM/Languages/R.vb
similarity index 95%
rename from CommandLine/InteropService/SharedORM/R.vb
rename to CommandLine/InteropService/SharedORM/Languages/R.vb
index a02d6fa5..8d49c690 100644
--- a/CommandLine/InteropService/SharedORM/R.vb
+++ b/CommandLine/InteropService/SharedORM/Languages/R.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::372ca7f6bacc3a4cf907325fc409eaf5, CommandLine\InteropService\SharedORM\R.vb"
+#Region "Microsoft.VisualBasic::372ca7f6bacc3a4cf907325fc409eaf5, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\Languages\R.vb"
' Author:
'
diff --git a/CommandLine/InteropService/SharedORM/VisualBasic.vb b/CommandLine/InteropService/SharedORM/Languages/VisualBasic.vb
similarity index 61%
rename from CommandLine/InteropService/SharedORM/VisualBasic.vb
rename to CommandLine/InteropService/SharedORM/Languages/VisualBasic.vb
index 84ff6da9..00ee48fb 100644
--- a/CommandLine/InteropService/SharedORM/VisualBasic.vb
+++ b/CommandLine/InteropService/SharedORM/Languages/VisualBasic.vb
@@ -1,54 +1,56 @@
-#Region "Microsoft.VisualBasic::12fe77c4e4c9cda30cfbdc6575522baa, CommandLine\InteropService\SharedORM\VisualBasic.vb"
+#Region "Microsoft.VisualBasic::a0e120cd0724c822a82a40107e2e0093, Microsoft.VisualBasic.Core\CommandLine\InteropService\SharedORM\Languages\VisualBasic.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Class VisualBasic
- '
- ' Constructor: (+2 Overloads) Sub New
- '
- ' Function: __defaultValue, __vbParameters, __xmlComments, createCliCalls, GetSourceCode
- ' normalizedAsVisualBasicIdentifier
- '
- ' Sub: __calls
- '
- '
- ' /********************************************************************************/
+' Class VisualBasic
+'
+' Constructor: (+2 Overloads) Sub New
+'
+' Function: addXmlComments, createCliCalls, GetSourceCode, normAsVisualBasicName, optionalDefaultValue
+' vbParameters
+'
+' Sub: cliCallsInternal
+'
+'
+' /********************************************************************************/
#End Region
Imports System.Runtime.CompilerServices
Imports System.Text
+Imports Microsoft.VisualBasic.CommandLine.Reflection
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Scripting.SymbolBuilder.VBLanguage
Imports Microsoft.VisualBasic.Text
Imports Microsoft.VisualBasic.Text.Xml
@@ -91,7 +93,7 @@ Namespace CommandLine.InteropService.SharedORM
Call vb.AppendLine()
Call vb.AppendLine("Namespace " & [namespace])
Call vb.AppendLine()
- Call vb.AppendLine(__xmlComments(XmlEntity.EscapingXmlEntity(info)))
+ Call vb.AppendLine(addXmlComments(XmlEntity.EscapingXmlEntity(info)))
Call vb.AppendLine($"Public Class {appName} : Inherits {GetType(InteropService).Name}")
Call vb.AppendLine()
Call vb.AppendLine($" Public Const App$ = ""{exe}.exe""")
@@ -99,14 +101,19 @@ Namespace CommandLine.InteropService.SharedORM
Call vb.AppendLine(" Sub New(App$)")
Call vb.AppendLine($" MyBase.{NameOf(InteropService._executableAssembly)} = App$")
Call vb.AppendLine(" End Sub")
- Call vb.AppendLine()
+ Call vb.AppendLine("
+'''
+''' Create an internal CLI pipeline invoker from a given environment path.
+'''
+''' A directory path that contains the target application
+''' ")
Call vb.AppendLine(" ")
Call vb.AppendLine($" Public Shared Function FromEnvironment(directory As String) As {appName}")
Call vb.AppendLine($" Return New {appName}(App:=directory & ""/"" & {appName}.App)")
Call vb.AppendLine(" End Function")
- For Each API In Me.EnumeratesAPI
- Call __calls(vb, API.CLI, incompatible:=Not InCompatibleAttribute.CLRProcessCompatible(API.API))
+ For Each api As APITuple In Me.EnumeratesAPI
+ Call cliCallsInternal(vb, api, incompatible:=Not InCompatibleAttribute.CLRProcessCompatible(api.API))
Next
Call vb.AppendLine("End Class")
@@ -115,7 +122,12 @@ Namespace CommandLine.InteropService.SharedORM
Return vb.ToString
End Function
- Private Shared Function __xmlComments(description$) As String
+ '''
+ '''
+ '''
+ '''
+ '''
+ Private Shared Function addXmlComments(description$) As String
If description.StringEmpty Then
description = "'''"
Else
@@ -133,13 +145,13 @@ Namespace CommandLine.InteropService.SharedORM
End Function
'''
- '''
+ ''' 生成一个命令行API的调用代码
'''
'''
- '''
+ '''
'''
'''
- Private Sub __calls(vb As StringBuilder, API As NamedValue(Of CommandLine), incompatible As Boolean)
+ Private Sub cliCallsInternal(vb As StringBuilder, cli As APITuple, incompatible As Boolean)
#Region "Code template"
@@ -151,11 +163,19 @@ Namespace CommandLine.InteropService.SharedORM
' End Function
#End Region
+ Dim api As NamedValue(Of CommandLine) = cli.CLI
' 直接使用函数原型的名字了,会比较容易辨别一些
- Dim func$ = API.Name
+ Dim func$ = api.Name
' Xml comment 已经是经过转义了的,所以不需要再做xml entity的转义了
- Dim xmlComments$ = __xmlComments(API.Description)
+ Dim xmlComments$ = addXmlComments(api.Description)
Dim params$()
+ Dim usage As Argument() = cli.API _
+ .GetCustomAttributes(True) _
+ .Where(Function(a)
+ Return a.GetType Is GetType(Argument)
+ End Function) _
+ .Select(Function(use) DirectCast(use, Argument)) _
+ .ToArray
Try
If func.First <= "9" AndAlso func.First >= "0"c Then
@@ -164,14 +184,20 @@ Namespace CommandLine.InteropService.SharedORM
' 不是以数字开头的,则尝试解决关键词的问题
func = KeywordProcessor.AutoEscapeVBKeyword(func)
End If
- params = __vbParameters(API.Value)
+ params = vbParameters(api.Value)
Catch ex As Exception
- ex = New Exception("Check for your CLI Usage definition: " & API.Value.ToString, ex)
+ ex = New Exception("Check for your CLI Usage definition: " & api.Value.ToString, ex)
Throw ex
End Try
Call vb.AppendLine(xmlComments)
+ Call vb.AppendLine(usage.DoCall(AddressOf ArgumentXmlDocs).JoinBy(vbCrLf))
+ Call vb.AppendLine($"Public Function {func}({params.JoinBy(", ")}) As Integer")
+ Call vb.AppendLine($" Dim CLI As New StringBuilder(""{api.Value.Name}"")")
+ ' 插入命令名称和参数值之间的一个必须的空格
+ Call vb.AppendLine(" Call CLI.Append("" "")")
+ Call vb.AppendLine(createCliCalls(+api))
Dim deli$
If params.Length > 4 Then
@@ -181,9 +207,9 @@ Namespace CommandLine.InteropService.SharedORM
End If
Call vb.AppendLine($"Public Function {func}({params.JoinBy(", ")}) As Integer")
- Call vb.AppendLine($" Dim CLI As New StringBuilder(""{API.Value.Name}"")")
+ Call vb.AppendLine($" Dim CLI As New StringBuilder(""{api.Value.Name}"")")
Call vb.AppendLine(" Call CLI.Append("" "")") ' 插入命令名称和参数值之间的一个必须的空格
- Call vb.AppendLine(createCliCalls(+API))
+ Call vb.AppendLine(createCliCalls(+api))
Call vb.AppendLine()
If incompatible Then
@@ -198,26 +224,45 @@ Namespace CommandLine.InteropService.SharedORM
Call vb.AppendLine("End Function")
End Sub
+ Private Shared Function ArgumentXmlDocs(args As Argument()) As String()
+ Dim out As New List(Of String)
+ Dim param$
+ Dim comments$
+
+ For Each arg As Argument In args
+ comments = XmlEntity.EscapingXmlEntity(arg.Description) _
+ .Replace("\n", vbCrLf) _
+ .LineTokens _
+ .Select(Function(l) "''' " & l) _
+ .JoinBy(vbCrLf) _
+ .Trim("'"c)
+ param = $"''' {comments}
+''' "
+ out += param
+ Next
+
+ Return out
+ End Function
'''
''' 在这个函数之中会生成函数的参数列表
'''
'''
'''
- Private Shared Function __vbParameters(API As CommandLine) As String()
+ Private Shared Function vbParameters(API As CommandLine) As String()
Dim out As New List(Of String)
Dim param$
- If API.__arguments = 1 AndAlso API.__arguments(Scan0).Name.StringEmpty Then
+ If API.arguments = 1 AndAlso API.arguments(Scan0).Name.StringEmpty Then
' /command
out += $"term As String"
Else
For Each arg As NamedValue(Of String) In API.ParameterList
- param = $"{VisualBasic.normalizedAsVisualBasicIdentifier(arg.Name)} As String"
+ param = $"{VisualBasic.normAsVisualBasicName(arg.Name)} As String"
If Not arg.Description.StringEmpty Then
' 可选参数
- param = $"Optional {param} = ""{__defaultValue(arg.Value)}"""
+ param = $"Optional {param} = ""{optionalDefaultValue(arg.Value)}"""
End If
out += param
@@ -225,7 +270,7 @@ Namespace CommandLine.InteropService.SharedORM
End If
For Each bool In API.BoolFlags
- out += $"Optional {VisualBasic.normalizedAsVisualBasicIdentifier(bool)} As Boolean = False"
+ out += $"Optional {VisualBasic.normAsVisualBasicName(bool)} As Boolean = False"
Next
Return out
@@ -236,7 +281,7 @@ Namespace CommandLine.InteropService.SharedORM
'''
'''
'''
- Private Shared Function __defaultValue(value$) As String
+ Private Shared Function optionalDefaultValue(value$) As String
If value.First = """"c AndAlso value.Last = """"c Then
' 如果是直接使用双引号包裹而不是使用<>尖括号进行包裹,则认为双引号所包裹的值都是默认值
value = value.GetStackValue(ASCII.Quot, ASCII.Quot)
@@ -247,7 +292,8 @@ Namespace CommandLine.InteropService.SharedORM
If InStr(value, "default=") > 0 Then
value = Strings.Split(value, "default=").Last.Trim(""""c)
Else
- value = "" ' 没有表达式前缀,则使用默认的空字符串
+ ' 没有表达式前缀,则使用默认的空字符串
+ value = ""
End If
Else
' 其他情况都认为是使用空值为默认值
@@ -262,19 +308,26 @@ Namespace CommandLine.InteropService.SharedORM
'''
''' 创建命令行调用字符串
'''
- '''
+ '''
'''
- Private Shared Function createCliCalls(Api As CommandLine) As String
+ Private Shared Function createCliCalls(api As CommandLine) As String
Dim CLI As New StringBuilder
Dim vbcode$
+ ' 可能在参数中存在/@set环境参数的设置的调用
+ Dim envir As String = Nothing
- If Api.__arguments = 1 AndAlso Api.__arguments(Scan0).Name.StringEmpty Then
+ If api.arguments = 1 AndAlso api.arguments(Scan0).Name.StringEmpty Then
' /command
vbcode = " Call CLI.Append($""{term}"")"
CLI.AppendLine(vbcode)
Else
- For Each param As NamedValue(Of String) In Api.ParameterList
- Dim var$ = normalizedAsVisualBasicIdentifier(param.Name)
+ For Each param As NamedValue(Of String) In api.ParameterList
+ Dim var$ = normAsVisualBasicName(param.Name)
+
+ If param.Name.TextEquals("/@set") Then
+ envir = param.Name
+ Continue For
+ End If
' 注意:在这句代码的最后有一个空格,是间隔参数所必需的,不可以删除
vbcode = $" Call CLI.Append(""{param.Name} "" & """""""" & {var} & """""" "")"
@@ -291,15 +344,29 @@ Namespace CommandLine.InteropService.SharedORM
Next
End If
- For Each b In Api.BoolFlags
- Dim var$ = normalizedAsVisualBasicIdentifier(b)
+ For Each b In api.BoolFlags
+ Dim var$ = normAsVisualBasicName(b)
Call CLI.AppendLine($" If {var} Then")
- Call CLI.AppendLine($" Call CLI.Append(""{b} "")") ' 逻辑参数后面有一个空格,是正确的生成CLI所必需的
+ ' 逻辑参数后面有一个空格,是正确的生成CLI所必需的
+ Call CLI.AppendLine($" Call CLI.Append(""{b} "")")
Call CLI.AppendLine(" End If")
Next
- Call CLI.AppendLine($" Call CLI.Append(""/@set {Microsoft.VisualBasic.App.FlagInternalPipeline}=TRUE "")")
+ ' 在最后将/@set环境参数组装起来
+ If Not envir.StringEmpty Then
+ envir = normAsVisualBasicName(envir)
+
+ Call CLI.AppendLine($" If Not {envir}.{NameOf(StringEmpty)} Then")
+ Call CLI.AppendLine($" Call CLI.Append($""/@set """"""""{Microsoft.VisualBasic.App.FlagInternalPipeline}=TRUE;'{{{envir}}}'"""""""" "")")
+ Call CLI.AppendLine("Else")
+ ' 没有需要组装的,直接添加调用
+ Call CLI.AppendLine($" Call CLI.Append(""/@set {Microsoft.VisualBasic.App.FlagInternalPipeline}=TRUE "")")
+ Call CLI.AppendLine(" End If")
+ Else
+ ' 没有需要组装的,直接添加调用
+ Call CLI.AppendLine($" Call CLI.Append(""/@set {Microsoft.VisualBasic.App.FlagInternalPipeline}=TRUE "")")
+ End If
Return CLI.ToString
End Function
@@ -311,7 +378,7 @@ Namespace CommandLine.InteropService.SharedORM
'''
'''
'''
- Private Shared Function normalizedAsVisualBasicIdentifier(arg$) As String
+ Private Shared Function normAsVisualBasicName(arg$) As String
' 在命令行的参数名称前面一般都会有/-之类的控制符前缀,在这里去掉
Dim name$ = arg.Trim("/"c, "\"c, "-"c)
Dim s As Char() = name.ToArray
diff --git a/CommandLine/Interpreters/Abstract.vb b/CommandLine/Interpreters/Abstract.vb
index 0d691b7b..b7dffc1a 100644
--- a/CommandLine/Interpreters/Abstract.vb
+++ b/CommandLine/Interpreters/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dc46e1f7a1d006175ea1351e45e19984, CommandLine\Interpreters\Abstract.vb"
+#Region "Microsoft.VisualBasic::dc46e1f7a1d006175ea1351e45e19984, Microsoft.VisualBasic.Core\CommandLine\Interpreters\Abstract.vb"
' Author:
'
diff --git a/CommandLine/Interpreters/ExecuteImpl.vb b/CommandLine/Interpreters/ExecuteImpl.vb
new file mode 100644
index 00000000..51e9d29b
--- /dev/null
+++ b/CommandLine/Interpreters/ExecuteImpl.vb
@@ -0,0 +1,180 @@
+#Region "Microsoft.VisualBasic::ab8efcb9c4794bfbb95e6be96ee8920b, Microsoft.VisualBasic.Core\CommandLine\Interpreters\ExecuteImpl.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Module ExecuteImpl
+ '
+ ' Function: CreateCLIPipelineFile, ListingRelatedCommands
+ '
+ ' Sub: HandleProgramManual, HandleShellHistory, PrintVariables
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.IO
+Imports System.Runtime.CompilerServices
+Imports System.Text
+Imports Microsoft.VisualBasic.CommandLine.ManView
+Imports Microsoft.VisualBasic.ComponentModel.Settings
+Imports Microsoft.VisualBasic.Language.UnixBash
+Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Text
+Imports Microsoft.VisualBasic.Text.Levenshtein
+Imports VB = Microsoft.VisualBasic.CommandLine.InteropService.SharedORM.VisualBasic
+
+Namespace CommandLine
+
+ '''
+ ''' Executive implementation of
+ '''
+ Module ExecuteImpl
+
+
+ Friend Function CreateCLIPipelineFile(cli_app As Interpreter, args As CommandLine) As Integer
+ Dim namespace$ = args("/namespace") Or "CLI"
+ Dim vb$ = New VB(App:=cli_app, [namespace]:=[namespace]).GetSourceCode
+ Dim dev As TextWriter
+
+ If args("---echo") Then
+ dev = App.StdOut
+ Else
+ dev = ($"{App.HOME}/{cli_app.Type.Assembly.CodeBase.BaseName}.vb") _
+ .Open(, doClear:=True) _
+ .DoCall(Function(file)
+ Return New StreamWriter(file, Encodings.UTF8WithoutBOM.CodePage)
+ End Function)
+ End If
+
+ Call dev.WriteLine(vb)
+ Call dev.Flush()
+ Call dev.Close()
+
+ Return 0
+ End Function
+
+
+ Friend Function ListingRelatedCommands(cli_app As Interpreter, query$) As String()
+ Dim key As New LevenshteinString(query.ToLower)
+ Dim LQuery = From x As String
+ In cli_app.apiTable.Keys.AsParallel
+ Let compare = key Like x
+ Where Not compare Is Nothing AndAlso
+ compare.Score > 0.3
+ Select compare.Score,
+ x
+ Order By Score Descending
+
+ Dim levenshteins = LQuery _
+ .Select(Function(x) x.x) _
+ .AsList
+
+ levenshteins += cli_app.apiTable _
+ .Keys _
+ .Where(Function(s)
+ Return InStr(s, query, CompareMethod.Text) > 0 OrElse
+ InStr(query, s, CompareMethod.Text) > 0
+ End Function)
+
+ Return levenshteins _
+ .Distinct _
+ .Select(Function(name)
+ Return cli_app.apiTable(name).Name
+ End Function) _
+ .ToArray
+ End Function
+
+ Friend Sub PrintVariables()
+ Dim vars = App.GetAppVariables
+
+ Call Console.WriteLine()
+ Call Console.WriteLine(PS1.Fedora12.ToString)
+ Call Console.WriteLine()
+ Call Console.WriteLine($"Print environment variables for {GetType(App).FullName}:")
+ Call Console.WriteLine(ConfigEngine.Prints(vars))
+ End Sub
+
+ Friend Sub HandleShellHistory(args As CommandLine)
+ Dim logs$ = (App.LogErrDIR.ParentPath & "/.shells.log")
+
+ If args.Parameters.IsNullOrEmpty Then
+ Call Console.WriteLine()
+ Call logs.ReadAllText.EchoLine
+ Call Console.WriteLine()
+ Else
+ With args.ParameterList.First
+ Select Case .Name.ToLower
+ Case "/clear"
+ Call New Byte() {}.FlushStream(logs)
+ Case "/search"
+
+ Dim term$ = .Value
+
+ Call Console.WriteLine()
+ Call logs.IterateAllLines _
+ .Where(Function(line)
+ Return InStr(line, term, CompareMethod.Text) > 0
+ End Function) _
+ .JoinBy(vbCrLf) _
+ .EchoLine
+ Call Console.WriteLine()
+
+ Case Else
+ Console.WriteLine("Unknown command!")
+ End Select
+ End With
+ End If
+ End Sub
+
+ Friend Sub HandleProgramManual(cli_app As Interpreter, args As CommandLine)
+ ' 默认是分段打印帮助信息,假若加上了 --print参数的话,则才会一次性的打印所有的信息出来
+ Dim doc As String = cli_app.SDKdocs()
+ Dim output$ = args("/out") Or "./"
+
+ If Not args("--file") Then
+ If args("--print") Then
+ Call Console.WriteLine(doc)
+ Else
+ Call SDKManual.LaunchManual(CLI:=cli_app)
+ End If
+ Else
+ ' 只会写文件而不会在终端打开帮助窗口
+ End If
+
+ Call ($"{output}/{App.AssemblyName}.md") _
+ .DoCall(Sub(md)
+ Call doc.SaveTo(md, Encoding.UTF8)
+ End Sub)
+ End Sub
+ End Module
+End Namespace
diff --git a/CommandLine/Interpreters/InteractiveConsole.vb b/CommandLine/Interpreters/InteractiveConsole.vb
index 3dbfc8f8..8a844141 100644
--- a/CommandLine/Interpreters/InteractiveConsole.vb
+++ b/CommandLine/Interpreters/InteractiveConsole.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7a2992138e9e7423d9198b9a47be833d, CommandLine\Interpreters\InteractiveConsole.vb"
+#Region "Microsoft.VisualBasic::3ed88763e0a6e16efdd5d124ae9af951, Microsoft.VisualBasic.Core\CommandLine\Interpreters\InteractiveConsole.vb"
' Author:
'
@@ -37,7 +37,7 @@
'
' Function: RunApp
'
- ' Sub: RunAppInternal
+ ' Sub: doListingDirectory, RunAppInternal
'
'
' /********************************************************************************/
@@ -50,6 +50,7 @@ Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.UnixBash
Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Scripting.Expressions
+Imports Microsoft.VisualBasic.Terminal
Namespace CommandLine
@@ -73,32 +74,59 @@ Namespace CommandLine
End Sub
Public Function RunApp() As Integer
- Dim input As Value(Of String) = ""
- Dim ps1 As PS1 = PS1.Fedora12
+ Dim shell As New Shell(
+ ps1:=PS1.Fedora12,
+ exec:=Sub(input)
+ Call CLITools.TryParse(input).DoCall(AddressOf RunAppInternal)
+ End Sub
+ ) With {
+ .Quite = "exit"
+ }
Call MyBase.Execute(args:=New CommandLine With {.Name = "?"})
Call Console.WriteLine()
Call Console.WriteLine()
- Call Console.Write(ps1.ToString)
+ Call Console.Write(shell.ps1.ToString)
Call Console.Write(" ")
- Do While Not (input = Console.ReadLine).TextEquals("exit")
- With input.Value
- If Not .StringEmpty Then
- Call RunAppInternal(CLITools.TryParse(.ByRef))
- End If
- End With
-
- Call Console.Write(ps1.ToString)
- Call Console.Write(" ")
- Loop
-
+ ' 代码执行会被阻塞在这里, 直到输入exit退出
+ Call shell.Run()
Call Console.WriteLine("Bye bye.")
Return 0
End Function
+ Private Sub doListingDirectory(cmd As CommandLine)
+ Dim directory$ = If(cmd.Tokens.ElementAtOrDefault(1), App.CurrentDirectory)
+
+ If Not directory.DirectoryExists Then
+ Console.ForegroundColor = ConsoleColor.Red
+ Console.WriteLine($"Directory ""{directory}"" not exist on your filesystem!")
+ Console.ForegroundColor = ConsoleColor.White
+
+ Return
+ End If
+
+ Dim directories = FileIO.FileSystem.GetDirectories(directory)
+ Dim files = FileIO.FileSystem.GetFiles(directory)
+
+ For Each dir As String In directories
+ Call Console.WriteLine(" " & dir.Replace("\"c, "/"c).Split("/"c).Last)
+ Next
+
+ Dim table = files _
+ .Select(Function(path)
+ Return {
+ path.Replace("\"c, "/"c).Split("/"c).Last,
+ New FileInfo(path).Length & " Bytes"
+ }
+ End Function) _
+ .ToArray
+
+ Call PrintAsTable.Print(table, New StreamWriter(Console.OpenStandardOutput))
+ End Sub
+
'''
''' Contains sevral build in command about file system operation and the program CLI interpreter commands
'''
@@ -108,33 +136,7 @@ Namespace CommandLine
Case "ls" ' list directory
- Dim directory$ = If(cmd.Tokens.ElementAtOrDefault(1), App.CurrentDirectory)
-
- If Not directory.DirectoryExists Then
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine($"Directory ""{directory}"" not exist on your filesystem!")
- Console.ForegroundColor = ConsoleColor.White
-
- Return
- End If
-
- Dim directories = FileIO.FileSystem.GetDirectories(directory)
- Dim files = FileIO.FileSystem.GetFiles(directory)
-
- For Each dir As String In directories
- Call Console.WriteLine(" " & dir.Replace("\"c, "/"c).Split("/"c).Last)
- Next
-
- Dim table = files _
- .Select(Function(path)
- Return {
- path.Replace("\"c, "/"c).Split("/"c).Last,
- New FileInfo(path).Length & " Bytes"
- }
- End Function) _
- .ToArray
-
- Call PrintAsTable.Print(table, New StreamWriter(Console.OpenStandardOutput))
+ Call doListingDirectory(cmd)
Case "cd" ' change directory
diff --git a/CommandLine/Interpreters/Interpreter.vb b/CommandLine/Interpreters/Interpreter.vb
index 28ce3659..b35d898d 100644
--- a/CommandLine/Interpreters/Interpreter.vb
+++ b/CommandLine/Interpreters/Interpreter.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dcfc8f9f59421f3383f29e83fa30780e, CommandLine\Interpreters\Interpreter.vb"
+#Region "Microsoft.VisualBasic::8809e5ad7b8bb9480cf6ffb246d01139, Microsoft.VisualBasic.Core\CommandLine\Interpreters\Interpreter.vb"
' Author:
'
@@ -53,19 +53,18 @@
Imports System.Reflection
Imports System.Runtime.CompilerServices
-Imports System.Text
+#If DEBUG Then
+#Else
Imports Microsoft.VisualBasic.ApplicationServices.Debugging
+#End If
Imports Microsoft.VisualBasic.CommandLine.ManView
Imports Microsoft.VisualBasic.CommandLine.Reflection
Imports Microsoft.VisualBasic.CommandLine.Reflection.EntryPoints
-Imports Microsoft.VisualBasic.ComponentModel.Settings
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.UnixBash
+Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Linq.Extensions
Imports Microsoft.VisualBasic.Serialization.JSON
-Imports Microsoft.VisualBasic.Text
-Imports Microsoft.VisualBasic.Text.Levenshtein
-Imports VB = Microsoft.VisualBasic.CommandLine.InteropService.SharedORM.VisualBasic
#Const NET_45 = 0
@@ -87,8 +86,8 @@ Namespace CommandLine
'''
''' 在添加之前请确保键名是小写的字符串
'''
- Protected Friend __API_table As New Dictionary(Of String, APIEntryPoint)
- Protected __rootNamespace$
+ Protected Friend apiTable As New Dictionary(Of String, APIEntryPoint)
+ Protected rootNamespace$
#Region "Optional delegates"
@@ -117,11 +116,11 @@ Namespace CommandLine
'''
Public Function ToDictionary() As Dictionary(Of String, APIEntryPoint)
- Return __API_table
+ Return apiTable
End Function
Public Overrides Function ToString() As String
- Return "CLI://" & __rootNamespace
+ Return "CLI://" & rootNamespace
End Function
'''
@@ -144,7 +143,8 @@ Namespace CommandLine
#End If
Return i
Else
- Return __executeEmpty() ' 命令行是空的
+ ' 命令行是空的
+ Return doExecuteNonCLIInput()
End If
End Function
@@ -153,15 +153,18 @@ Namespace CommandLine
''' 否则打印出所有的命令名称信息
'''
'''
- Private Function __executeEmpty() As Integer
+ Private Function doExecuteNonCLIInput() As Integer
If Not ExecuteEmptyCli Is Nothing Then
+#If DEBUG Then
+ Return _ExecuteEmptyCli()
+#Else
Try
Return _ExecuteEmptyCli()
Catch ex As Exception
Call App.LogException(ex)
Call ex.PrintException
End Try
-
+#End If
Return -100
Else
' 当用户什么也不输入的时候,打印出所有的命令名称帮助信息
@@ -179,53 +182,17 @@ Namespace CommandLine
Private Function apiInvoke(commandName$, argvs As Object(), help_argvs$()) As Integer
Dim CLI As CommandLine = DirectCast(argvs(Scan0), CommandLine)
- If __API_table.ContainsKey(commandName) Then _
- Return __API_table(commandName).Execute(argvs)
+ If apiTable.ContainsKey(commandName) Then _
+ Return apiTable(commandName).Execute(argvs)
If "??vars".TextEquals(commandName) Then
- Dim vars = App.GetAppVariables
-
- Call Console.WriteLine()
- Call Console.WriteLine(PS1.Fedora12.ToString)
- Call Console.WriteLine()
- Call Console.WriteLine($"Print environment variables for {GetType(App).FullName}:")
- Call Console.WriteLine(ConfigEngine.Prints(vars))
+ Call ExecuteImpl.PrintVariables()
Return 0
ElseIf "??history".TextEquals(commandName) Then
- Dim logs$ = (App.LogErrDIR.ParentPath & "/.shells.log")
-
- With DirectCast(argvs(Scan0), CommandLine)
- If .Parameters.IsNullOrEmpty Then
- Call Console.WriteLine()
- Call logs.ReadAllText.EchoLine
- Call Console.WriteLine()
- Else
- With .ParameterList.First
- Select Case .Name.ToLower
- Case "/clear"
- Call New Byte() {}.FlushStream(logs)
- Case "/search"
-
- Dim term$ = .Value
-
- Call Console.WriteLine()
- Call logs.IterateAllLines _
- .Where(Function(line)
- Return InStr(line, term, CompareMethod.Text) > 0
- End Function) _
- .JoinBy(vbCrLf) _
- .EchoLine
- Call Console.WriteLine()
-
- Case Else
- Console.WriteLine("Unknown command!")
- End Select
- End With
- End If
- End With
+ Call ExecuteImpl.HandleShellHistory(args:=CLI)
Return 0
@@ -237,8 +204,8 @@ Namespace CommandLine
End If
ElseIf InStr(commandName, "??") = 1 Then ' 支持类似于R语言里面的 ??帮助命令
- commandName = Mid(commandName, 3) ' 去除前面的两个??问号,得到查询的term
- Return Help(commandName)
+ ' 去除前面的两个??问号,得到查询的term
+ Return Mid(commandName, 3).DoCall(AddressOf Help)
ElseIf String.Equals(commandName, "~") Then
' 打印出应用程序的位置,linux里面的HOME
@@ -247,38 +214,13 @@ Namespace CommandLine
Return 0
ElseIf String.Equals(commandName, "man") Then
- ' 默认是分段打印帮助信息,假若加上了 --print参数的话,则才会一次性的打印所有的信息出来
- Dim doc As String = SDKdocs()
- Dim output$ = CLI("/out") Or "./"
-
- If Not CLI.GetBoolean("--file") Then
- If CLI.GetBoolean("--print") Then
- Call Console.WriteLine(doc)
- Else
- Call SDKManual.LaunchManual(CLI:=Me)
- End If
- Else
- ' 只会写文件而不会在终端打开帮助窗口
- End If
-
- Return doc.SaveTo($"{output}/{App.AssemblyName}.md", Encoding.UTF8).CLICode
+ Call ExecuteImpl.HandleProgramManual(Me, CLI)
ElseIf String.Equals(commandName, "/linux-bash", StringComparison.OrdinalIgnoreCase) Then
Return My.BashShell()
ElseIf String.Equals(commandName, "/CLI.dev", StringComparison.OrdinalIgnoreCase) Then
- Dim namespace$ = CLI("/namespace") Or "CLI"
- Dim vb$ = New VB(App:=Me, [namespace]:=[namespace]).GetSourceCode
-
- If CLI.IsTrue("---echo") Then
- Console.WriteLine(vb)
- Return 0
- Else
- Dim sourcefile$ = $"{App.HOME}/{Type.Assembly.CodeBase.BaseName}.vb"
- Return vb _
- .SaveTo(sourcefile, Encodings.UTF8WithoutBOM.CodePage) _
- .CLICode
- End If
+ Return Me.CreateCLIPipelineFile(args:=CLI)
Else
' 命令行的名称和上面的都不符合,但是可以在文件系统之中找得到一个相应的文件,则执行文件句柄
@@ -365,8 +307,8 @@ Namespace CommandLine
Public Sub AddCommand(Command As APIEntryPoint)
Dim key$ = Command.Name.ToLower
- If Not __API_table.ContainsKey(key) Then
- Call __API_table.Add(key, Command)
+ If Not apiTable.ContainsKey(key) Then
+ Call apiTable.Add(key, Command)
End If
End Sub
@@ -399,7 +341,7 @@ Namespace CommandLine
Public ReadOnly Property ListCommandInfo As EntryPoints.APIEntryPoint()
Get
- Return __API_table.Values.ToArray
+ Return apiTable.Values.ToArray
End Get
End Property
@@ -415,14 +357,14 @@ Namespace CommandLine
'''
Sub New(type As Type, Optional caller As String = Nothing)
For Each cInfo As APIEntryPoint In __getsAllCommands(type, False)
- If __API_table.ContainsKey(cInfo.Name.ToLower) Then
+ If apiTable.ContainsKey(cInfo.Name.ToLower) Then
Throw New Exception(cInfo.Name & " is duplicated with other command!")
Else
- Call __API_table.Add(cInfo.Name.ToLower, cInfo)
+ Call apiTable.Add(cInfo.Name.ToLower, cInfo)
End If
Next
- Me.__rootNamespace = type.Namespace
+ Me.rootNamespace = type.Namespace
Me._Stack = caller
Me._Type = type
Me._Info = type.NamespaceEntry(True)
@@ -479,32 +421,23 @@ Namespace CommandLine
'''
Private Shared Function getAPI(methodInfo As MethodInfo, commandAttribute As Type, [throw] As Boolean) As APIEntryPoint
Dim cmdAttr As ExportAPIAttribute = Nothing
- Dim commandInfo As APIEntryPoint
Try
Dim attrs As Object() = methodInfo.GetCustomAttributes(commandAttribute, False)
+
If attrs.IsNullOrEmpty Then
Return Nothing
+ Else
+ cmdAttr = DirectCast(attrs(0), ExportAPIAttribute)
End If
- cmdAttr = DirectCast(attrs(0), ExportAPIAttribute)
- commandInfo = New APIEntryPoint(cmdAttr, methodInfo, [throw]) ' 在这里将外部的属性标记和所属的函数的入口点进行连接
- If cmdAttr.Info.StringEmpty Then
- cmdAttr.Info = methodInfo.Description ' 帮助信息的获取兼容系统的Description方法
- End If
- If cmdAttr.Usage.StringEmpty Then
- cmdAttr.Usage = methodInfo.Usage
- End If
- If cmdAttr.Example.StringEmpty Then
- cmdAttr.Example = methodInfo.ExampleInfo
- End If
-
- Return commandInfo
+ Return doLoadApiInternal(cmdAttr, methodInfo, [throw])
Catch ex As Exception
If Not cmdAttr Is Nothing Then
ex = New Exception("This command API can not be imports: " & cmdAttr.GetJson, ex)
ex = New Exception(CheckNotice, ex)
End If
+
Call App.LogException(New Exception(methodInfo.FullName(True), ex))
Call ex.PrintException
@@ -512,6 +445,27 @@ Namespace CommandLine
End Try
End Function
+ '''
+ ''' 在这里将外部的属性标记和所属的函数的入口点进行连接
+ '''
+ '''
+ Private Shared Function doLoadApiInternal(cmdAttr As ExportAPIAttribute, methodInfo As MethodInfo, [throw] As Boolean) As APIEntryPoint
+ Dim commandInfo As New APIEntryPoint(cmdAttr, methodInfo, [throw])
+
+ If cmdAttr.Info.StringEmpty Then
+ ' 帮助信息的获取兼容系统的Description方法
+ cmdAttr.Info = methodInfo.Description
+ End If
+ If cmdAttr.Usage.StringEmpty Then
+ cmdAttr.Usage = methodInfo.Usage
+ End If
+ If cmdAttr.Example.StringEmpty Then
+ cmdAttr.Example = methodInfo.ExampleInfo
+ End If
+
+ Return commandInfo
+ End Function
+
Const CheckNotice As String = "Please checks for the export api definition on your CLI interface function."
'''
@@ -616,8 +570,8 @@ Namespace CommandLine
#Region "Implements System.Collections.Generic.IReadOnlyDictionary(Of String, CommandInfo)"
Public Iterator Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)) Implements IEnumerable(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).GetEnumerator
- For Each key As String In Me.__API_table.Keys
- Yield New KeyValuePair(Of String, EntryPoints.APIEntryPoint)(key, Me.__API_table(key))
+ For Each key As String In Me.apiTable.Keys
+ Yield New KeyValuePair(Of String, EntryPoints.APIEntryPoint)(key, Me.apiTable(key))
Next
End Function
@@ -626,7 +580,7 @@ Namespace CommandLine
End Function
Public Sub Add(item As KeyValuePair(Of String, EntryPoints.APIEntryPoint)) Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).Add
- Call __API_table.Add(item.Key, item.Value)
+ Call apiTable.Add(item.Key, item.Value)
End Sub
'''
@@ -634,15 +588,15 @@ Namespace CommandLine
'''
'''
Public Sub Clear() Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).Clear
- Call __API_table.Clear()
+ Call apiTable.Clear()
End Sub
Public Function Contains(item As KeyValuePair(Of String, EntryPoints.APIEntryPoint)) As Boolean Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).Contains
- Return __API_table.Contains(item)
+ Return apiTable.Contains(item)
End Function
Public Sub CopyTo(array() As KeyValuePair(Of String, EntryPoints.APIEntryPoint), arrayIndex As Integer) Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).CopyTo
- Call __API_table.ToArray.CopyTo(array, arrayIndex)
+ Call apiTable.ToArray.CopyTo(array, arrayIndex)
End Sub
'''
@@ -653,7 +607,7 @@ Namespace CommandLine
'''
Public ReadOnly Property Count As Integer Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).Count
Get
- Return Me.__API_table.Count
+ Return Me.apiTable.Count
End Get
End Property
@@ -664,11 +618,11 @@ Namespace CommandLine
End Property
Public Function Remove(item As KeyValuePair(Of String, EntryPoints.APIEntryPoint)) As Boolean Implements ICollection(Of KeyValuePair(Of String, EntryPoints.APIEntryPoint)).Remove
- Return __API_table.Remove(item.Key)
+ Return apiTable.Remove(item.Key)
End Function
Public Sub Add(key As String, value As EntryPoints.APIEntryPoint) Implements IDictionary(Of String, EntryPoints.APIEntryPoint).Add
- Call __API_table.Add(key, value)
+ Call apiTable.Add(key, value)
End Sub
'''
@@ -678,7 +632,7 @@ Namespace CommandLine
'''
'''
Public Function ExistsCommand(CommandName As String) As Boolean Implements IDictionary(Of String, EntryPoints.APIEntryPoint).ContainsKey
- Return Me.__API_table.ContainsKey(CommandName.ToLower)
+ Return Me.apiTable.ContainsKey(CommandName.ToLower)
End Function
'''
@@ -688,7 +642,7 @@ Namespace CommandLine
'''
Default Public Overloads Property Item(key As String) As EntryPoints.APIEntryPoint Implements IDictionary(Of String, EntryPoints.APIEntryPoint).Item
Get
- Return Me.__API_table(key)
+ Return Me.apiTable(key)
End Get
Set(value As EntryPoints.APIEntryPoint)
'DO NOTHING
@@ -701,7 +655,7 @@ Namespace CommandLine
If commands.Length = 0 Then
Return Nothing
Else
- Return __API_table(commands.First.ToLower)
+ Return apiTable(commands.First.ToLower)
End If
End Function
@@ -710,34 +664,10 @@ Namespace CommandLine
'''
''' 模糊匹配
'''
+ '''
+
Public Function ListingRelated(query$) As String()
- Dim key As New LevenshteinString(query.ToLower)
- Dim LQuery = From x As String
- In __API_table.Keys.AsParallel
- Let compare = key Like x
- Where Not compare Is Nothing AndAlso
- compare.Score > 0.3
- Select compare.Score,
- x
- Order By Score Descending
-
- Dim levenshteins = LQuery _
- .Select(Function(x) x.x) _
- .AsList
-
- levenshteins += __API_table _
- .Keys _
- .Where(Function(s)
- Return InStr(s, query, CompareMethod.Text) > 0 OrElse
- InStr(query, s, CompareMethod.Text) > 0
- End Function)
-
- Return levenshteins _
- .Distinct _
- .Select(Function(name)
- Return __API_table(name).Name
- End Function) _
- .ToArray
+ Return Me.ListingRelatedCommands(query)
End Function
'''
@@ -749,16 +679,16 @@ Namespace CommandLine
'''
Public ReadOnly Property APINameList As ICollection(Of String) Implements IDictionary(Of String, EntryPoints.APIEntryPoint).Keys
Get
- Return Me.__API_table.Keys
+ Return Me.apiTable.Keys
End Get
End Property
Public Function Remove(CommandName As String) As Boolean Implements IDictionary(Of String, EntryPoints.APIEntryPoint).Remove
- Return __API_table.Remove(CommandName)
+ Return apiTable.Remove(CommandName)
End Function
Public Function TryGetValue(key As String, ByRef value As EntryPoints.APIEntryPoint) As Boolean Implements IDictionary(Of String, EntryPoints.APIEntryPoint).TryGetValue
- Return Me.__API_table.TryGetValue(key, value)
+ Return Me.apiTable.TryGetValue(key, value)
End Function
'''
@@ -767,7 +697,7 @@ Namespace CommandLine
'''
Public ReadOnly Property APIList As ICollection(Of EntryPoints.APIEntryPoint) Implements IDictionary(Of String, EntryPoints.APIEntryPoint).Values
Get
- Return Me.__API_table.Values
+ Return Me.apiTable.Values
End Get
End Property
#End Region
diff --git a/CommandLine/Interpreters/View/CommandHelp.vb b/CommandLine/Interpreters/View/CommandHelp.vb
index 7e25e310..b9e11072 100644
--- a/CommandLine/Interpreters/View/CommandHelp.vb
+++ b/CommandLine/Interpreters/View/CommandHelp.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7d15e03f189cfb4385a3670b0c012f3f, CommandLine\Interpreters\View\CommandHelp.vb"
+#Region "Microsoft.VisualBasic::9ab9d9fc38a7984d3704413ecb4369dd, Microsoft.VisualBasic.Core\CommandLine\Interpreters\View\CommandHelp.vb"
' Author:
'
@@ -54,8 +54,8 @@ Namespace CommandLine.ManView
Public Function PrintCommandHelp(app As Interpreter, commandName$) As Integer
Dim name As New Value(Of String)
- If app.__API_table.ContainsKey(name = commandName.ToLower) Then
- Call app.__API_table(name).PrintHelp
+ If app.apiTable.ContainsKey(name = commandName.ToLower) Then
+ Call app.apiTable(name).PrintHelp
Else
Dim list$() = app.ListingRelated(commandName)
@@ -91,13 +91,13 @@ Namespace CommandLine.ManView
msg$ = .ByRef & New String(" "c, maxLength - .Length + 3)
- With app.__API_table(.ToLower).Info
+ With app.apiTable(.ToLower).Info
If Not .StringEmpty Then
msg$ &= Mid(.ByRef, 1, 60) & "..."
End If
End With
- Call Console.WriteLine(" " & msg)
+ Call My.Log4VB.Println(" " & msg, ConsoleColor.DarkBlue, ConsoleColor.DarkMagenta)
End With
Next
End Sub
diff --git a/CommandLine/Interpreters/View/ExceptionHandler.vb b/CommandLine/Interpreters/View/ExceptionHandler.vb
index ecd4f92c..fd118fac 100644
--- a/CommandLine/Interpreters/View/ExceptionHandler.vb
+++ b/CommandLine/Interpreters/View/ExceptionHandler.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f9bd4ed1ebd97efa821f0d22538001dd, CommandLine\Interpreters\View\ExceptionHandler.vb"
+#Region "Microsoft.VisualBasic::f9bd4ed1ebd97efa821f0d22538001dd, Microsoft.VisualBasic.Core\CommandLine\Interpreters\View\ExceptionHandler.vb"
' Author:
'
diff --git a/CommandLine/Interpreters/View/ManualBuilder.vb b/CommandLine/Interpreters/View/ManualBuilder.vb
index 0b911640..2003f05e 100644
--- a/CommandLine/Interpreters/View/ManualBuilder.vb
+++ b/CommandLine/Interpreters/View/ManualBuilder.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f32829cd8ec40319d48da8c0ab0411dd, CommandLine\Interpreters\View\ManualBuilder.vb"
+#Region "Microsoft.VisualBasic::dc32204e0965efc9b065ce0270d0b93a, Microsoft.VisualBasic.Core\CommandLine\Interpreters\View\ManualBuilder.vb"
' Author:
'
@@ -46,7 +46,6 @@ Imports Microsoft.VisualBasic.ApplicationServices
Imports Microsoft.VisualBasic.ApplicationServices.Terminal
Imports Microsoft.VisualBasic.CommandLine.Reflection
Imports Microsoft.VisualBasic.CommandLine.Reflection.EntryPoints
-Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Text
@@ -80,7 +79,8 @@ Namespace CommandLine.ManView
' print API name and description
Call Console.WriteLine()
- Call Console.WriteLine($" '{api.Name}' - {infoLines.FirstOrDefault}")
+ Call Console.Write(" ")
+ Call My.Log4VB.Println($"'{api.Name}' - {infoLines.FirstOrDefault}", ConsoleColor.Yellow, ConsoleColor.DarkBlue)
If infoLines.Length > 1 Then
blank = New String(
@@ -102,21 +102,41 @@ Namespace CommandLine.ManView
Call Console.WriteLine($"Usage:")
Call Console.WriteLine()
- Console.ForegroundColor = ConsoleColor.Cyan
+ Dim AppPath$
+
+ If App.Platform = PlatformID.Unix OrElse App.Platform = PlatformID.MacOSX Then
+ AppPath = App.ExecutablePath.TrimSuffix
+ Else
+ AppPath = App.ExecutablePath
+ End If
Call Console.Write(" ")
- Call Console.Write(
- If(App.Platform = PlatformID.Unix OrElse
- App.Platform = PlatformID.MacOSX,
- App.ExecutablePath.TrimSuffix,
- App.ExecutablePath) & " ")
-
- Console.ForegroundColor = ConsoleColor.Green
- Call Console.WriteLine(api.Usage)
- Console.ForegroundColor = .ByRef
+ Call My.Log4VB.Print(AppPath, ConsoleColor.DarkCyan)
+ Call Console.Write(" ")
+ Call My.Log4VB.Println(api.Usage, ConsoleColor.Green)
End With
+ Dim outputMarks = api.EntryPoint _
+ .GetCustomAttributes(True) _
+ .Where(Function(a) a.GetType Is GetType(OutputAttribute)) _
+ .Select(Function(out) DirectCast(out, OutputAttribute)) _
+ .ToArray
+
+ If Not outputMarks.IsNullOrEmpty Then
+ Call Console.WriteLine()
+ Call Console.WriteLine(" This command produce these data files:")
+ Call Console.WriteLine(" ====================================================")
+ Call Console.WriteLine()
+
+ Call outputMarks _
+ .Select(Function(o)
+ Dim desc = o.extension.GetMIMEDescrib
+ Return {desc.FileExt, desc.MIMEType, desc.Name, o.result.FullName}
+ End Function) _
+ .PrintTable(App.StdOut)
+ End If
+
If Not api.Arguments.IsNullOrEmpty Then
Call Console.WriteLine()
Call Console.WriteLine(" Command with arguments:")
@@ -146,7 +166,9 @@ Namespace CommandLine.ManView
If .TokenType = CLITypes.Boolean Then
' 逻辑值类型的只能够是可选类型
- s = "(optional) (boolean)"
+ ' 逻辑开关不计算在内
+ ' s = "(optional) (boolean)"
+ s = ""
bool = True
Else
@@ -197,8 +219,7 @@ Namespace CommandLine.ManView
Dim skipOptionalLine As Boolean = False
' 必须的参数放在前面,可选的参数都是在后面的位置
- For Each param As Argument In api.Arguments.Select(Function(x) x.Value)
-
+ For Each param As Argument In api.Arguments.Select(Function(a) a.Value)
If param.TokenType = CLITypes.Boolean AndAlso Not boolSeperator Then
boolSeperator = True
@@ -256,7 +277,8 @@ Namespace CommandLine.ManView
End If
' 这里的blank调整的是命令开关名称与描述之间的字符间距
- blank = New String(" "c, helpOffset - l + 2)
+ l = helpOffset - l + 2
+ blank = If(l > 0, New String(" "c, l), " ")
infoLines$ = param.Description _
.LineTokens _
.Select(Function(str) str.Trim(" "c, ASCII.TAB)) _
@@ -284,6 +306,11 @@ Namespace CommandLine.ManView
If std_in OrElse std_out OrElse bool Then
Call Console.WriteLine()
+ Call Console.WriteLine()
+ Call Console.WriteLine()
+ Call Console.WriteLine(" [Annotations]")
+ Call Console.WriteLine(" " & New String("-"c, 52))
+ Call Console.WriteLine()
End If
If std_in Then
diff --git a/CommandLine/Interpreters/View/SDKManual.vb b/CommandLine/Interpreters/View/SDKManual.vb
index 111369ed..0004a23b 100644
--- a/CommandLine/Interpreters/View/SDKManual.vb
+++ b/CommandLine/Interpreters/View/SDKManual.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fc6979b4b647ec8a171f444056ce9403, CommandLine\Interpreters\View\SDKManual.vb"
+#Region "Microsoft.VisualBasic::d1a21000559db76fee5e46129eaf6664, Microsoft.VisualBasic.Core\CommandLine\Interpreters\View\SDKManual.vb"
' Author:
'
@@ -35,11 +35,14 @@
'
' Function: HelpSummary, LaunchManual, MarkdownDoc
'
+ ' Sub: AppSummary
+ '
'
' /********************************************************************************/
#End Region
+Imports System.IO
Imports System.Runtime.CompilerServices
Imports System.Text
Imports Microsoft.VisualBasic.ApplicationServices.Debugging
@@ -183,6 +186,47 @@ Namespace CommandLine.ManView
Return sb.ToString
End Function
+ '''
+ '''
+ '''
+ '''
+ ''' 命令行的使用功能描述信息文本
+ ''' 命令行的使用语法
+ '''
+
+ Public Sub AppSummary(assem As AssemblyInfo, description$, SYNOPSIS$, write As TextWriter)
+ Dim descr = assem.AssemblyDescription
+
+ Call write.WriteLine()
+
+ Call write.WriteLine(" // ")
+ Call write.WriteLine(" // " & Strings.Trim(descr) Or "[No description]".AsDefault)
+ Call write.WriteLine(" // ")
+ Call write.WriteLine(" // VERSION: " & (assem.AssemblyVersion Or "1.0.0.*".AsDefault))
+ Call write.WriteLine(" // ASSEMBLY: " & assem.AssemblyFullName)
+ Call write.WriteLine(" // COPYRIGHT: " & assem.AssemblyCopyright)
+ Call write.WriteLine(" // GUID: " & assem.Guid)
+ Call write.WriteLine(" // BUILT: " & assem.BuiltTime.ToString)
+ Call write.WriteLine(" // ")
+
+ Call write.WriteLine()
+ Call write.WriteLine()
+
+ For Each line$ In Paragraph.SplitParagraph(description, 110)
+ Call write.WriteLine(" " & line$)
+ Next
+
+ If Not SYNOPSIS.StringEmpty Then
+ Call write.WriteLine()
+ Call write.WriteLine()
+ Call write.WriteLine("SYNOPSIS")
+ Call write.WriteLine(SYNOPSIS)
+ Call write.WriteLine()
+ End If
+
+ Call write.Flush()
+ End Sub
+
'''
''' Returns the summary brief help information of all of the commands in current cli interpreter.
''' (枚举出本CLI解释器之中的所有的命令的帮助的摘要信息)
@@ -198,30 +242,14 @@ Namespace CommandLine.ManView
.Max
If Not markdown Then
- Dim descr = VBCore.Info.AssemblyDescription
-
- Call sb.AppendLine()
-
- Call sb.AppendLine(" // ")
- Call sb.AppendLine(" // " & Strings.Trim(descr))
- Call sb.AppendLine(" // ")
- Call sb.AppendLine(" // VERSION: " & (VBCore.Info.AssemblyVersion Or "1.0.0.*".AsDefault))
- Call sb.AppendLine(" // COPYRIGHT: " & VBCore.Info.AssemblyCopyright)
- Call sb.AppendLine(" // GUID: " & VBCore.Info.Guid)
- Call sb.AppendLine(" // ")
-
- Call sb.AppendLine()
- Call sb.AppendLine()
-
- For Each line$ In Paragraph.SplitParagraph(App.Info.Description, 110)
- Call sb.AppendLine(" " & line$)
- Next
-
- Call sb.AppendLine()
- Call sb.AppendLine()
- Call sb.AppendLine("SYNOPSIS")
- Call sb.AppendLine($"{VBCore.AssemblyName} command [/argument argument-value...] [/@set environment-variable=value...]")
- Call sb.AppendLine()
+ Call ($"{VBCore.AssemblyName} command [/argument argument-value...] [/@set environment-variable=value...]") _
+ .DoCall(Sub(SYNOPSIS)
+ Call VBCore.Info.AppSummary(
+ description:=App.Info.Description,
+ SYNOPSIS:=SYNOPSIS,
+ write:=New StringWriter(sb)
+ )
+ End Sub)
End If
Call sb.AppendLine(ListAllCommandsPrompt)
diff --git a/CommandLine/Parsers/CLIParser.vb b/CommandLine/Parsers/CLIParser.vb
index e69514af..1a5d3fbc 100644
--- a/CommandLine/Parsers/CLIParser.vb
+++ b/CommandLine/Parsers/CLIParser.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::03039aa4ca689de63604b6c9fbe15425, CommandLine\Parsers\CLIParser.vb"
+#Region "Microsoft.VisualBasic::03039aa4ca689de63604b6c9fbe15425, Microsoft.VisualBasic.Core\CommandLine\Parsers\CLIParser.vb"
' Author:
'
diff --git a/CommandLine/Parsers/DictionaryParser.vb b/CommandLine/Parsers/DictionaryParser.vb
index 3798c8b3..08eeabeb 100644
--- a/CommandLine/Parsers/DictionaryParser.vb
+++ b/CommandLine/Parsers/DictionaryParser.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ea86ff9e843facd124b362478be0bb71, CommandLine\Parsers\DictionaryParser.vb"
+#Region "Microsoft.VisualBasic::f332dc69aefd68863b03f3edc856ddbd, Microsoft.VisualBasic.Core\CommandLine\Parsers\DictionaryParser.vb"
' Author:
'
@@ -96,8 +96,7 @@ Namespace CommandLine.Parsers
For Each var$ In t
Dim value = var.GetTagValue("="c)
- out(value.Name) =
- value.Value.GetString("'")
+ out(value.Name) = value.Value.GetString("'")
Next
Return out
diff --git a/CommandLine/Reflection/ArgumentCollection.vb b/CommandLine/Reflection/ArgumentCollection.vb
index aed22e3e..77f51b4a 100644
--- a/CommandLine/Reflection/ArgumentCollection.vb
+++ b/CommandLine/Reflection/ArgumentCollection.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::14e8ab7aecc38938a464dedd78d060c3, CommandLine\Reflection\ArgumentCollection.vb"
+#Region "Microsoft.VisualBasic::14e8ab7aecc38938a464dedd78d060c3, Microsoft.VisualBasic.Core\CommandLine\Reflection\ArgumentCollection.vb"
' Author:
'
diff --git a/CommandLine/Reflection/Attributes/ActiveViews.vb b/CommandLine/Reflection/Attributes/ActiveViews.vb
index e7e35257..003167a9 100644
--- a/CommandLine/Reflection/Attributes/ActiveViews.vb
+++ b/CommandLine/Reflection/Attributes/ActiveViews.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e61dd6f3ed4c08397368f16e7769142f, CommandLine\Reflection\Attributes\ActiveViews.vb"
+#Region "Microsoft.VisualBasic::e61dd6f3ed4c08397368f16e7769142f, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\ActiveViews.vb"
' Author:
'
diff --git a/CommandLine/Reflection/Attributes/Argument.vb b/CommandLine/Reflection/Attributes/Argument.vb
index f2df4b26..beed1c32 100644
--- a/CommandLine/Reflection/Attributes/Argument.vb
+++ b/CommandLine/Reflection/Attributes/Argument.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::75f8ae1bb23daaa167294cbe5d4d92fc, CommandLine\Reflection\Attributes\Argument.vb"
+#Region "Microsoft.VisualBasic::64214d9aa13eb893c9ab261d3880468b, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\Argument.vb"
' Author:
'
@@ -39,6 +39,12 @@
' Constructor: (+1 Overloads) Sub New
' Function: ToString
'
+ ' Class OutputAttribute
+ '
+ ' Properties: extension, result
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
'
' /********************************************************************************/
@@ -206,4 +212,21 @@ Namespace CommandLine.Reflection
Return sb.ToString
End Function
End Class
+
+
+ Public Class OutputAttribute : Inherits Attribute
+
+ Public ReadOnly Property result As Type
+ '''
+ ''' The file extension name, like ``*.csv``
+ '''
+ '''
+ Public ReadOnly Property extension As String
+
+ Sub New(resultType As Type, fileExt$)
+ result = resultType
+ extension = fileExt
+ End Sub
+
+ End Class
End Namespace
diff --git a/CommandLine/Reflection/Attributes/Attribute.vb b/CommandLine/Reflection/Attributes/Attribute.vb
index c1cb0944..2216bc5b 100644
--- a/CommandLine/Reflection/Attributes/Attribute.vb
+++ b/CommandLine/Reflection/Attributes/Attribute.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::14ab68a159339eca4da9b94e67cc896d, CommandLine\Reflection\Attributes\Attribute.vb"
+#Region "Microsoft.VisualBasic::6c99645dbbe3d3bf19078771fb9f1c88, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\Attribute.vb"
' Author:
'
@@ -45,11 +45,19 @@
' Constructor: (+1 Overloads) Sub New
' Function: ToString
'
+ ' Class NoteAttribute
+ '
+ ' Properties: noteText
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
'
' /********************************************************************************/
#End Region
+Imports System.ComponentModel
+
Namespace CommandLine.Reflection
@@ -79,4 +87,22 @@ Namespace CommandLine.Reflection
Return ExampleInfo
End Function
End Class
+
+ '''
+ ''' 这个自定义属性与的使用类似
+ ''' 只不过是针对命令的简单说明
+ ''' 以及描述
+ '''
+ ''' 这个自定义属性是针对命令内的某些注意事项的更加详细的描述,默认是不显示的
+ ''' 会在man模式下被显示出来
+ '''
+
+ Public Class NoteAttribute : Inherits Attribute
+
+ Public ReadOnly Property noteText As String
+
+ Sub New(note As String)
+ Me.noteText = note
+ End Sub
+ End Class
End Namespace
diff --git a/CommandLine/Reflection/Attributes/ExportAPI.vb b/CommandLine/Reflection/Attributes/ExportAPI.vb
index 771d37b6..d6024057 100644
--- a/CommandLine/Reflection/Attributes/ExportAPI.vb
+++ b/CommandLine/Reflection/Attributes/ExportAPI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fb69fc76f81f00cb04dcaaab9410eb37, CommandLine\Reflection\Attributes\ExportAPI.vb"
+#Region "Microsoft.VisualBasic::624394559d1f26443f64cf6789fd5ebb, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\ExportAPI.vb"
' Author:
'
@@ -103,14 +103,14 @@ Namespace CommandLine.Reflection
'''
'''
'''
- Public Property Info As String Implements IExportAPI.Info
+ Public Property Info As String Implements IExportAPI.Info
'''
''' The usage of this command.(这个命令的用法,本属性仅仅是一个助记符,当用户没有编写任何的使用方法信息的时候才会使用本属性的值)
'''
'''
'''
'''
- Public Property Usage As String Implements IExportAPI.Usage
+ Public Property Usage As String Implements IExportAPI.Usage
'''
''' A example that to useing this command.
''' (对这个命令的使用示例,本属性仅仅是一个助记符,当用户没有编写任何示例信息的时候才会使用本属性的值,
@@ -119,7 +119,7 @@ Namespace CommandLine.Reflection
'''
'''
'''
- Public Property Example As String Implements IExportAPI.Example
+ Public Property Example As String Implements IExportAPI.Example
'''
''' You are going to define a available export api for you application to another language or scripting program environment.
diff --git a/CommandLine/Reflection/Attributes/Flags.vb b/CommandLine/Reflection/Attributes/Flags.vb
index c54ccaee..69dc066a 100644
--- a/CommandLine/Reflection/Attributes/Flags.vb
+++ b/CommandLine/Reflection/Attributes/Flags.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e6ec7bef4c88e217265d0a358da1fd20, CommandLine\Reflection\Attributes\Flags.vb"
+#Region "Microsoft.VisualBasic::e6ec7bef4c88e217265d0a358da1fd20, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\Flags.vb"
' Author:
'
diff --git a/CommandLine/Reflection/Attributes/Grouping.vb b/CommandLine/Reflection/Attributes/Grouping.vb
index 17f8712c..23d25d68 100644
--- a/CommandLine/Reflection/Attributes/Grouping.vb
+++ b/CommandLine/Reflection/Attributes/Grouping.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e5a222b781d498a1d810a60f4396b7ea, CommandLine\Reflection\Attributes\Grouping.vb"
+#Region "Microsoft.VisualBasic::e5a222b781d498a1d810a60f4396b7ea, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\Grouping.vb"
' Author:
'
diff --git a/CommandLine/Reflection/Attributes/[Namespace].vb b/CommandLine/Reflection/Attributes/[Namespace].vb
index dff29133..e5ec3768 100644
--- a/CommandLine/Reflection/Attributes/[Namespace].vb
+++ b/CommandLine/Reflection/Attributes/[Namespace].vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::55234b4e078ecfd7de610386fc031c73, CommandLine\Reflection\Attributes\[Namespace].vb"
+#Region "Microsoft.VisualBasic::55234b4e078ecfd7de610386fc031c73, Microsoft.VisualBasic.Core\CommandLine\Reflection\Attributes\[Namespace].vb"
' Author:
'
diff --git a/CommandLine/Reflection/CLIToken.vb b/CommandLine/Reflection/CLIToken.vb
index 4aec0a90..8cbb4b5c 100644
--- a/CommandLine/Reflection/CLIToken.vb
+++ b/CommandLine/Reflection/CLIToken.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dc7e39b244447c07223488c5089fa330, CommandLine\Reflection\CLIToken.vb"
+#Region "Microsoft.VisualBasic::dc7e39b244447c07223488c5089fa330, Microsoft.VisualBasic.Core\CommandLine\Reflection\CLIToken.vb"
' Author:
'
diff --git a/CommandLine/Reflection/CLITypes.vb b/CommandLine/Reflection/CLITypes.vb
index 2cba52ca..8024d58a 100644
--- a/CommandLine/Reflection/CLITypes.vb
+++ b/CommandLine/Reflection/CLITypes.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2fc1db2e6208fb90a99353505f436fe9, CommandLine\Reflection\CLITypes.vb"
+#Region "Microsoft.VisualBasic::2fc1db2e6208fb90a99353505f436fe9, Microsoft.VisualBasic.Core\CommandLine\Reflection\CLITypes.vb"
' Author:
'
diff --git a/CommandLine/Reflection/EntryPoints/APIEntryPoint.vb b/CommandLine/Reflection/EntryPoints/APIEntryPoint.vb
index b3973af3..51384405 100644
--- a/CommandLine/Reflection/EntryPoints/APIEntryPoint.vb
+++ b/CommandLine/Reflection/EntryPoints/APIEntryPoint.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a96cb85fcf17d0101fbb7e187ce62576, CommandLine\Reflection\EntryPoints\APIEntryPoint.vb"
+#Region "Microsoft.VisualBasic::10a0fc85496398c6ac5f6a1be9eb7bf6, Microsoft.VisualBasic.Core\CommandLine\Reflection\EntryPoints\APIEntryPoint.vb"
' Author:
'
@@ -187,6 +187,14 @@ Namespace CommandLine.Reflection.EntryPoints
End If
End If
+ Dim note As NoteAttribute = EntryPoint.GetCustomAttribute(Of NoteAttribute)
+
+ If Not note Is Nothing Then
+ Call sb.AppendLine()
+ Call sb.AppendLine("Author Comment About This Command:")
+ Call sb.AppendLine(note.noteText)
+ End If
+
Return sb.ToString
End Function
diff --git a/CommandLine/Reflection/EntryPoints/Delegate.vb b/CommandLine/Reflection/EntryPoints/Delegate.vb
index fa07b001..3f2a258d 100644
--- a/CommandLine/Reflection/EntryPoints/Delegate.vb
+++ b/CommandLine/Reflection/EntryPoints/Delegate.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::981cb8a14cca84134672790ab4bb046f, CommandLine\Reflection\EntryPoints\Delegate.vb"
+#Region "Microsoft.VisualBasic::981cb8a14cca84134672790ab4bb046f, Microsoft.VisualBasic.Core\CommandLine\Reflection\EntryPoints\Delegate.vb"
' Author:
'
diff --git a/CommandLine/Reflection/Grouping.vb b/CommandLine/Reflection/Grouping.vb
index 14ebef1a..3ce00637 100644
--- a/CommandLine/Reflection/Grouping.vb
+++ b/CommandLine/Reflection/Grouping.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9b8ec8a564ea48316af97c0e2daa02e6, CommandLine\Reflection\Grouping.vb"
+#Region "Microsoft.VisualBasic::9b8ec8a564ea48316af97c0e2daa02e6, Microsoft.VisualBasic.Core\CommandLine\Reflection\Grouping.vb"
' Author:
'
diff --git a/CommandLine/Reflection/RunDll.vb b/CommandLine/Reflection/RunDll.vb
index 28862114..6b005eb2 100644
--- a/CommandLine/Reflection/RunDll.vb
+++ b/CommandLine/Reflection/RunDll.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e89d959e6a8a1b5bfde7cb4d9886656c, CommandLine\Reflection\RunDll.vb"
+#Region "Microsoft.VisualBasic::e89d959e6a8a1b5bfde7cb4d9886656c, Microsoft.VisualBasic.Core\CommandLine\Reflection\RunDll.vb"
' Author:
'
diff --git a/CommandLine/Stream.vb b/CommandLine/Stream.vb
index 0a475e5b..c6102053 100644
--- a/CommandLine/Stream.vb
+++ b/CommandLine/Stream.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f7090379a93984ecee32ecbba064de75, CommandLine\Stream.vb"
+#Region "Microsoft.VisualBasic::1d29d822507b18e368473917fe944414, Microsoft.VisualBasic.Core\CommandLine\Stream.vb"
' Author:
'
@@ -65,7 +65,7 @@ Namespace CommandLine
''' + standard output: std_out://
''' + memory mapping file: memory://file/uri
'''
- Public Module StreamExtensions
+ Public Module StreamExtensions
Public Function FileType(reference As String) As FileTypes
If reference.TextEquals("std_in://") OrElse reference.TextEquals("std_out://") Then
@@ -77,27 +77,64 @@ Namespace CommandLine
End If
End Function
+ '''
+ ''' 一个用于通用化的打开数据流读取对象的函数
+ '''
+ '''
+ '''
Public Function OpenForRead(reference As String) As Stream
If reference.TextEquals("std_in://") Then
Return Console.OpenStandardInput
ElseIf reference.TextEquals("std_out://") Then
Throw New InvalidProgramException()
ElseIf reference.ToLower.StartsWith("memory://") Then
+ Dim view As Stream
+
reference = reference.GetTagValue(":/").Value
- Return MemoryMappedFile.OpenExisting(reference).CreateViewStream
+ view = MemoryMappedFile.OpenExisting(reference).CreateViewStream
+ view.Seek(Scan0, SeekOrigin.Begin)
+
+ Return view
Else
Return New FileStream(reference, FileMode.Open, access:=FileAccess.Read, share:=FileShare.ReadWrite)
End If
End Function
- Public Function OpenForWrite(reference As String, Optional size& = 1024 * 1024 * 1024) As Stream
+ '''
+ ''' 请注意,这个函数在创建内存映射文件的时候,默认是0.5GB大小的
+ '''
+ '''
+ '''
+ '''
+ Public Function OpenForWrite(reference As String, Optional size& = 512 * 1024 * 1024) As Stream
If reference.TextEquals("std_in://") Then
Throw New InvalidProgramException
ElseIf reference.TextEquals("std_out://") Then
Return Console.OpenStandardOutput
ElseIf reference.ToLower.StartsWith("memory://") Then
+ Dim view As Stream
+ 'Dim security As New MemoryMappedFileSecurity()
+ 'Dim userName$ = "everyone"
+
+ 'If Not App.IsMicrosoftPlatform Then
+ ' ' 20190724 linux平台上很有可能不存在"everyone"这个账户角色
+ ' userName = Environment.UserName
+ 'End If
+
+ ' Security.AddAccessRule(New AccessRule(Of MemoryMappedFileRights)(userName, MemoryMappedFileRights.FullControl, AccessControlType.Allow))
reference = reference.GetTagValue(":/").Value
- Return MemoryMappedFile.CreateOrOpen(reference, size).CreateViewStream
+ view = MemoryMappedFile.CreateOrOpen(reference, size, MemoryMappedFileAccess.ReadWrite).CreateViewStream
+ 'view = MemoryMappedFile.CreateOrOpen(
+ ' reference, size,
+ ' access:=MemoryMappedFileAccess.ReadWrite,
+ ' options:=MemoryMappedFileOptions.DelayAllocatePages,
+ ' memoryMappedFileSecurity:=security,
+ ' inheritability:=HandleInheritability.Inheritable
+ ').CreateViewStream
+
+ Call view.Seek(Scan0, SeekOrigin.Begin)
+
+ Return view
Else
Return New FileStream(reference, FileMode.OpenOrCreate, access:=FileAccess.Write, share:=FileShare.Read)
End If
diff --git a/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLClusterTree.vb b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLClusterTree.vb
new file mode 100644
index 00000000..8319c2d7
--- /dev/null
+++ b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLClusterTree.vb
@@ -0,0 +1,193 @@
+#Region "Microsoft.VisualBasic::eb6950d0324c575c9e727f0a29e12344, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\AVLTree\AVLClusterTree.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Enum ComparisonDirectionPrefers
+ '
+ ' Left, Right
+ '
+ '
+ '
+ '
+ '
+ ' Class ClusterKey
+ '
+ ' Properties: NumberOfKey
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
+ ' Function: DoComparison, ToString
+ '
+ ' Sub: Add
+ '
+ ' Class AVLClusterTree
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
+ ' Function: doCompares, GetEnumerator, IEnumerable_GetEnumerator
+ '
+ ' Sub: Add, Clear
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Runtime.CompilerServices
+Imports Microsoft.VisualBasic.Language
+
+Namespace ComponentModel.Algorithm.BinaryTree
+
+ Public Enum ComparisonDirectionPrefers
+ Left
+ Right
+ End Enum
+
+ Public Class ClusterKey(Of K)
+
+ ReadOnly members As New List(Of K)
+ ReadOnly views As Func(Of K, String)
+
+ Public ReadOnly Property NumberOfKey As Integer
+ Get
+ Return members.Count
+ End Get
+ End Property
+
+ Default Public ReadOnly Property Item(index As Integer) As K
+ Get
+ Return members(index)
+ End Get
+ End Property
+
+ Sub New([single] As K, views As Func(Of K, String))
+ Me.views = views
+
+ ' Add a initial single member object
+ Call members.Add([single])
+ End Sub
+
+
+ Public Sub Add(newMember As K)
+ Call members.Add(newMember)
+ End Sub
+
+ Public Overrides Function ToString() As String
+ If members.Count = 1 Then
+ Return views(members(Scan0))
+ Else
+ Return views(members(Scan0)) & $", and with {members.Count} cluster members.."
+ End If
+ End Function
+
+ '''
+ ''' 在这里应该是多个key比较一个query
+ '''
+ '''
+ '''
+ Public Shared Function DoComparison(compares As Comparison(Of K), prefer As ComparisonDirectionPrefers) As Func(Of ClusterKey(Of K), K, Integer)
+ Return Function(cluster, key) As Integer
+ Dim compareVal As Value(Of Integer) = -100
+ Dim left As Boolean = False
+ Dim right As Boolean
+
+ For Each index As K In cluster.members
+ If (compareVal = compares(index, key)) = 0 Then
+ Return 0
+ Else
+ If compareVal.Equals(1) Then
+ right = True
+ Else
+ left = True
+ End If
+ End If
+ Next
+
+ If prefer = ComparisonDirectionPrefers.Left Then
+ If left Then
+ Return -1
+ Else
+ Return 1
+ End If
+ Else
+ If right Then
+ Return 1
+ Else
+ Return -1
+ End If
+ End If
+ End Function
+ End Function
+ End Class
+
+ Public Class AVLClusterTree(Of K) : Implements IEnumerable(Of ClusterKey(Of K))
+
+ ReadOnly avltree As AVLTree(Of ClusterKey(Of K), K)
+ ReadOnly views As Func(Of K, String)
+
+ Sub New(compares As Comparison(Of K),
+ Optional views As Func(Of K, String) = Nothing,
+ Optional prefer As ComparisonDirectionPrefers = ComparisonDirectionPrefers.Left)
+
+ Me.views = views
+ Me.avltree = New AVLTree(Of ClusterKey(Of K), K)(doCompares(compares, prefer), Function(c) c.ToString)
+ End Sub
+
+ Private Shared Function doCompares(compares As Comparison(Of K), prefer As ComparisonDirectionPrefers) As Comparison(Of ClusterKey(Of K))
+ Dim unsymmetricalCompares = ClusterKey(Of K).DoComparison(compares, prefer)
+
+ ' 在AVL数据模块中,比较代码中,待插入的key都是放在左边,即X参数部分
+ Return Function(x, y)
+ Return unsymmetricalCompares(y, x(Scan0))
+ End Function
+ End Function
+
+
+ Public Sub Add(key As K)
+ Call avltree.Add(New ClusterKey(Of K)(key, views), key, Sub(node, null) node.Key.Add(key))
+ End Sub
+
+ Public Sub Clear()
+ Call avltree.Clear()
+ End Sub
+
+ Public Iterator Function GetEnumerator() As IEnumerator(Of ClusterKey(Of K)) Implements IEnumerable(Of ClusterKey(Of K)).GetEnumerator
+ For Each cluster In avltree.root.PopulateNodes
+ Yield cluster.Key
+ Next
+ End Function
+
+ Private Iterator Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
+ Yield GetEnumerator()
+ End Function
+ End Class
+End Namespace
diff --git a/ComponentModel/Algorithm/BinaryTree/AVLSupports.vb b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLSupports.vb
similarity index 97%
rename from ComponentModel/Algorithm/BinaryTree/AVLSupports.vb
rename to ComponentModel/Algorithm/BinaryTree/AVLTree/AVLSupports.vb
index 9feb08e3..f381ccf6 100644
--- a/ComponentModel/Algorithm/BinaryTree/AVLSupports.vb
+++ b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLSupports.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fa8b3cc7757e3eebf57da0d645f14bb2, ComponentModel\Algorithm\BinaryTree\AVLSupports.vb"
+#Region "Microsoft.VisualBasic::fa8b3cc7757e3eebf57da0d645f14bb2, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\AVLTree\AVLSupports.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/AVLTree.vb b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLTree.vb
similarity index 82%
rename from ComponentModel/Algorithm/BinaryTree/AVLTree.vb
rename to ComponentModel/Algorithm/BinaryTree/AVLTree/AVLTree.vb
index 4aaa308d..89ffe52f 100644
--- a/ComponentModel/Algorithm/BinaryTree/AVLTree.vb
+++ b/ComponentModel/Algorithm/BinaryTree/AVLTree/AVLTree.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::81eec77cd0117693bed3fa2054025986, ComponentModel\Algorithm\BinaryTree\AVLTree.vb"
+#Region "Microsoft.VisualBasic::ae2cef48d9685292786c693e33d68e7c, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\AVLTree\AVLTree.vb"
' Author:
'
@@ -31,16 +31,20 @@
' Summaries:
+ ' Delegate Sub
+ '
+ '
' Class AVLTree
'
' Constructor: (+2 Overloads) Sub New
'
' Function: Add, Find, Remove
'
- ' Sub: Add, appendLeft, appendRight, Remove, removeCurrent
+ ' Sub: (+2 Overloads) Add, appendLeft, appendRight, Remove, removeCurrent
' removeLeft, removeRight
'
'
+ '
' /********************************************************************************/
#End Region
@@ -49,6 +53,8 @@ Imports System.Runtime.CompilerServices
Namespace ComponentModel.Algorithm.BinaryTree
+ Public Delegate Sub DuplicatedKeyHandler(Of K, V)(keyNode As BinaryTree(Of K, V), newValue As V)
+
'''
''' The AVL binary tree operator.
'''
@@ -80,24 +86,31 @@ Namespace ComponentModel.Algorithm.BinaryTree
Public Sub Add(key As K, value As V, Optional valueReplace As Boolean = True)
- _root = Add(key, value, _root, valueReplace)
+ _root = Add(key, value, _root, Sub(node, newValue)
+ If valueReplace Then
+ node.Value = newValue
+ End If
+ End Sub)
End Sub
- Public Function Add(key As K, value As V, tree As BinaryTree(Of K, V), valueReplace As Boolean) As BinaryTree(Of K, V)
+
+ Public Sub Add(key As K, value As V, handleDuplicated As DuplicatedKeyHandler(Of K, V))
+ _root = Add(key, value, _root, handleDuplicated)
+ End Sub
+
+ Private Function Add(key As K, value As V, tree As BinaryTree(Of K, V), handleDuplicatedKey As DuplicatedKeyHandler(Of K, V)) As BinaryTree(Of K, V)
If tree Is Nothing Then
' 追加新的叶子节点
tree = New BinaryTree(Of K, V)(key, value, Nothing, views)
stack.Add(tree)
Else
Select Case compares(key, tree.Key)
- Case < 0 : Call appendLeft(tree, key, value, valueReplace)
- Case > 0 : Call appendRight(tree, key, value, valueReplace)
+ Case < 0 : Call appendLeft(tree, key, value, handleDuplicatedKey)
+ Case > 0 : Call appendRight(tree, key, value, handleDuplicatedKey)
Case = 0
' 将value追加到附加值中(也可对应重复元素)
- If valueReplace Then
- tree.Value = value
- End If
+ Call handleDuplicatedKey(tree, value)
' 2018.3.6
' 如果是需要使用二叉树进行聚类操作,那么等于零的值可能都是同一个簇之中的
@@ -115,8 +128,8 @@ Namespace ComponentModel.Algorithm.BinaryTree
Return tree
End Function
- Private Sub appendRight(ByRef tree As BinaryTree(Of K, V), key As K, value As V, replace As Boolean)
- tree.Right = Add(key, value, tree.Right, replace)
+ Private Sub appendRight(ByRef tree As BinaryTree(Of K, V), key As K, value As V, handleDuplicatedKey As DuplicatedKeyHandler(Of K, V))
+ tree.Right = Add(key, value, tree.Right, handleDuplicatedKey)
If tree.Right.height - tree.Left.height = 2 Then
If compares(key, tree.Right.Key) > 0 Then
@@ -127,8 +140,8 @@ Namespace ComponentModel.Algorithm.BinaryTree
End If
End Sub
- Private Sub appendLeft(ByRef tree As BinaryTree(Of K, V), key As K, value As V, replace As Boolean)
- tree.Left = Add(key, value, tree.Left, replace)
+ Private Sub appendLeft(ByRef tree As BinaryTree(Of K, V), key As K, value As V, handleDuplicatedKey As DuplicatedKeyHandler(Of K, V))
+ tree.Left = Add(key, value, tree.Left, handleDuplicatedKey)
If tree.Left.height - tree.Right.height = 2 Then
If compares(key, tree.Left.Key) < 0 Then
diff --git a/ComponentModel/Algorithm/BinaryTree/BinaryTree.vb b/ComponentModel/Algorithm/BinaryTree/BinaryTree.vb
index c91c3169..77d21af7 100644
--- a/ComponentModel/Algorithm/BinaryTree/BinaryTree.vb
+++ b/ComponentModel/Algorithm/BinaryTree/BinaryTree.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::42aa90d57a9c12fb5abb3f794d617c0a, ComponentModel\Algorithm\BinaryTree\BinaryTree.vb"
+#Region "Microsoft.VisualBasic::42aa90d57a9c12fb5abb3f794d617c0a, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\BinaryTree.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/Enumerable.vb b/ComponentModel/Algorithm/BinaryTree/Enumerable.vb
index a9d0b8c1..e09c30fb 100644
--- a/ComponentModel/Algorithm/BinaryTree/Enumerable.vb
+++ b/ComponentModel/Algorithm/BinaryTree/Enumerable.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a7cb59891d0578f90f7f4ec63df91fd5, ComponentModel\Algorithm\BinaryTree\Enumerable.vb"
+#Region "Microsoft.VisualBasic::a7cb59891d0578f90f7f4ec63df91fd5, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\Enumerable.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/NaiveBinaryTree.vb b/ComponentModel/Algorithm/BinaryTree/NaiveBinaryTree.vb
index 3e7e2451..8f589236 100644
--- a/ComponentModel/Algorithm/BinaryTree/NaiveBinaryTree.vb
+++ b/ComponentModel/Algorithm/BinaryTree/NaiveBinaryTree.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1cab0da9ef50f6674ce07f1b33dad9fc, ComponentModel\Algorithm\BinaryTree\NaiveBinaryTree.vb"
+#Region "Microsoft.VisualBasic::1cab0da9ef50f6674ce07f1b33dad9fc, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\NaiveBinaryTree.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/RBTree/Iterator.vb b/ComponentModel/Algorithm/BinaryTree/RBTree/Iterator.vb
index adab5c03..93095b5c 100644
--- a/ComponentModel/Algorithm/BinaryTree/RBTree/Iterator.vb
+++ b/ComponentModel/Algorithm/BinaryTree/RBTree/Iterator.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b5d416823ceb889f45ddda51bb3399da, ComponentModel\Algorithm\BinaryTree\RBTree\Iterator.vb"
+#Region "Microsoft.VisualBasic::b5d416823ceb889f45ddda51bb3399da, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\RBTree\Iterator.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/RBTree/RBNode.vb b/ComponentModel/Algorithm/BinaryTree/RBTree/RBNode.vb
index cb20dc22..67cf1b56 100644
--- a/ComponentModel/Algorithm/BinaryTree/RBTree/RBNode.vb
+++ b/ComponentModel/Algorithm/BinaryTree/RBTree/RBNode.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9433a555ccbd8a2e99c97c7302b143e2, ComponentModel\Algorithm\BinaryTree\RBTree\RBNode.vb"
+#Region "Microsoft.VisualBasic::9433a555ccbd8a2e99c97c7302b143e2, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\RBTree\RBNode.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/RBTree/RBTree.vb b/ComponentModel/Algorithm/BinaryTree/RBTree/RBTree.vb
index 99362e96..a78ee94e 100644
--- a/ComponentModel/Algorithm/BinaryTree/RBTree/RBTree.vb
+++ b/ComponentModel/Algorithm/BinaryTree/RBTree/RBTree.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f511fd972828adb3075654c4ee2e030f, ComponentModel\Algorithm\BinaryTree\RBTree\RBTree.vb"
+#Region "Microsoft.VisualBasic::f511fd972828adb3075654c4ee2e030f, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\RBTree\RBTree.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/BinaryTree/TreeBase.vb b/ComponentModel/Algorithm/BinaryTree/TreeBase.vb
index 904bcc43..dc9c1a32 100644
--- a/ComponentModel/Algorithm/BinaryTree/TreeBase.vb
+++ b/ComponentModel/Algorithm/BinaryTree/TreeBase.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5ea4bf16488c3938884e26b6f9cf6e76, ComponentModel\Algorithm\BinaryTree\TreeBase.vb"
+#Region "Microsoft.VisualBasic::0cbb33942790924b29c741e8ceaf2528, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\TreeBase.vb"
' Author:
'
@@ -92,6 +92,10 @@ Namespace ComponentModel.Algorithm.BinaryTree
stack.Clear()
End Sub
+ '''
+ ''' 这个函数是直接返回stack list对象中的元素值
+ '''
+ '''
Public Function GetAllNodes() As IEnumerable(Of BinaryTree(Of K, V))
Return stack.AsEnumerable
diff --git a/ComponentModel/Algorithm/BinaryTree/TreeNode.vb b/ComponentModel/Algorithm/BinaryTree/TreeNode.vb
index f9aed83b..51a0f55d 100644
--- a/ComponentModel/Algorithm/BinaryTree/TreeNode.vb
+++ b/ComponentModel/Algorithm/BinaryTree/TreeNode.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5782b024c7e50936395593d1f04136dd, ComponentModel\Algorithm\BinaryTree\TreeNode.vb"
+#Region "Microsoft.VisualBasic::5782b024c7e50936395593d1f04136dd, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\BinaryTree\TreeNode.vb"
' Author:
'
@@ -135,7 +135,7 @@ Namespace ComponentModel.Algorithm.BinaryTree
'''
'''
'''
- ''' Default debug view is
+ ''' Default debug view is
Sub New(key As K, value As V,
Optional parent As BinaryTree(Of K, V) = Nothing,
Optional toString As Func(Of K, String) = Nothing)
diff --git a/ComponentModel/Algorithm/DynamicProgramming/DynamicProgramming.vb b/ComponentModel/Algorithm/DynamicProgramming/DynamicProgramming.vb
index 190b8164..00cdb9a4 100644
--- a/ComponentModel/Algorithm/DynamicProgramming/DynamicProgramming.vb
+++ b/ComponentModel/Algorithm/DynamicProgramming/DynamicProgramming.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1f506608694faa5f51d75c94347722b9, ComponentModel\Algorithm\DynamicProgramming\DynamicProgramming.vb"
+#Region "Microsoft.VisualBasic::1f506608694faa5f51d75c94347722b9, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\DynamicProgramming\DynamicProgramming.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/DynamicProgramming/LCS.vb b/ComponentModel/Algorithm/DynamicProgramming/LCS.vb
index 202c6a3c..b811f559 100644
--- a/ComponentModel/Algorithm/DynamicProgramming/LCS.vb
+++ b/ComponentModel/Algorithm/DynamicProgramming/LCS.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2d36972eb0db76a21d3c01728f21b71d, ComponentModel\Algorithm\DynamicProgramming\LCS.vb"
+#Region "Microsoft.VisualBasic::397f4575f6d432a951f7a422e85c23ee, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\DynamicProgramming\LCS.vb"
' Author:
'
@@ -33,9 +33,9 @@
' Module LongestCommonSubsequenceExtension
'
- ' Function: __equals, MaxLengthSubString, MaxSet
+ ' Function: charEquals, MaxLengthSubString, MaxSet
'
- ' Sub: __LCS
+ ' Sub: doLCSInternal
'
'
' /********************************************************************************/
@@ -59,11 +59,11 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
'''
'''
Public Function MaxLengthSubString(a As String, b As String) As String
- Return MaxSet(a.ToArray, b.ToArray, AddressOf __equals)
+ Return MaxSet(a.ToArray, b.ToArray, AddressOf charEquals)
End Function
- Private Function __equals(a As Char, b As Char) As Boolean
+ Private Function charEquals(a As Char, b As Char) As Boolean
Return a = b
End Function
@@ -91,27 +91,27 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
Dim lst As New List(Of T)
- __LCS(p, a, a.Length, b.Length, lst)
+ doLCSInternal(p, a, a.Length, b.Length, lst)
Call lst.Reverse()
Return lst.ToArray
End Function
- Private Sub __LCS(Of T)(p()() As Char, a() As T, i As Integer, j As Integer, ByRef lst As List(Of T))
+ Private Sub doLCSInternal(Of T)(p()() As Char, a() As T, i As Integer, j As Integer, ByRef lst As List(Of T))
If i = 0 OrElse j = 0 Then
Return
End If
If p(i)(j) = "-"c Then
- __LCS(p, a, i - 1, j - 1, lst)
+ doLCSInternal(p, a, i - 1, j - 1, lst)
lst += a(i - 1)
ElseIf p(i)(j) = "<"c Then
- __LCS(p, a, i - 1, j, lst)
+ doLCSInternal(p, a, i - 1, j, lst)
ElseIf p(i)(j) = ">"c Then
- __LCS(p, a, i, j - 1, lst)
+ doLCSInternal(p, a, i, j - 1, lst)
End If
End Sub
End Module
diff --git a/ComponentModel/Algorithm/DynamicProgramming/LongestCommonSubsequence.vb b/ComponentModel/Algorithm/DynamicProgramming/LongestCommonSubsequence.vb
index e2e870f2..fe857e42 100644
--- a/ComponentModel/Algorithm/DynamicProgramming/LongestCommonSubsequence.vb
+++ b/ComponentModel/Algorithm/DynamicProgramming/LongestCommonSubsequence.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1dd182cc126f1ec9add3568244450e3c, ComponentModel\Algorithm\DynamicProgramming\LongestCommonSubsequence.vb"
+#Region "Microsoft.VisualBasic::1dd182cc126f1ec9add3568244450e3c, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\DynamicProgramming\LongestCommonSubsequence.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/DynamicProgramming/SCS.vb b/ComponentModel/Algorithm/DynamicProgramming/SCS.vb
index caba5c08..dd7add15 100644
--- a/ComponentModel/Algorithm/DynamicProgramming/SCS.vb
+++ b/ComponentModel/Algorithm/DynamicProgramming/SCS.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b6f3b5144db49c530543e62920605973, ComponentModel\Algorithm\DynamicProgramming\SCS.vb"
+#Region "Microsoft.VisualBasic::1e8f96d8510319c1ec0fc9011f9b0e4f, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\DynamicProgramming\SCS.vb"
' Author:
'
@@ -109,8 +109,8 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
''' 当这个函数遇到完全没有重叠的序列片段的时候,是会直接将这个不重叠的片段接到SCS的最末尾的
'''
- Public Function ShortestCommonSuperString(Seqs As List(Of String)) As String
- Dim l As Integer = Seqs.Count
+ Public Function ShortestCommonSuperString(seqs As Generic.List(Of String)) As String
+ Dim l As Integer = seqs.Count
Do While l > 1
Dim currMax As Integer = Integer.MinValue
@@ -119,8 +119,8 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
For j As Integer = 0 To l - 1
For k As Integer = j + 1 To l - 1
- Dim str As String = Seqs(j)
- Dim b As String = Seqs(k)
+ Dim str As String = seqs(j)
+ Dim b As String = seqs(k)
If str.Contains(b) Then
If b.Length > currMax Then
@@ -139,16 +139,18 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
Else
' find max common prefix and suffix
Dim maxPrefixMatch = MaxPrefixLength(str, b)
+
If maxPrefixMatch > currMax Then
- finalStr = str + b.Substring(maxPrefixMatch)
+ finalStr = str & b.Substring(maxPrefixMatch)
currMax = maxPrefixMatch
p = j
q = k
End If
Dim maxSuffixMatch = MaxPrefixLength(b, str)
+
If maxSuffixMatch > currMax Then
- finalStr = b + str.Substring(maxSuffixMatch)
+ finalStr = b & str.Substring(maxSuffixMatch)
currMax = maxSuffixMatch
p = j
q = k
@@ -158,11 +160,11 @@ Namespace ComponentModel.Algorithm.DynamicProgramming
Next
l -= 1
- Seqs(p) = finalStr
- Seqs(q) = Seqs(l)
+ seqs(p) = finalStr
+ seqs(q) = seqs(l)
Loop
- Return Seqs.First
+ Return seqs.First
End Function
Private Function MaxPrefixLength(a As String, b As String) As Integer
diff --git a/ComponentModel/Algorithm/Levenshtein/DamerauLevenshteinDistance.vb b/ComponentModel/Algorithm/Levenshtein/DamerauLevenshteinDistance.vb
index d2bd69d8..1518d3a4 100644
--- a/ComponentModel/Algorithm/Levenshtein/DamerauLevenshteinDistance.vb
+++ b/ComponentModel/Algorithm/Levenshtein/DamerauLevenshteinDistance.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::887d8ba8c1d4a61356a14909208dca48, ComponentModel\Algorithm\Levenshtein\DamerauLevenshteinDistance.vb"
+#Region "Microsoft.VisualBasic::887d8ba8c1d4a61356a14909208dca48, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\Levenshtein\DamerauLevenshteinDistance.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/Levenshtein/LevenshteinDistance.vb b/ComponentModel/Algorithm/Levenshtein/LevenshteinDistance.vb
index 40850e23..6bbff00e 100644
--- a/ComponentModel/Algorithm/Levenshtein/LevenshteinDistance.vb
+++ b/ComponentModel/Algorithm/Levenshtein/LevenshteinDistance.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1b934dbc1d0d334500ccbc8997fed1dc, ComponentModel\Algorithm\Levenshtein\LevenshteinDistance.vb"
+#Region "Microsoft.VisualBasic::b6d0782260ba6c301e1a8969edc40cac, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\Levenshtein\LevenshteinDistance.vb"
' Author:
'
@@ -33,11 +33,11 @@
' Module LevenshteinDistance
'
- ' Function: __createTable, __int32Equals, (+2 Overloads) ComputeDistance, CreateTable, GetVisulization
+ ' Function: (+2 Overloads) ComputeDistance, createMatrix, CreateTable, GetVisulization, i32Equals
' SaveMatch
' Delegate Function
'
- ' Function: __computeRoute, (+2 Overloads) ComputeDistance, Similarity
+ ' Function: (+2 Overloads) ComputeDistance, computeRouteImpl, Similarity
'
'
'
@@ -53,7 +53,7 @@ Imports Microsoft.VisualBasic.Linq.Extensions
Imports Microsoft.VisualBasic.Net.Protocols
Imports Microsoft.VisualBasic.Scripting.MetaData
Imports Microsoft.VisualBasic.Text.Xml.Models
-Imports sys = System.Math
+Imports stdNum = System.Math
Namespace Text.Levenshtein
@@ -82,11 +82,11 @@ Vladimir I",
'''
'''
'''
- Private Function __createTable(reference As Integer(), hypotheses As Integer(), cost As Double) As Double(,)
- Return CreateTable(Of Integer)(reference, hypotheses, DynamicProgramming.Cost(Of Integer).DefaultCost(cost), AddressOf __int32Equals)
+ Private Function createMatrix(reference As Integer(), hypotheses As Integer(), cost As Double) As Double(,)
+ Return CreateTable(Of Integer)(reference, hypotheses, DynamicProgramming.Cost(Of Integer).DefaultCost(cost), AddressOf i32Equals)
End Function
- Private Function __int32Equals(a As Integer, b As Integer) As Boolean
+ Private Function i32Equals(a As Integer, b As Integer) As Boolean
Return a = b
End Function
@@ -124,10 +124,10 @@ Vladimir I",
' if the letters are same
distTable(i, j) = distTable(i - 1, j - 1)
Else ' if not add 1 to its neighborhoods and assign minumun of its neighborhoods
- Dim n As Double = sys.Min(
+ Dim n As Double = stdNum.Min(
distTable(i - 1, j - 1) + cost.substitute(reference(i - 1), hypotheses(j - 1)),
distTable(i - 1, j) + cost.delete(reference(i - 1)))
- distTable(i, j) = sys.Min(n, distTable(i, j - 1) + cost.insert(hypotheses(j - 1)))
+ distTable(i, j) = stdNum.Min(n, distTable(i, j - 1) + cost.insert(hypotheses(j - 1)))
End If
Next
Next
@@ -177,7 +177,7 @@ Vladimir I",
.Hypotheses = sHyp,
.Reference = sRef
}
- Return __computeRoute(sHyp, result, i, j, distTable)
+ Return computeRouteImpl(sHyp, result, i, j, distTable)
End Function
@@ -204,16 +204,16 @@ Vladimir I",
If hypotheses Is Nothing Then hypotheses = ""
If reference Is Nothing Then reference = New Integer() {}
- Dim distTable#(,) = __createTable(reference,
+ Dim distTable#(,) = createMatrix(reference,
hypotheses.Select(Function(ch) Asc(ch)).ToArray,
cost)
- Dim i As Integer = reference.Length,
- j As Integer = hypotheses.Length
+ Dim i As Integer = reference.Length
+ Dim j As Integer = hypotheses.Length
Dim result As New DistResult With {
.Hypotheses = hypotheses,
.Reference = Nothing
}
- Return __computeRoute(hypotheses, result, i, j, distTable)
+ Return computeRouteImpl(hypotheses, result, i, j, distTable)
End Function
Const a As Integer = Asc("a"c)
@@ -258,7 +258,7 @@ Vladimir I",
'''
'''
'''
- Private Function __computeRoute(hypotheses$,
+ Private Function computeRouteImpl(hypotheses$,
result As DistResult,
i%, j%,
distTable#(,)) As DistResult
@@ -355,18 +355,17 @@ Vladimir I",
If hypotheses Is Nothing Then hypotheses = ""
If reference Is Nothing Then reference = ""
- Dim distTable As Double(,) = __createTable(
- reference.Select(Function(ch) AscW(ch)).ToArray,
- hypotheses.Select(Function(ch) AscW(ch)).ToArray,
- cost)
- Dim i As Integer = reference.Length,
- j As Integer = hypotheses.Length
+ Dim vectorRef = reference.Select(Function(ch) AscW(ch)).ToArray
+ Dim vectorHypo = hypotheses.Select(Function(ch) AscW(ch)).ToArray
+ Dim distTable As Double(,) = createMatrix(vectorRef, vectorHypo, cost)
+ Dim i As Integer = reference.Length
+ Dim j As Integer = hypotheses.Length
Dim result As New DistResult With {
.Hypotheses = hypotheses,
.Reference = reference
}
- Return __computeRoute(hypotheses, result, i, j, distTable)
+ Return computeRouteImpl(hypotheses, result, i, j, distTable)
End Function
End Module
End Namespace
diff --git a/ComponentModel/Algorithm/Levenshtein/LevenshteinModel.vb b/ComponentModel/Algorithm/Levenshtein/LevenshteinModel.vb
index 38eaf36e..6182a72e 100644
--- a/ComponentModel/Algorithm/Levenshtein/LevenshteinModel.vb
+++ b/ComponentModel/Algorithm/Levenshtein/LevenshteinModel.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6ac0df2fcb666d45d92a8d277e2b6fb8, ComponentModel\Algorithm\Levenshtein\LevenshteinModel.vb"
+#Region "Microsoft.VisualBasic::6ac0df2fcb666d45d92a8d277e2b6fb8, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\Levenshtein\LevenshteinModel.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/Levenshtein/ResultVisualize.vb b/ComponentModel/Algorithm/Levenshtein/ResultVisualize.vb
index 8150171a..72997b4b 100644
--- a/ComponentModel/Algorithm/Levenshtein/ResultVisualize.vb
+++ b/ComponentModel/Algorithm/Levenshtein/ResultVisualize.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::08ea5c7237abc19bd95da3aca099d9bb, ComponentModel\Algorithm\Levenshtein\ResultVisualize.vb"
+#Region "Microsoft.VisualBasic::08ea5c7237abc19bd95da3aca099d9bb, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\Levenshtein\ResultVisualize.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/base/Combination/Comb.vb b/ComponentModel/Algorithm/base/Combination/Comb.vb
index 6ea9f956..58445836 100644
--- a/ComponentModel/Algorithm/base/Combination/Comb.vb
+++ b/ComponentModel/Algorithm/base/Combination/Comb.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1696f908c778b7346677fded1a4d746b, ComponentModel\Algorithm\base\Combination\Comb.vb"
+#Region "Microsoft.VisualBasic::1696f908c778b7346677fded1a4d746b, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\base\Combination\Comb.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/base/Combination/Combination.vb b/ComponentModel/Algorithm/base/Combination/Combination.vb
index 048cd256..48f3cd54 100644
--- a/ComponentModel/Algorithm/base/Combination/Combination.vb
+++ b/ComponentModel/Algorithm/base/Combination/Combination.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0c3e852a5ac5d3e681d3d88fdeea1ba6, ComponentModel\Algorithm\base\Combination\Combination.vb"
+#Region "Microsoft.VisualBasic::0c3e852a5ac5d3e681d3d88fdeea1ba6, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\base\Combination\Combination.vb"
' Author:
'
diff --git a/ComponentModel/Algorithm/base/SlideWindow/Extensions.vb b/ComponentModel/Algorithm/base/SlideWindow/Extensions.vb
index cde32e88..2ac06bda 100644
--- a/ComponentModel/Algorithm/base/SlideWindow/Extensions.vb
+++ b/ComponentModel/Algorithm/base/SlideWindow/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::130b7311f6a8f174fbfc81795c78adc9, ComponentModel\Algorithm\base\SlideWindow\Extensions.vb"
+#Region "Microsoft.VisualBasic::2b94e72bbce38acfe2b38197e5bf7e9e, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\base\SlideWindow\Extensions.vb"
' Author:
'
@@ -98,7 +98,7 @@ Namespace ComponentModel.Algorithm.base
offset = 1
End If
- Dim p As VBInteger = 0
+ Dim p As i32 = 0
n = n - winSize - 1
@@ -133,7 +133,7 @@ Namespace ComponentModel.Algorithm.base
End If
End Function
- Private Iterator Function __extendTails(Of T)(tempList As List(Of T), winSize%, left%, p As VBInteger) As IEnumerable(Of SlideWindow(Of T))
+ Private Iterator Function __extendTails(Of T)(tempList As List(Of T), winSize%, left%, p As i32) As IEnumerable(Of SlideWindow(Of T))
Dim array As T() = tempList.ToArray
For i As Integer = 0 To winSize - 1
@@ -175,7 +175,7 @@ Namespace ComponentModel.Algorithm.base
Public Function [Select](Of T, TOut)(windows As IEnumerable(Of SlideWindow(Of T)), projection As Func(Of T, T, T, T, T, T, TOut)) As IEnumerable(Of TOut)
Return windows.Select(selector:=Function(win)
- Dim i As VBInteger = Scan0
+ Dim i As i32 = Scan0
Return projection(win(++i), win(++i), win(++i), win(++i), win(++i), win(++i))
End Function)
End Function
diff --git a/ComponentModel/Algorithm/base/SlideWindow/SlideWindow.vb b/ComponentModel/Algorithm/base/SlideWindow/SlideWindow.vb
index 18152134..db5a4cd1 100644
--- a/ComponentModel/Algorithm/base/SlideWindow/SlideWindow.vb
+++ b/ComponentModel/Algorithm/base/SlideWindow/SlideWindow.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7975f639c9878a467e69a57bf62f0424, ComponentModel\Algorithm\base\SlideWindow\SlideWindow.vb"
+#Region "Microsoft.VisualBasic::7975f639c9878a467e69a57bf62f0424, Microsoft.VisualBasic.Core\ComponentModel\Algorithm\base\SlideWindow\SlideWindow.vb"
' Author:
'
diff --git a/ComponentModel/Count.vb b/ComponentModel/Count.vb
index d7aa78a2..2d20fb9c 100644
--- a/ComponentModel/Count.vb
+++ b/ComponentModel/Count.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dfbbdb353c3faead10950620e0ceb0b5, ComponentModel\Count.vb"
+#Region "Microsoft.VisualBasic::4ad22354f6820da7f7549ed80669838c, Microsoft.VisualBasic.Core\ComponentModel\Count.vb"
' Author:
'
@@ -56,7 +56,7 @@ Namespace ComponentModel
'''
''' The object counter
'''
- Public Class Counter : Inherits VBInteger
+ Public Class Counter : Inherits i32
'''
''' Create a new integer counter start from ZERO.(新建一个计数器)
diff --git a/ComponentModel/DataSource/Iterator.vb b/ComponentModel/DataSource/Iterator.vb
index 1b47dca7..c6a4a11d 100644
--- a/ComponentModel/DataSource/Iterator.vb
+++ b/ComponentModel/DataSource/Iterator.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ba69b268287687d4453b6df22cbcea97, ComponentModel\DataSource\Iterator.vb"
+#Region "Microsoft.VisualBasic::6bac56438c6394f3ad3d004ef53f5677, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Iterator.vb"
' Author:
'
@@ -55,7 +55,6 @@
Imports System.Runtime.CompilerServices
Imports System.Threading
-Imports System.Threading.Thread
Namespace ComponentModel.DataSourceModel
@@ -123,7 +122,8 @@ Namespace ComponentModel.DataSourceModel
_started = True
' Single thread safely
- For Each x As Object In _source ' 单线程安全
+ ' 单线程安全
+ For Each x As Object In _source
Call receiveDone.WaitOne()
Call receiveDone.Reset()
@@ -151,7 +151,8 @@ Namespace ComponentModel.DataSourceModel
''' Sets the enumerator to its initial position, which is before the first element in the collection.
'''
Public Sub Reset() Implements IEnumerator.Reset
- If Not _forEach Is Nothing Then ' 终止这条线程然后再新建
+ If Not _forEach Is Nothing Then
+ ' 终止这条线程然后再新建
Call _forEach.Abort()
End If
@@ -173,7 +174,8 @@ Namespace ComponentModel.DataSourceModel
''' true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
'''
Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext
- If ReadDone Then ' 在移动之前已经读取完毕了
+ If ReadDone Then
+ ' 在移动之前已经读取完毕了
_Current = Nothing
Return False
End If
diff --git a/ComponentModel/DataSource/Property/Controls.vb b/ComponentModel/DataSource/Property/Controls.vb
index 29e2147e..72664d97 100644
--- a/ComponentModel/DataSource/Property/Controls.vb
+++ b/ComponentModel/DataSource/Property/Controls.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::653e0433987e989ce48bac0f2a3d83b6, ComponentModel\DataSource\Property\Controls.vb"
+#Region "Microsoft.VisualBasic::653e0433987e989ce48bac0f2a3d83b6, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\Controls.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Property/DynamicProperty.vb b/ComponentModel/DataSource/Property/DynamicProperty.vb
index 0f669e35..b6df7a55 100644
--- a/ComponentModel/DataSource/Property/DynamicProperty.vb
+++ b/ComponentModel/DataSource/Property/DynamicProperty.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::10639614f100433a4eb09a252f359a2b, ComponentModel\DataSource\Property\DynamicProperty.vb"
+#Region "Microsoft.VisualBasic::92f84c2ceb27d47add3515044ec49605, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\DynamicProperty.vb"
' Author:
'
@@ -59,6 +59,7 @@ Namespace ComponentModel.DataSourceModel
Public MustInherit Class DynamicPropertyBase(Of T)
Implements IDynamicMeta(Of T)
Implements IEnumerable(Of NamedValue(Of T))
+ Implements IDynamicsObject
'''
''' The dynamics property object with specific type of value.
@@ -88,7 +89,7 @@ Namespace ComponentModel.DataSourceModel
'''
'''
'''
- Default Public Overloads Property ItemValue(name$) As T
+ Default Public Overridable Overloads Property ItemValue(name$) As T
Get
If Properties.ContainsKey(name) Then
@@ -135,6 +136,34 @@ Namespace ComponentModel.DataSourceModel
Call propertyTable.Add(propertyName, value)
End Sub
+ Public Sub SetValue(propertyName$, value As T)
+ If propertyTable Is Nothing Then
+ propertyTable = New Dictionary(Of String, T)
+ End If
+
+ propertyTable(propertyName) = value
+ End Sub
+
+
+ Public Function GetItemValue(propertyName As String) As T
+ Return ItemValue(propertyName)
+ End Function
+
+
+ Private Sub Add(propertyName As String, value As Object) Implements IDynamicsObject.Add
+ Call Add(propertyName, Conversion.CTypeDynamic(Of T)(value))
+ End Sub
+
+
+ Private Sub SetValue(propertyName As String, value As Object) Implements IDynamicsObject.SetValue
+ Call SetValue(propertyName, Conversion.CTypeDynamic(Of T)(value))
+ End Sub
+
+
+ Private Function IDynamicsObject_GetItemValue(propertyName As String) As Object Implements IDynamicsObject.GetItemValue
+ Return GetItemValue(propertyName)
+ End Function
+
'''
''' Determines whether the System.Collections.Generic.Dictionary`2 contains the specified
''' key.
@@ -152,6 +181,14 @@ Namespace ComponentModel.DataSourceModel
End If
End Function
+ '''
+ ''' Get all keys in
+ '''
+ '''
+ Private Function GetNames() As IEnumerable(Of String) Implements IDynamicsObject.GetNames
+ Return Properties.Keys
+ End Function
+
'''
''' 枚举这个动态字典类型之中的所有的键名,这个函数是默认不包含有类型自有的属性名称的
'''
diff --git a/ComponentModel/DataSource/Property/GenericProperty.vb b/ComponentModel/DataSource/Property/GenericProperty.vb
index 39fe2a50..1e47ab10 100644
--- a/ComponentModel/DataSource/Property/GenericProperty.vb
+++ b/ComponentModel/DataSource/Property/GenericProperty.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::acba7167e1e900039f16d90d328b2d31, ComponentModel\DataSource\Property\GenericProperty.vb"
+#Region "Microsoft.VisualBasic::acba7167e1e900039f16d90d328b2d31, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\GenericProperty.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Property/IProperty.vb b/ComponentModel/DataSource/Property/IProperty.vb
index 93f60c97..729f7528 100644
--- a/ComponentModel/DataSource/Property/IProperty.vb
+++ b/ComponentModel/DataSource/Property/IProperty.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9323d6cc7d0a0aa572c751ef79fd2eab, ComponentModel\DataSource\Property\IProperty.vb"
+#Region "Microsoft.VisualBasic::9323d6cc7d0a0aa572c751ef79fd2eab, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\IProperty.vb"
' Author:
'
@@ -67,6 +67,19 @@ Namespace ComponentModel.DataSourceModel
Sub SetValue(target As Object, value As Object)
End Interface
+ '''
+ ''' Apply for R# object
+ '''
+ Public Interface IDynamicsObject
+
+ Sub Add(propertyName$, value As Object)
+ Sub SetValue(propertyName$, value As Object)
+
+ Function GetNames() As IEnumerable(Of String)
+ Function GetItemValue(propertyName As String) As Object
+
+ End Interface
+
'''
''' Abstracts for the dynamics property.
'''
diff --git a/ComponentModel/DataSource/Property/NamedCollection.vb b/ComponentModel/DataSource/Property/NamedCollection.vb
index 2ab55c46..9767ad98 100644
--- a/ComponentModel/DataSource/Property/NamedCollection.vb
+++ b/ComponentModel/DataSource/Property/NamedCollection.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e99182a5af91e1e16afeddacac8e0b8e, ComponentModel\DataSource\Property\NamedCollection.vb"
+#Region "Microsoft.VisualBasic::6ecaea55568818c5640d9ca38d5ac3b0, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\NamedCollection.vb"
' Author:
'
@@ -37,6 +37,7 @@
'
' Constructor: (+4 Overloads) Sub New
' Function: GetEnumerator, GetValues, IEnumerable_GetEnumerator, ToString
+ ' Operators: <>, =
'
'
' /********************************************************************************/
@@ -199,8 +200,8 @@ Namespace ComponentModel.DataSourceModel
End Function
Public Iterator Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
- For Each x As T In value.SafeQuery
- Yield x
+ For Each obj As T In value.SafeQuery
+ Yield obj
Next
End Function
@@ -211,5 +212,13 @@ Namespace ComponentModel.DataSourceModel
Public Shared Widening Operator CType(tuple As (name$, value As T())) As NamedCollection(Of T)
Return New NamedCollection(Of T)(tuple.name, tuple.value)
End Operator
+
+ Public Shared Operator =(list As NamedCollection(Of T), count As Integer) As Boolean
+ Return list.Count = count
+ End Operator
+
+ Public Shared Operator <>(list As NamedCollection(Of T), count As Integer) As Boolean
+ Return Not list = count
+ End Operator
End Structure
End Namespace
diff --git a/ComponentModel/DataSource/Property/NamedValue.vb b/ComponentModel/DataSource/Property/NamedValue.vb
index 392a6545..f3305548 100644
--- a/ComponentModel/DataSource/Property/NamedValue.vb
+++ b/ComponentModel/DataSource/Property/NamedValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::529b3ac85939959a3564dad680f53aa1, ComponentModel\DataSource\Property\NamedValue.vb"
+#Region "Microsoft.VisualBasic::f4507e59be237ed145377ad63c2de46d, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\NamedValue.vb"
' Author:
'
@@ -44,6 +44,7 @@
#End Region
+Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports System.Web.Script.Serialization
Imports System.Xml.Serialization
@@ -105,6 +106,33 @@ Namespace ComponentModel.DataSourceModel
End Get
End Property
+ Default Public ReadOnly Property TryMethodInvoke(arg As Object) As Object
+ Get
+ If Value Is Nothing Then
+ Return Nothing
+ Else
+ Dim type As Type = ValueType
+
+ If type.IsInheritsFrom(GetType([Delegate])) Then
+ Dim del As [Delegate] = CObj(Value)
+ Return del.DynamicInvoke({arg})
+ Else
+ Dim indexProp As PropertyInfo = type _
+ .GetProperties(PublicProperty) _
+ .FirstOrDefault(Function(p)
+ Return p.CanRead AndAlso Not p.GetIndexParameters.IsNullOrEmpty
+ End Function)
+
+ If Not indexProp Is Nothing Then
+ Return indexProp.GetMethod.Invoke(Value, {arg})
+ Else
+ Return Nothing
+ End If
+ End If
+ End If
+ End Get
+ End Property
+
'''
''' Creates a object bind with a specific .
'''
diff --git a/ComponentModel/DataSource/Property/PropertyValue.vb b/ComponentModel/DataSource/Property/PropertyValue.vb
index 2c602728..2bf59cd8 100644
--- a/ComponentModel/DataSource/Property/PropertyValue.vb
+++ b/ComponentModel/DataSource/Property/PropertyValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8559057cd6a428b07ae9ae6e650b6295, ComponentModel\DataSource\Property\PropertyValue.vb"
+#Region "Microsoft.VisualBasic::b5834ea2d7b39560dd5d476170c1be22, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\PropertyValue.vb"
' Author:
'
@@ -58,8 +58,8 @@ Namespace ComponentModel.DataSourceModel
'''
Public Class PropertyValue(Of T) : Inherits Value(Of T)
- ReadOnly __get As Func(Of T)
- ReadOnly __set As Action(Of T)
+ ReadOnly handleGet As Func(Of T)
+ ReadOnly handleSet As Action(Of T)
'''
''' The Extension property value.
@@ -67,13 +67,15 @@ Namespace ComponentModel.DataSourceModel
'''
Public Overrides Property value As T
Get
- Return __get()
+ Return handleGet()
End Get
Set(value As T)
- MyBase.value = value
+ MyBase.Value = value
- If Not __set Is Nothing Then
- Call __set(value) ' 因为在初始化的时候会对这个属性赋值,但是set没有被初始化,所以会出错,在这里加了一个if判断来避免空引用的错误
+ If Not handleSet Is Nothing Then
+ ' 因为在初始化的时候会对这个属性赋值,但是set没有被初始化,
+ ' 所以会出错, 在这里加了一个if判断来避免空引用的错误
+ Call handleSet(value)
End If
End Set
End Property
@@ -90,16 +92,16 @@ Namespace ComponentModel.DataSourceModel
''' 请勿使用函数,否则会出现栈空间溢出
''' 请勿使用方法,否则会出现栈空间溢出
Sub New([get] As Func(Of T), [set] As Action(Of T))
- __get = [get]
- __set = [set]
+ handleGet = [get]
+ handleSet = [set]
End Sub
'''
''' Tag property value.(默认是将数据写入到基本类型的值之中)
'''
Sub New()
- __get = Function() MyBase.value
- __set = Sub(v) MyBase.value = v
+ handleGet = Function() MyBase.Value
+ handleSet = Sub(v) MyBase.Value = v
End Sub
'''
@@ -108,7 +110,7 @@ Namespace ComponentModel.DataSourceModel
'''
'''
Public Function SetValue(value As T) As DynamicPropertyBase(Of T)
- Call __set(value)
+ Call handleSet(value)
Return obj
End Function
diff --git a/ComponentModel/DataSource/Repository/ILocalSearchHandle.vb b/ComponentModel/DataSource/Repository/ILocalSearchHandle.vb
index 40282aba..62d5e03c 100644
--- a/ComponentModel/DataSource/Repository/ILocalSearchHandle.vb
+++ b/ComponentModel/DataSource/Repository/ILocalSearchHandle.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::217afa2cb9160b3e9fb40fd75f7f495b, ComponentModel\DataSource\Repository\ILocalSearchHandle.vb"
+#Region "Microsoft.VisualBasic::217afa2cb9160b3e9fb40fd75f7f495b, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Repository\ILocalSearchHandle.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Repository/IMatched.vb b/ComponentModel/DataSource/Repository/IMatched.vb
index 8f0a0fba..61907d9e 100644
--- a/ComponentModel/DataSource/Repository/IMatched.vb
+++ b/ComponentModel/DataSource/Repository/IMatched.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d68023fd62338db0f12e0a895c6091c6, ComponentModel\DataSource\Repository\IMatched.vb"
+#Region "Microsoft.VisualBasic::d68023fd62338db0f12e0a895c6091c6, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Repository\IMatched.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Repository/QueryCache.vb b/ComponentModel/DataSource/Repository/QueryCache.vb
index c02a08af..e54790e3 100644
--- a/ComponentModel/DataSource/Repository/QueryCache.vb
+++ b/ComponentModel/DataSource/Repository/QueryCache.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::001b8cce47ecce5f7b8273fbd965f952, ComponentModel\DataSource\Repository\QueryCache.vb"
+#Region "Microsoft.VisualBasic::001b8cce47ecce5f7b8273fbd965f952, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Repository\QueryCache.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Repository/Repository.vb b/ComponentModel/DataSource/Repository/Repository.vb
index 56cc6257..71884d72 100644
--- a/ComponentModel/DataSource/Repository/Repository.vb
+++ b/ComponentModel/DataSource/Repository/Repository.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::bb2dc61814a9ef8c6094f2a3d1b9516a, ComponentModel\DataSource\Repository\Repository.vb"
+#Region "Microsoft.VisualBasic::bb2dc61814a9ef8c6094f2a3d1b9516a, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Repository\Repository.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/SchemaMaps/BindProperty.vb b/ComponentModel/DataSource/SchemaMaps/BindProperty.vb
index 89186e6f..c157f2b8 100644
--- a/ComponentModel/DataSource/SchemaMaps/BindProperty.vb
+++ b/ComponentModel/DataSource/SchemaMaps/BindProperty.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6248876d415b08d11e14bdad794e4f3c, ComponentModel\DataSource\SchemaMaps\BindProperty.vb"
+#Region "Microsoft.VisualBasic::846e9343a1f39e358aabc37998874578, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\BindProperty.vb"
' Author:
'
@@ -74,8 +74,8 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
Dim field As T
Dim name As String
- ReadOnly __setValue As Action(Of Object, Object)
- ReadOnly __getValue As Func(Of Object, Object)
+ Friend ReadOnly handleSetValue As Action(Of Object, Object)
+ Friend ReadOnly handleGetValue As Func(Of Object, Object)
#Region "Property List"
@@ -140,8 +140,8 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
' Compile the property get/set as the delegate
With prop
- __setValue = AddressOf prop.SetValue ' .DeclaringType.PropertySet(.Name)
- __getValue = AddressOf prop.GetValue ' .DeclaringType.PropertyGet(.Name)
+ handleSetValue = AddressOf prop.SetValue ' .DeclaringType.PropertySet(.Name)
+ handleGetValue = AddressOf prop.GetValue ' .DeclaringType.PropertyGet(.Name)
End With
End Sub
@@ -170,8 +170,8 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
End If
With field
- __setValue = AddressOf field.SetValue ' .DeclaringType.FieldSet(.Name)
- __getValue = AddressOf field.GetValue ' .DeclaringType.FieldGet(.Name)
+ handleSetValue = AddressOf field.SetValue ' .DeclaringType.FieldSet(.Name)
+ handleGetValue = AddressOf field.GetValue ' .DeclaringType.FieldGet(.Name)
End With
End Sub
@@ -190,10 +190,10 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
End If
With field
- __setValue = Sub(a, b)
- Throw New ReadOnlyException
- End Sub
- __getValue = Function(obj) method.Invoke(obj, {})
+ handleSetValue = Sub(a, b)
+ Throw New ReadOnlyException
+ End Sub
+ handleGetValue = Function(obj) method.Invoke(obj, {})
End With
End Sub
@@ -233,7 +233,7 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
Public Sub SetValue(obj As Object, value As Object) Implements IProperty.SetValue
' 2017-6-26 目前value参数为空值的话,会报错,故而在这里添加了一个If分支判断
If value IsNot Nothing Then
- Call __setValue(obj, value)
+ Call handleSetValue(obj, value)
End If
End Sub
@@ -270,7 +270,7 @@ Namespace ComponentModel.DataSourceModel.SchemaMaps
'''
Public Function GetValue(x As Object) As Object Implements IProperty.GetValue
- Return __getValue(x)
+ Return handleGetValue(x)
End Function
'''
diff --git a/ComponentModel/DataSource/SchemaMaps/DataSource.vb b/ComponentModel/DataSource/SchemaMaps/DataSource.vb
index 66a5023c..34612f34 100644
--- a/ComponentModel/DataSource/SchemaMaps/DataSource.vb
+++ b/ComponentModel/DataSource/SchemaMaps/DataSource.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::633a486a87f1e57733543dbb7304615f, ComponentModel\DataSource\SchemaMaps\DataSource.vb"
+#Region "Microsoft.VisualBasic::633a486a87f1e57733543dbb7304615f, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\DataSource.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/SchemaMaps/Mappings.vb b/ComponentModel/DataSource/SchemaMaps/Mappings.vb
index e8b934f2..d72fc64a 100644
--- a/ComponentModel/DataSource/SchemaMaps/Mappings.vb
+++ b/ComponentModel/DataSource/SchemaMaps/Mappings.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::567ee34c5b8d1cb49ffa254ecdc9d3bc, ComponentModel\DataSource\SchemaMaps\Mappings.vb"
+#Region "Microsoft.VisualBasic::567ee34c5b8d1cb49ffa254ecdc9d3bc, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\Mappings.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/SchemaMaps/PropertyValue.vb b/ComponentModel/DataSource/SchemaMaps/PropertyValue.vb
index 61e59761..15d9a3a9 100644
--- a/ComponentModel/DataSource/SchemaMaps/PropertyValue.vb
+++ b/ComponentModel/DataSource/SchemaMaps/PropertyValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d8c88f2814f68448a420af814bbfb1f9, ComponentModel\DataSource\SchemaMaps\PropertyValue.vb"
+#Region "Microsoft.VisualBasic::d8c88f2814f68448a420af814bbfb1f9, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\PropertyValue.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/SchemaMaps/SQL.vb b/ComponentModel/DataSource/SchemaMaps/SQL.vb
index 8cfc0f4c..dbfd4296 100644
--- a/ComponentModel/DataSource/SchemaMaps/SQL.vb
+++ b/ComponentModel/DataSource/SchemaMaps/SQL.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5b06e4396b4bda66d00a83bb75c598bd, ComponentModel\DataSource\SchemaMaps\SQL.vb"
+#Region "Microsoft.VisualBasic::5b06e4396b4bda66d00a83bb75c598bd, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\SQL.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/SchemaMaps/Schema.vb b/ComponentModel/DataSource/SchemaMaps/Schema.vb
index f455372e..2d331d8c 100644
--- a/ComponentModel/DataSource/SchemaMaps/Schema.vb
+++ b/ComponentModel/DataSource/SchemaMaps/Schema.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0723d0ed2e2c569bb018511a68c9a99d, ComponentModel\DataSource\SchemaMaps\Schema.vb"
+#Region "Microsoft.VisualBasic::0723d0ed2e2c569bb018511a68c9a99d, Microsoft.VisualBasic.Core\ComponentModel\DataSource\SchemaMaps\Schema.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/BitMap/HashHandle.vb b/ComponentModel/DataStructures/BitMap/HashHandle.vb
index 3f3c16df..4028ca05 100644
--- a/ComponentModel/DataStructures/BitMap/HashHandle.vb
+++ b/ComponentModel/DataStructures/BitMap/HashHandle.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9ab6de94b9be81c46ce96c1a2414f20f, ComponentModel\DataStructures\BitMap\HashHandle.vb"
+#Region "Microsoft.VisualBasic::9ab6de94b9be81c46ce96c1a2414f20f, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\BitMap\HashHandle.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/BitMap/HashList.vb b/ComponentModel/DataStructures/BitMap/HashList.vb
index 538d671a..7c3a0850 100644
--- a/ComponentModel/DataStructures/BitMap/HashList.vb
+++ b/ComponentModel/DataStructures/BitMap/HashList.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d41f4036924781109ecb6eb3a959b1b5, ComponentModel\DataStructures\BitMap\HashList.vb"
+#Region "Microsoft.VisualBasic::d41f4036924781109ecb6eb3a959b1b5, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\BitMap\HashList.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/BitMap/HashModel.vb b/ComponentModel/DataStructures/BitMap/HashModel.vb
index a0f844fc..405425cc 100644
--- a/ComponentModel/DataStructures/BitMap/HashModel.vb
+++ b/ComponentModel/DataStructures/BitMap/HashModel.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6454ef3a138ca347bcd3778898de75ea, ComponentModel\DataStructures\BitMap\HashModel.vb"
+#Region "Microsoft.VisualBasic::41ba2dd93115d064fca9cd3c745bf034, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\BitMap\HashModel.vb"
' Author:
'
@@ -62,7 +62,6 @@
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic
-Imports Microsoft.VisualBasic.Language
Namespace ComponentModel
@@ -117,14 +116,16 @@ Namespace ComponentModel
End Sub
End Class
+
+
Public Module AddressedValueExtensions
Public Function Vector(Of T As IAddress(Of Integer), TOut)(source As IEnumerable(Of T), length As Integer, getValue As Func(Of T, TOut)) As TOut()
Dim chunk As TOut() = New TOut(length - 1) {}
- For Each x As T In source
- chunk(x.Address) = getValue(x)
+ For Each element As T In source
+ chunk(element.Address) = getValue(element)
Next
Return chunk
diff --git a/ComponentModel/DataStructures/CapacityQueue.vb b/ComponentModel/DataStructures/CapacityQueue.vb
index 5365cbc8..07af6342 100644
--- a/ComponentModel/DataStructures/CapacityQueue.vb
+++ b/ComponentModel/DataStructures/CapacityQueue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3671c550d58132fc3b4056767b3e8568, ComponentModel\DataStructures\CapacityQueue.vb"
+#Region "Microsoft.VisualBasic::3671c550d58132fc3b4056767b3e8568, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\CapacityQueue.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Enumerable/IEnumerable.vb b/ComponentModel/DataStructures/Enumerable/IEnumerable.vb
index ac7561da..5b9ad307 100644
--- a/ComponentModel/DataStructures/Enumerable/IEnumerable.vb
+++ b/ComponentModel/DataStructures/Enumerable/IEnumerable.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3eb69c5ec28321fbdb068dfd45528a54, ComponentModel\DataStructures\Enumerable\IEnumerable.vb"
+#Region "Microsoft.VisualBasic::3eb69c5ec28321fbdb068dfd45528a54, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Enumerable\IEnumerable.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Enumerable/NamedValueList.vb b/ComponentModel/DataStructures/Enumerable/NamedValueList.vb
index c090d0b1..a5631958 100644
--- a/ComponentModel/DataStructures/Enumerable/NamedValueList.vb
+++ b/ComponentModel/DataStructures/Enumerable/NamedValueList.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b28acecbf305e4db101b0452f5ed115e, ComponentModel\DataStructures\Enumerable\NamedValueList.vb"
+#Region "Microsoft.VisualBasic::b28acecbf305e4db101b0452f5ed115e, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Enumerable\NamedValueList.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/FuzzyGroup.vb b/ComponentModel/DataStructures/FuzzyGroup.vb
index 06a01768..f546f14f 100644
--- a/ComponentModel/DataStructures/FuzzyGroup.vb
+++ b/ComponentModel/DataStructures/FuzzyGroup.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1c1c46cbd2631aa9d993af74ef412941, ComponentModel\DataStructures\FuzzyGroup.vb"
+#Region "Microsoft.VisualBasic::1c1c46cbd2631aa9d993af74ef412941, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\FuzzyGroup.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/HashDictionary.vb b/ComponentModel/DataStructures/HashDictionary.vb
index 11db7cb3..a4332612 100644
--- a/ComponentModel/DataStructures/HashDictionary.vb
+++ b/ComponentModel/DataStructures/HashDictionary.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::abb1f44460101a4c04d6f44e10d206a9, ComponentModel\DataStructures\HashDictionary.vb"
+#Region "Microsoft.VisualBasic::abb1f44460101a4c04d6f44e10d206a9, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\HashDictionary.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/LoopArray.vb b/ComponentModel/DataStructures/LoopArray.vb
index c53bdd5e..a7c6e640 100644
--- a/ComponentModel/DataStructures/LoopArray.vb
+++ b/ComponentModel/DataStructures/LoopArray.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6cbca453e2ad0186dd0aa5e35dce4f3a, ComponentModel\DataStructures\LoopArray.vb"
+#Region "Microsoft.VisualBasic::6cbca453e2ad0186dd0aa5e35dce4f3a, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\LoopArray.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Pointer.vb b/ComponentModel/DataStructures/Pointer.vb
index 50f42923..eae93593 100644
--- a/ComponentModel/DataStructures/Pointer.vb
+++ b/ComponentModel/DataStructures/Pointer.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0c118f269e92d3295ecf727bc3e30ca3, ComponentModel\DataStructures\Pointer.vb"
+#Region "Microsoft.VisualBasic::0c118f269e92d3295ecf727bc3e30ca3, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Pointer.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Set/BadBehaviourResponses.vb b/ComponentModel/DataStructures/Set/BadBehaviourResponses.vb
index 5b8b3ebb..1da8abdc 100644
--- a/ComponentModel/DataStructures/Set/BadBehaviourResponses.vb
+++ b/ComponentModel/DataStructures/Set/BadBehaviourResponses.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::bc03d914d599c8998230d843a443ae88, ComponentModel\DataStructures\Set\BadBehaviourResponses.vb"
+#Region "Microsoft.VisualBasic::bc03d914d599c8998230d843a443ae88, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Set\BadBehaviourResponses.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Set/Set.vb b/ComponentModel/DataStructures/Set/Set.vb
index 4ff8ea6d..cc952431 100644
--- a/ComponentModel/DataStructures/Set/Set.vb
+++ b/ComponentModel/DataStructures/Set/Set.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d6fc50e8d571fb7e37285a9f5e7c4828, ComponentModel\DataStructures\Set\Set.vb"
+#Region "Microsoft.VisualBasic::d6fc50e8d571fb7e37285a9f5e7c4828, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Set\Set.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Set/SetAPI.vb b/ComponentModel/DataStructures/Set/SetAPI.vb
index 3e586140..6e9912e1 100644
--- a/ComponentModel/DataStructures/Set/SetAPI.vb
+++ b/ComponentModel/DataStructures/Set/SetAPI.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1124a0f8383f649a8ceb886eabadb08e, ComponentModel\DataStructures\Set\SetAPI.vb"
+#Region "Microsoft.VisualBasic::1124a0f8383f649a8ceb886eabadb08e, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Set\SetAPI.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Set/SetsExtension.vb b/ComponentModel/DataStructures/Set/SetsExtension.vb
index 6ad25212..c34d4f54 100644
--- a/ComponentModel/DataStructures/Set/SetsExtension.vb
+++ b/ComponentModel/DataStructures/Set/SetsExtension.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c8c29ac4791a14e7240181a0cec1e6df, ComponentModel\DataStructures\Set\SetsExtension.vb"
+#Region "Microsoft.VisualBasic::c8c29ac4791a14e7240181a0cec1e6df, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Set\SetsExtension.vb"
' Author:
'
@@ -80,25 +80,27 @@ Public Module SetsExtension
End Function
'''
- ''' 就并集
+ ''' Performs a union of two sets.
+ ''' (就并集)
'''
'''
'''
'''
-
+
Public Function Union(s1 As [Set], s2 As [Set]) As [Set]
Return s1 Or s2
End Function
'''
- ''' 求交集
+ ''' Performs an intersection of two sets.
+ ''' (求交集)
'''
'''
'''
'''
-
+
Public Function Intersection(s1 As [Set], s2 As [Set]) As [Set]
Return s1 And s2
End Function
diff --git a/ComponentModel/DataStructures/Set/StringSet.vb b/ComponentModel/DataStructures/Set/StringSet.vb
index 5fc4da7b..7b7b4f9f 100644
--- a/ComponentModel/DataStructures/Set/StringSet.vb
+++ b/ComponentModel/DataStructures/Set/StringSet.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::40222131056ab52cedace7de0903de1a, ComponentModel\DataStructures\Set\StringSet.vb"
+#Region "Microsoft.VisualBasic::40222131056ab52cedace7de0903de1a, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Set\StringSet.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Tree/BinaryTree/Abstract.vb b/ComponentModel/DataStructures/Tree/BinaryTree/Abstract.vb
index 3388d700..5cf36124 100644
--- a/ComponentModel/DataStructures/Tree/BinaryTree/Abstract.vb
+++ b/ComponentModel/DataStructures/Tree/BinaryTree/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cf604f709a0ada068726574cd3cccdda, ComponentModel\DataStructures\Tree\BinaryTree\Abstract.vb"
+#Region "Microsoft.VisualBasic::cf604f709a0ada068726574cd3cccdda, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Tree\BinaryTree\Abstract.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Tree/BinaryTree/Extensions.vb b/ComponentModel/DataStructures/Tree/BinaryTree/Extensions.vb
index a3a79520..33c2c8fa 100644
--- a/ComponentModel/DataStructures/Tree/BinaryTree/Extensions.vb
+++ b/ComponentModel/DataStructures/Tree/BinaryTree/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::02910dad45c4d59dbeeed97a2dcd1667, ComponentModel\DataStructures\Tree\BinaryTree\Extensions.vb"
+#Region "Microsoft.VisualBasic::02910dad45c4d59dbeeed97a2dcd1667, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Tree\BinaryTree\Extensions.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Tree/BinaryTree/TreeNode.vb b/ComponentModel/DataStructures/Tree/BinaryTree/TreeNode.vb
index ef772849..e85081e9 100644
--- a/ComponentModel/DataStructures/Tree/BinaryTree/TreeNode.vb
+++ b/ComponentModel/DataStructures/Tree/BinaryTree/TreeNode.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2512e6ceaf36abffed482f292c39e523, ComponentModel\DataStructures\Tree\BinaryTree\TreeNode.vb"
+#Region "Microsoft.VisualBasic::2512e6ceaf36abffed482f292c39e523, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Tree\BinaryTree\TreeNode.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Tree/ITreeNode.vb b/ComponentModel/DataStructures/Tree/ITreeNode.vb
index a65e1a0e..8660804e 100644
--- a/ComponentModel/DataStructures/Tree/ITreeNode.vb
+++ b/ComponentModel/DataStructures/Tree/ITreeNode.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1b6696441a2046b70e2472e46d333064, ComponentModel\DataStructures\Tree\ITreeNode.vb"
+#Region "Microsoft.VisualBasic::1b6696441a2046b70e2472e46d333064, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Tree\ITreeNode.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Tree/TreeNodeBase.vb b/ComponentModel/DataStructures/Tree/TreeNodeBase.vb
index a808ecc6..72aa7cdb 100644
--- a/ComponentModel/DataStructures/Tree/TreeNodeBase.vb
+++ b/ComponentModel/DataStructures/Tree/TreeNodeBase.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::83acf0710495996b2d0c99f72e5d717f, ComponentModel\DataStructures\Tree\TreeNodeBase.vb"
+#Region "Microsoft.VisualBasic::83acf0710495996b2d0c99f72e5d717f, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Tree\TreeNodeBase.vb"
' Author:
'
diff --git a/ComponentModel/DataStructures/Trigger.vb b/ComponentModel/DataStructures/Trigger.vb
index b803128b..e4d87b26 100644
--- a/ComponentModel/DataStructures/Trigger.vb
+++ b/ComponentModel/DataStructures/Trigger.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ae5886bdee1b150a22ab337c8978e358, ComponentModel\DataStructures\Trigger.vb"
+#Region "Microsoft.VisualBasic::ae5886bdee1b150a22ab337c8978e358, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Trigger.vb"
' Author:
'
diff --git a/ComponentModel/DriverModel.vb b/ComponentModel/DriverModel.vb
index aa7d7c9d..ef5c835f 100644
--- a/ComponentModel/DriverModel.vb
+++ b/ComponentModel/DriverModel.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::adcad34ffc4db772e17534e416b8591c, ComponentModel\DriverModel.vb"
+#Region "Microsoft.VisualBasic::adcad34ffc4db772e17534e416b8591c, Microsoft.VisualBasic.Core\ComponentModel\DriverModel.vb"
' Author:
'
diff --git a/ComponentModel/File/BufferedStream.vb b/ComponentModel/File/BufferedStream.vb
index 5d11e2db..9514b166 100644
--- a/ComponentModel/File/BufferedStream.vb
+++ b/ComponentModel/File/BufferedStream.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::126a3b8b1d0672c924a7a45d0da0d8dd, ComponentModel\File\BufferedStream.vb"
+#Region "Microsoft.VisualBasic::126a3b8b1d0672c924a7a45d0da0d8dd, Microsoft.VisualBasic.Core\ComponentModel\File\BufferedStream.vb"
' Author:
'
diff --git a/ComponentModel/File/FileSaveHandle.vb b/ComponentModel/File/FileSaveHandle.vb
index 0bb913a8..c160b3c7 100644
--- a/ComponentModel/File/FileSaveHandle.vb
+++ b/ComponentModel/File/FileSaveHandle.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9da379de7a509b7f30cb035a60cf2062, ComponentModel\File\FileSaveHandle.vb"
+#Region "Microsoft.VisualBasic::9da379de7a509b7f30cb035a60cf2062, Microsoft.VisualBasic.Core\ComponentModel\File\FileSaveHandle.vb"
' Author:
'
diff --git a/ComponentModel/File/XmlDataModel.vb b/ComponentModel/File/XmlDataModel.vb
index ebd43a32..714562ae 100644
--- a/ComponentModel/File/XmlDataModel.vb
+++ b/ComponentModel/File/XmlDataModel.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c463731b5ea4ea70468881dc9e813dba, ComponentModel\File\XmlDataModel.vb"
+#Region "Microsoft.VisualBasic::0186ad048f2a0e13a6b06622544fbc07, Microsoft.VisualBasic.Core\ComponentModel\File\XmlDataModel.vb"
' Author:
'
@@ -35,7 +35,7 @@
'
' Properties: Stylesheet, TypeComment
'
- ' Function: (+2 Overloads) GetTypeReferenceComment
+ ' Function: CreateTypeReferenceComment, (+2 Overloads) GetTypeReferenceComment
'
' Sub: SaveTypeComment
' Interface IXmlType
@@ -61,6 +61,7 @@ Imports System.Runtime.Serialization
Imports System.Web.Script.Serialization
Imports System.Xml
Imports System.Xml.Serialization
+Imports Microsoft.VisualBasic.ApplicationServices.Development
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.SecurityString
@@ -117,6 +118,10 @@ Namespace ComponentModel
Return New XmlDocument().CreateComment(GetTypeReferenceComment(Me.GetType))
End Function
+ Public Shared Function CreateTypeReferenceComment(type As Type) As XmlComment
+ Return New XmlDocument().CreateComment(GetTypeReferenceComment(type))
+ End Function
+
Public Shared Sub SaveTypeComment(model As IXmlType)
model.TypeComment = New XmlDocument().CreateComment(GetTypeReferenceComment(model.GetType))
End Sub
@@ -177,6 +182,7 @@ Namespace ComponentModel
'''
Public Shared Function GetTypeReferenceComment(modelType As Type, Optional indent% = 4) As String
Dim fullName$ = modelType.FullName
+ Dim devtools = modelType.Assembly.FromAssembly
Dim assembly$ = modelType.Assembly.FullName
Dim update As Date = File.GetLastWriteTime(modelType.Assembly.Location)
Dim md5$ = modelType.Assembly.Location.GetFileMd5
@@ -184,8 +190,10 @@ Namespace ComponentModel
Dim traceInfo$ = vbCrLf &
$"{indentBlank} model: " & fullName & vbCrLf &
$"{indentBlank} assembly: " & assembly & vbCrLf &
+ $"{indentBlank} version: " & devtools.AssemblyVersion & vbCrLf &
+ $"{indentBlank} built: " & devtools.BuiltTime.ToString & vbCrLf &
$"{indentBlank} md5: " & md5 & vbCrLf &
- $"{indentBlank} timestamp: " & update.ToLongDateString & vbCrLf &
+ $"{indentBlank} timestamp: " & update.ToString & vbCrLf &
" "
Return traceInfo
diff --git a/ComponentModel/LazyLoader.vb b/ComponentModel/LazyLoader.vb
index 3b896d61..bfcc0f2f 100644
--- a/ComponentModel/LazyLoader.vb
+++ b/ComponentModel/LazyLoader.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5f2492c0796ad85ab891091031fad3f0, ComponentModel\LazyLoader.vb"
+#Region "Microsoft.VisualBasic::5f2492c0796ad85ab891091031fad3f0, Microsoft.VisualBasic.Core\ComponentModel\LazyLoader.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Extensions.vb b/ComponentModel/Ranges/Extensions.vb
index 12808836..516ed5b6 100644
--- a/ComponentModel/Ranges/Extensions.vb
+++ b/ComponentModel/Ranges/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9b1e1c05c972f9fb87a019455680f7c2, ComponentModel\Ranges\Extensions.vb"
+#Region "Microsoft.VisualBasic::9b1e1c05c972f9fb87a019455680f7c2, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Extensions.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/RangeList.vb b/ComponentModel/Ranges/RangeList.vb
index 3b6b6be7..8f3c0d38 100644
--- a/ComponentModel/Ranges/RangeList.vb
+++ b/ComponentModel/Ranges/RangeList.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::db823fc685023f06205b5c43d4ba9f77, ComponentModel\Ranges\RangeList.vb"
+#Region "Microsoft.VisualBasic::db823fc685023f06205b5c43d4ba9f77, Microsoft.VisualBasic.Core\ComponentModel\Ranges\RangeList.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/RangeModel/DoubleRange.vb b/ComponentModel/Ranges/RangeModel/DoubleRange.vb
index 37be9742..605ad2e2 100644
--- a/ComponentModel/Ranges/RangeModel/DoubleRange.vb
+++ b/ComponentModel/Ranges/RangeModel/DoubleRange.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cb551ec303f9cd2f31b64681ea0a05db, ComponentModel\Ranges\RangeModel\DoubleRange.vb"
+#Region "Microsoft.VisualBasic::9988a01fe3a072b391b86080ef2b2388, Microsoft.VisualBasic.Core\ComponentModel\Ranges\RangeModel\DoubleRange.vb"
' Author:
'
@@ -35,8 +35,8 @@
'
' Properties: Length, Max, Min
'
- ' Constructor: (+6 Overloads) Sub New
- ' Function: Enumerate, GetEnumerator, IEnumerable_GetEnumerator, (+3 Overloads) IsInside, (+2 Overloads) IsOverlapping
+ ' Constructor: (+7 Overloads) Sub New
+ ' Function: (+2 Overloads) Enumerate, GetEnumerator, IEnumerable_GetEnumerator, (+3 Overloads) IsInside, (+2 Overloads) IsOverlapping
' ScaleMapping, (+2 Overloads) ToString, TryParse
' Operators: *, <>, =, (+2 Overloads) Like
'
@@ -121,6 +121,10 @@ Namespace ComponentModel.Ranges.Model
Call Me.New(range.Min, range.Max)
End Sub
+ Sub New(vec As Vector(Of Double))
+ Call Me.New(vec.AsEnumerable)
+ End Sub
+
'''
''' Value copy
'''
@@ -225,6 +229,10 @@ Namespace ComponentModel.Ranges.Model
Return New DoubleRange(tuple.min, tuple.max)
End Operator
+ Public Shared Widening Operator CType(vector As Vector(Of Double)) As DoubleRange
+ Return New DoubleRange(vector.Min, vector.Max)
+ End Operator
+
Public Shared Widening Operator CType(data As VectorShadows(Of Single)) As DoubleRange
Return data _
.Select(Function(s) CDbl(s)) _
@@ -271,17 +279,16 @@ Namespace ComponentModel.Ranges.Model
If Length = 0 Then
Return {}
Else
- Dim delta# = Length / n
- Dim out As New List(Of Double)
-
- For x As Double = Min To Max Step delta
- out += x
- Next
-
- Return out
+ Return Enumerate(Length / n).ToArray
End If
End Function
+ Public Iterator Function Enumerate(resolution#) As IEnumerable(Of Double)
+ For x As Double = Min To Max Step resolution
+ Yield x
+ Next
+ End Function
+
'''
''' Transform a numeric value in this into
''' target numeric range: ````.
diff --git a/ComponentModel/Ranges/RangeModel/IRanges.vb b/ComponentModel/Ranges/RangeModel/IRanges.vb
index 35bfb157..9dc09d7a 100644
--- a/ComponentModel/Ranges/RangeModel/IRanges.vb
+++ b/ComponentModel/Ranges/RangeModel/IRanges.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4afa0e3433c6b350276ffc1dab43fc17, ComponentModel\Ranges\RangeModel\IRanges.vb"
+#Region "Microsoft.VisualBasic::4afa0e3433c6b350276ffc1dab43fc17, Microsoft.VisualBasic.Core\ComponentModel\Ranges\RangeModel\IRanges.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/RangeModel/IntRange.vb b/ComponentModel/Ranges/RangeModel/IntRange.vb
index 6d5c5454..8accb423 100644
--- a/ComponentModel/Ranges/RangeModel/IntRange.vb
+++ b/ComponentModel/Ranges/RangeModel/IntRange.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7aaf99a205d4a67af35d7827b2a91f2f, ComponentModel\Ranges\RangeModel\IntRange.vb"
+#Region "Microsoft.VisualBasic::a22ce0ce5b9821bc33f44903dc549653, Microsoft.VisualBasic.Core\ComponentModel\Ranges\RangeModel\IntRange.vb"
' Author:
'
@@ -64,17 +64,17 @@ Namespace ComponentModel.Ranges.Model
'''
''' Minimum value
'''
- Public Property Min() As Integer Implements IRanges(Of Integer).Min
+ Public Property Min As Integer Implements IRanges(Of Integer).Min
'''
''' Maximum value
'''
- Public Property Max() As Integer Implements IRanges(Of Integer).Max
+ Public Property Max As Integer Implements IRanges(Of Integer).Max
'''
''' Length of the range (deffirence between maximum and minimum values)
'''
- Public ReadOnly Property Length() As Integer
+ Public ReadOnly Property Length As Integer
Get
Return Max - Min
End Get
diff --git a/ComponentModel/Ranges/RangeModel/Range.vb b/ComponentModel/Ranges/RangeModel/Range.vb
index a453d26b..6af122d6 100644
--- a/ComponentModel/Ranges/RangeModel/Range.vb
+++ b/ComponentModel/Ranges/RangeModel/Range.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5358ad4da98838b9dabf00acc48c73fe, ComponentModel\Ranges\RangeModel\Range.vb"
+#Region "Microsoft.VisualBasic::5358ad4da98838b9dabf00acc48c73fe, Microsoft.VisualBasic.Core\ComponentModel\Ranges\RangeModel\Range.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Relations.vb b/ComponentModel/Ranges/Relations.vb
index 50e48c33..d348ff25 100644
--- a/ComponentModel/Ranges/Relations.vb
+++ b/ComponentModel/Ranges/Relations.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::46642feb1338db563f29bfee8498d597, ComponentModel\Ranges\Relations.vb"
+#Region "Microsoft.VisualBasic::46642feb1338db563f29bfee8498d597, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Relations.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Selector/IndexSelector.vb b/ComponentModel/Ranges/Selector/IndexSelector.vb
index a5c830cb..1be10fc4 100644
--- a/ComponentModel/Ranges/Selector/IndexSelector.vb
+++ b/ComponentModel/Ranges/Selector/IndexSelector.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b7b6985a0997ef3768ef740897ce76e6, ComponentModel\Ranges\Selector\IndexSelector.vb"
+#Region "Microsoft.VisualBasic::95139befeafc8875d31a9c3935bef117, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Selector\IndexSelector.vb"
' Author:
'
@@ -38,7 +38,7 @@
'
' Class OrderSelector
'
- ' Properties: Count, Desc
+ ' Properties: Count, Desc, Max, Min
'
' Constructor: (+1 Overloads) Sub New
' Function: Find, FirstGreaterThan, GetEnumerator, IEnumerable_GetEnumerator, SelectByRange
@@ -123,6 +123,26 @@ Namespace ComponentModel.Ranges
End Get
End Property
+ Public ReadOnly Property Max As T
+ Get
+ If Desc Then
+ Return source.First
+ Else
+ Return source.Last
+ End If
+ End Get
+ End Property
+
+ Public ReadOnly Property Min As T
+ Get
+ If Desc Then
+ Return source.Last
+ Else
+ Return source.First
+ End If
+ End Get
+ End Property
+
Public ReadOnly Property Count As Integer Implements IReadOnlyCollection(Of T).Count
Get
diff --git a/ComponentModel/Ranges/Selector/IntTag.vb b/ComponentModel/Ranges/Selector/IntTag.vb
index 9a4bad47..36c3abb0 100644
--- a/ComponentModel/Ranges/Selector/IntTag.vb
+++ b/ComponentModel/Ranges/Selector/IntTag.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cad912ae1140ccfb151d96a22f387105, ComponentModel\Ranges\Selector\IntTag.vb"
+#Region "Microsoft.VisualBasic::cad912ae1140ccfb151d96a22f387105, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Selector\IntTag.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Selector/NumericTagged.vb b/ComponentModel/Ranges/Selector/NumericTagged.vb
index bdd72779..7fd0f9cd 100644
--- a/ComponentModel/Ranges/Selector/NumericTagged.vb
+++ b/ComponentModel/Ranges/Selector/NumericTagged.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5fe28d8fe19788ad638c9172a49963b1, ComponentModel\Ranges\Selector\NumericTagged.vb"
+#Region "Microsoft.VisualBasic::5fe28d8fe19788ad638c9172a49963b1, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Selector\NumericTagged.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Selector/SelectorExtensions.vb b/ComponentModel/Ranges/Selector/SelectorExtensions.vb
index afcf445f..8439d486 100644
--- a/ComponentModel/Ranges/Selector/SelectorExtensions.vb
+++ b/ComponentModel/Ranges/Selector/SelectorExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::15939da101ac28942dc583364c4fdc73, ComponentModel\Ranges\Selector\SelectorExtensions.vb"
+#Region "Microsoft.VisualBasic::15939da101ac28942dc583364c4fdc73, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Selector\SelectorExtensions.vb"
' Author:
'
diff --git a/ComponentModel/Ranges/Unit.vb b/ComponentModel/Ranges/Unit.vb
index b8120b84..bf7574bc 100644
--- a/ComponentModel/Ranges/Unit.vb
+++ b/ComponentModel/Ranges/Unit.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ddbfb5a6571bfb21e8d67c68844b81ff, ComponentModel\Ranges\Unit.vb"
+#Region "Microsoft.VisualBasic::9e0cfe8fe42ca5f508c2f6df254c5533, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Unit.vb"
' Author:
'
@@ -150,7 +150,7 @@ Namespace ComponentModel.Ranges
'''
'''
''' 枚举类型,基础类型必须是值等于1
- Public Class UnitValue(Of TUnit As Structure) : Inherits VBDouble
+ Public Class UnitValue(Of TUnit As Structure) : Inherits f64
'''
''' 分(d) ``10^-1``
diff --git a/ComponentModel/RelayCommand.vb b/ComponentModel/RelayCommand.vb
index 4959a7a8..dcd23384 100644
--- a/ComponentModel/RelayCommand.vb
+++ b/ComponentModel/RelayCommand.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4b561929ac8aa841e80923efc6860ee8, ComponentModel\RelayCommand.vb"
+#Region "Microsoft.VisualBasic::4b561929ac8aa841e80923efc6860ee8, Microsoft.VisualBasic.Core\ComponentModel\RelayCommand.vb"
' Author:
'
diff --git a/ComponentModel/Settings/ConfigEngine.vb b/ComponentModel/Settings/ConfigEngine.vb
index 7e78fd18..8a5bd7ee 100644
--- a/ComponentModel/Settings/ConfigEngine.vb
+++ b/ComponentModel/Settings/ConfigEngine.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fb94b88579b5a80cf463c333ca85e8ea, ComponentModel\Settings\ConfigEngine.vb"
+#Region "Microsoft.VisualBasic::fb94b88579b5a80cf463c333ca85e8ea, Microsoft.VisualBasic.Core\ComponentModel\Settings\ConfigEngine.vb"
' Author:
'
diff --git a/ComponentModel/Settings/DataModels/BindMapping.vb b/ComponentModel/Settings/DataModels/BindMapping.vb
index c3d96343..5b81f047 100644
--- a/ComponentModel/Settings/DataModels/BindMapping.vb
+++ b/ComponentModel/Settings/DataModels/BindMapping.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ef3317fb5e61d1d32694c9f58aec294d, ComponentModel\Settings\DataModels\BindMapping.vb"
+#Region "Microsoft.VisualBasic::ef3317fb5e61d1d32694c9f58aec294d, Microsoft.VisualBasic.Core\ComponentModel\Settings\DataModels\BindMapping.vb"
' Author:
'
diff --git a/ComponentModel/Settings/DataModels/ModelBase.vb b/ComponentModel/Settings/DataModels/ModelBase.vb
index 7b965744..e08a12b3 100644
--- a/ComponentModel/Settings/DataModels/ModelBase.vb
+++ b/ComponentModel/Settings/DataModels/ModelBase.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4e460ae58064f52b4031d38acbaac7c1, ComponentModel\Settings\DataModels\ModelBase.vb"
+#Region "Microsoft.VisualBasic::4e460ae58064f52b4031d38acbaac7c1, Microsoft.VisualBasic.Core\ComponentModel\Settings\DataModels\ModelBase.vb"
' Author:
'
diff --git a/ComponentModel/Settings/DataModels/ProfileItem.vb b/ComponentModel/Settings/DataModels/ProfileItem.vb
index 3083bc4b..696c6a52 100644
--- a/ComponentModel/Settings/DataModels/ProfileItem.vb
+++ b/ComponentModel/Settings/DataModels/ProfileItem.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c9dcb5e3f47f6ca3fbd2267da011ed69, ComponentModel\Settings\DataModels\ProfileItem.vb"
+#Region "Microsoft.VisualBasic::c9dcb5e3f47f6ca3fbd2267da011ed69, Microsoft.VisualBasic.Core\ComponentModel\Settings\DataModels\ProfileItem.vb"
' Author:
'
diff --git a/ComponentModel/Settings/DataModels/ProfileTable.vb b/ComponentModel/Settings/DataModels/ProfileTable.vb
index a6100d3f..1b8e8b44 100644
--- a/ComponentModel/Settings/DataModels/ProfileTable.vb
+++ b/ComponentModel/Settings/DataModels/ProfileTable.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::25116c411d3081067fe2931bf057c3b6, ComponentModel\Settings\DataModels\ProfileTable.vb"
+#Region "Microsoft.VisualBasic::25116c411d3081067fe2931bf057c3b6, Microsoft.VisualBasic.Core\ComponentModel\Settings\DataModels\ProfileTable.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/ClassMapper.vb b/ComponentModel/Settings/Inf/ClassMapper.vb
index 5fab7416..9cbca35d 100644
--- a/ComponentModel/Settings/Inf/ClassMapper.vb
+++ b/ComponentModel/Settings/Inf/ClassMapper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fc9722d3dead7ea1fe31aeab80c665a3, ComponentModel\Settings\Inf\ClassMapper.vb"
+#Region "Microsoft.VisualBasic::fc9722d3dead7ea1fe31aeab80c665a3, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\ClassMapper.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/INIProfile.vb b/ComponentModel/Settings/Inf/INIProfile.vb
index 68a8e2bf..66b630e2 100644
--- a/ComponentModel/Settings/Inf/INIProfile.vb
+++ b/ComponentModel/Settings/Inf/INIProfile.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cd7b0b8cf190022f2edd465c920b58e3, ComponentModel\Settings\Inf\INIProfile.vb"
+#Region "Microsoft.VisualBasic::cd7b0b8cf190022f2edd465c920b58e3, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\INIProfile.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/IOProvider.vb b/ComponentModel/Settings/Inf/IOProvider.vb
index cc98fe1e..88fc5914 100644
--- a/ComponentModel/Settings/Inf/IOProvider.vb
+++ b/ComponentModel/Settings/Inf/IOProvider.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3d3eb3705667b82881bcc847fca2a15a, ComponentModel\Settings\Inf\IOProvider.vb"
+#Region "Microsoft.VisualBasic::3d3eb3705667b82881bcc847fca2a15a, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\IOProvider.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/IniFile.vb b/ComponentModel/Settings/Inf/IniFile.vb
index 53f653b5..a0c98547 100644
--- a/ComponentModel/Settings/Inf/IniFile.vb
+++ b/ComponentModel/Settings/Inf/IniFile.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::136f0568fcde1a437db9944c1b3c978f, ComponentModel\Settings\Inf\IniFile.vb"
+#Region "Microsoft.VisualBasic::136f0568fcde1a437db9944c1b3c978f, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\IniFile.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/Section.vb b/ComponentModel/Settings/Inf/Section.vb
index 8fd6633d..2cb3d604 100644
--- a/ComponentModel/Settings/Inf/Section.vb
+++ b/ComponentModel/Settings/Inf/Section.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d9ba2514d25c6d20d89e7697a06f554f, ComponentModel\Settings\Inf\Section.vb"
+#Region "Microsoft.VisualBasic::d9ba2514d25c6d20d89e7697a06f554f, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\Section.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Inf/Serialization.vb b/ComponentModel/Settings/Inf/Serialization.vb
index d57198bb..2ed35789 100644
--- a/ComponentModel/Settings/Inf/Serialization.vb
+++ b/ComponentModel/Settings/Inf/Serialization.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4c4bc00b15ec114103b991207f7ba1bd, ComponentModel\Settings\Inf\Serialization.vb"
+#Region "Microsoft.VisualBasic::4c4bc00b15ec114103b991207f7ba1bd, Microsoft.VisualBasic.Core\ComponentModel\Settings\Inf\Serialization.vb"
' Author:
'
diff --git a/ComponentModel/Settings/Settings.vb b/ComponentModel/Settings/Settings.vb
index e60394ae..1e7f801d 100644
--- a/ComponentModel/Settings/Settings.vb
+++ b/ComponentModel/Settings/Settings.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5da60dbd3e007a0efc48dec6e821a958, ComponentModel\Settings\Settings.vb"
+#Region "Microsoft.VisualBasic::5da60dbd3e007a0efc48dec6e821a958, Microsoft.VisualBasic.Core\ComponentModel\Settings\Settings.vb"
' Author:
'
diff --git a/ComponentModel/Settings/SimpleConfig.vb b/ComponentModel/Settings/SimpleConfig.vb
index 01847031..3bd15fc9 100644
--- a/ComponentModel/Settings/SimpleConfig.vb
+++ b/ComponentModel/Settings/SimpleConfig.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a33e499722e8f82ca55ee720a1cf47ca, ComponentModel\Settings\SimpleConfig.vb"
+#Region "Microsoft.VisualBasic::a33e499722e8f82ca55ee720a1cf47ca, Microsoft.VisualBasic.Core\ComponentModel\Settings\SimpleConfig.vb"
' Author:
'
diff --git a/ComponentModel/SingletonHolder.vb b/ComponentModel/SingletonHolder.vb
index 69028ece..5dd58011 100644
--- a/ComponentModel/SingletonHolder.vb
+++ b/ComponentModel/SingletonHolder.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::923d8969616415108d9842f4375482e3, ComponentModel\SingletonHolder.vb"
+#Region "Microsoft.VisualBasic::923d8969616415108d9842f4375482e3, Microsoft.VisualBasic.Core\ComponentModel\SingletonHolder.vb"
' Author:
'
diff --git a/ComponentModel/System.Collections.Generic/BinaryHeap.vb b/ComponentModel/System.Collections.Generic/BinaryHeap.vb
new file mode 100644
index 00000000..9170e5bc
--- /dev/null
+++ b/ComponentModel/System.Collections.Generic/BinaryHeap.vb
@@ -0,0 +1,210 @@
+#Region "Microsoft.VisualBasic::28c3c76e2bc8137ccf9d8326f22776a7, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\BinaryHeap.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Class BinaryHeap
+ '
+ ' Properties: peek, size
+ '
+ ' Constructor: (+1 Overloads) Sub New
+ '
+ ' Function: pop
+ '
+ ' Sub: bubbleUp, push, remove, sinkDown
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports Microsoft.VisualBasic.Language
+
+Namespace ComponentModel.Collection
+
+ '''
+ ''' Binary heap implementation from:
+ '''
+ ''' > http://eloquentjavascript.net/appendix2.html
+ '''
+ '''
+ Public Class BinaryHeap(Of T As Class)
+
+ ReadOnly content As New List(Of T)
+ ReadOnly scoreFunction As Func(Of T, Double)
+
+ Public ReadOnly Property size As Integer
+ Get
+ Return content.Count
+ End Get
+ End Property
+
+ Default Public ReadOnly Property Item(i As Integer) As T
+ Get
+ Return content(i)
+ End Get
+ End Property
+
+ Public ReadOnly Property peek As T
+ Get
+ Return content(Scan0)
+ End Get
+ End Property
+
+ Sub New(scoreFunction As Func(Of T, Double))
+ Me.scoreFunction = scoreFunction
+ End Sub
+
+ Public Sub push(element As T)
+ ' Add the new element to the end of the array.
+ ' Then allow it to bubble up.
+ content.Add(element)
+ bubbleUp(content.Count - 1)
+ End Sub
+
+ Public Function pop() As T
+ ' Store the first element so we can return it later.
+ ' Get the element at the end of the array.
+ Dim result = content(Scan0)
+ Dim [end] = content.Pop
+
+ ' If there are any elements left, put the end element at the
+ ' start, And let it sink down.
+ If content > 0 Then
+ content(Scan0) = [end]
+ sinkDown(Scan0)
+ End If
+
+ Return result
+ End Function
+
+ Public Sub remove(node As T)
+ Dim len = content.Count
+ Dim [end] As T
+
+ ' To remove a value, we must search through the array to find
+ ' it.
+ For i As Integer = 0 To len - 1
+ If content(i) Is node Then
+ ' When it is found, the process seen in 'pop' is repeated
+ ' to fill up the hole.
+ [end] = content.Pop
+
+ If i <> len - 1 Then
+ content(i) = [end]
+
+ If scoreFunction([end]) < scoreFunction(node) Then
+ bubbleUp(i)
+ Else
+ sinkDown(i)
+ End If
+ End If
+
+ Return
+ End If
+ Next
+
+ Throw New Exception("Node not found.")
+ End Sub
+
+ Private Sub bubbleUp(n As Integer)
+ ' Fetch the element that has to be moved.
+ Dim element = content(n)
+
+ ' When at 0, an element can not go up any further.
+ Do While n > 0
+ ' Compute the parent element's index, and fetch it.
+ Dim parentN% = Math.Floor((n + 1) / 2) - 1
+ Dim parent = content(parentN)
+
+ ' Swap the elements if the parent is greater.
+ If scoreFunction(element) < scoreFunction(parent) Then
+ content(parentN) = element
+ content(n) = parent
+ ' Update 'n' to continue at the new position.
+ n = parentN
+ Else
+ ' Found a parent that is less, no need to move it further.
+ Exit Do
+ End If
+ Loop
+ End Sub
+
+ Private Sub sinkDown(n As Integer)
+ ' Look up the target element and its score.
+ Dim length = content.Count
+ Dim element = content(n)
+ Dim elemScore = scoreFunction(element)
+ Dim child1Score As Double
+ Dim child1 As T
+
+ Do While True
+ ' Compute the indices of the child elements.
+ Dim child2N = (n + 1) * 2, child1N = child2N - 1
+ ' This is used to store the new position of the element,
+ ' if any.
+ Dim swap As Integer?
+
+ ' If the first child exists (is inside the array)...
+ If (child1N < length) Then
+ ' Look it up And compute its score.
+ child1 = content(child1N)
+ child1Score = scoreFunction(child1)
+
+ ' If the score Is less than our element's, we need to swap.
+ If child1Score < elemScore Then
+ swap = child1N
+ End If
+ End If
+
+ ' Do the same checks for the other child.
+ If child2N < length Then
+ Dim child2 = content(child2N)
+ Dim child2Score = scoreFunction(child2)
+
+ If (child2Score < If(swap Is Nothing, elemScore, child1Score)) Then
+ swap = child2N
+ End If
+ End If
+
+ ' If the element needs to be moved, swap it, and continue.
+ If Not swap Is Nothing Then
+ content(n) = content(swap)
+ content(swap) = element
+ n = swap
+ Else
+ ' Otherwise, we are done.
+ Exit Do
+ End If
+ Loop
+ End Sub
+ End Class
+End Namespace
diff --git a/ComponentModel/System.Collections.Generic/BucketDictionary.vb b/ComponentModel/System.Collections.Generic/BucketDictionary.vb
index 542b20ef..d4b7adbc 100644
--- a/ComponentModel/System.Collections.Generic/BucketDictionary.vb
+++ b/ComponentModel/System.Collections.Generic/BucketDictionary.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3833795011a6ed46058df56330aca07e, ComponentModel\System.Collections.Generic\BucketDictionary.vb"
+#Region "Microsoft.VisualBasic::fb63cde407f533b915185b636ca705d8, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\BucketDictionary.vb"
' Author:
'
@@ -50,6 +50,7 @@
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Serialization.JSON
Namespace ComponentModel.Collection
@@ -147,7 +148,7 @@ Namespace ComponentModel.Collection
End Sub
Public Overrides Function ToString() As String
- Return $"Tuple of [{GetType(K).Name}, {GetType(V).Name}] with {buckets.Count} buckets."
+ Return $"Tuple of [{GetType(K).Name}, {GetType(V).Name}] with {Count} records in {buckets.Count} buckets."
End Function
Public Function ContainsKey(key As K) As Boolean Implements IReadOnlyDictionary(Of K, V).ContainsKey
@@ -184,19 +185,41 @@ Namespace ComponentModel.Collection
End Function
End Class
+
Public Module BucketDictionaryExtensions
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+ ''' 当数据中存在重复的键名的时候,是将前面已有的数据覆盖掉还是抛出键名重复的错误?默认是不进行重写覆盖,而是键重复抛出错误。
+ '''
+ '''
- Public Function CreateBuckets(Of T, K)(source As IEnumerable(Of T), getKey As Func(Of T, K), Optional size% = Short.MaxValue * 10) As BucketDictionary(Of K, T)
- Return source.CreateBuckets(getKey, Function(o) o, size:=size)
+ Public Function CreateBuckets(Of T, K)(source As IEnumerable(Of T),
+ getKey As Func(Of T, K),
+ Optional size% = Short.MaxValue * 10,
+ Optional overridesDuplicates As Boolean = False) As BucketDictionary(Of K, T)
+ Return source.CreateBuckets(
+ getKey:=getKey,
+ getValue:=Function(o) o,
+ size:=size,
+ overridesDuplicates:=overridesDuplicates
+ )
End Function
Public Function CreateBuckets(Of T, K, V)(source As IEnumerable(Of T),
getKey As Func(Of T, K),
getValue As Func(Of T, V),
- Optional size% = Short.MaxValue * 10) As BucketDictionary(Of K, V)
+ Optional size% = Short.MaxValue * 10,
+ Optional overridesDuplicates As Boolean = False) As BucketDictionary(Of K, V)
Dim table As New BucketDictionary(Of K, V)(size)
Dim bucket As New Dictionary(Of K, V)
@@ -205,7 +228,13 @@ Namespace ComponentModel.Collection
Dim key As K = getKey(x)
Dim value As V = getValue(x)
- Call bucket.Add(key, value)
+ If overridesDuplicates Then
+ bucket(key) = value
+ ElseIf bucket.ContainsKey(key) Then
+ Throw New DuplicateNameException(key.GetJson)
+ Else
+ Call bucket.Add(key, value)
+ End If
If bucket.Count >= size Then
table.buckets.Add(bucket)
diff --git a/ComponentModel/System.Collections.Generic/IndexOf.vb b/ComponentModel/System.Collections.Generic/IndexOf.vb
index b85b037a..f3d938b2 100644
--- a/ComponentModel/System.Collections.Generic/IndexOf.vb
+++ b/ComponentModel/System.Collections.Generic/IndexOf.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::54e85494a04f696bb8540d6846ed52dc, ComponentModel\System.Collections.Generic\IndexOf.vb"
+#Region "Microsoft.VisualBasic::a6498fbe4fe1e79159f3793ea7e5ddf9, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\IndexOf.vb"
' Author:
'
@@ -37,12 +37,13 @@
'
' Constructor: (+4 Overloads) Sub New
'
- ' Function: Add, GetEnumerator, IEnumerable_GetEnumerator, indexing, (+2 Overloads) Intersect
- ' NotExists, ToString
+ ' Function: Add, GetEnumerator, GetOrdinal, IEnumerable_GetEnumerator, indexing
+ ' (+2 Overloads) Intersect, NotExists, ToString
'
' Sub: Clear, Delete
'
- ' Operators: (+2 Overloads) +, (+2 Overloads) Like
+ ' Operators: -, (+2 Overloads) +, <>, =, (+2 Overloads) IsFalse
+ ' (+2 Overloads) IsTrue, (+2 Overloads) Like
'
'
' /********************************************************************************/
@@ -183,6 +184,10 @@ Namespace ComponentModel.Collection
End Get
End Property
+ Public Function GetOrdinal(items As IEnumerable(Of T)) As Integer()
+ Return items.Select(Function(element) Me(element)).ToArray
+ End Function
+
Public Sub Delete(index As T)
Dim i = Me.IndexOf(index)
@@ -297,6 +302,24 @@ Namespace ComponentModel.Collection
Return list + index.Objects
End Operator
+ '''
+ ''' Delete items from source and then returns the new modify index collection
+ '''
+ '''
+ '''
+ '''
+ Public Shared Operator -(index As Index(Of T), list As List(Of T)) As Index(Of T)
+ Dim table = index.maps
+
+ For Each item As T In list
+ If table.ContainsKey(item) Then
+ Call table.Remove(item)
+ End If
+ Next
+
+ Return New Index(Of T)(table.Keys)
+ End Operator
+
'''
''' is one of the element in
'''
@@ -322,5 +345,38 @@ Namespace ComponentModel.Collection
Private Iterator Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Yield GetEnumerator()
End Function
+
+ '''
+ ''' The element numbers in current index object is equals to given count number value?
+ '''
+ '''
+ '''
+ '''
+
+ Public Shared Operator =(index As Index(Of T), count%) As Boolean
+ Return index.Count = count
+ End Operator
+
+
+ Public Shared Operator <>(index As Index(Of T), count%) As Boolean
+ Return Not index = count
+ End Operator
+
+ Public Shared Operator IsTrue(index As Index(Of T)) As Boolean
+ If index Is Nothing Then
+ Return False
+ ElseIf index.Count = 0 Then
+ Return False
+ ElseIf index.Count = 1 AndAlso Len(CObj(index.Objects(Scan0))) = 0 Then
+ Return False
+ Else
+ Return True
+ End If
+ End Operator
+
+
+ Public Shared Operator IsFalse(index As Index(Of T)) As Boolean
+ Return Not op_True(index)
+ End Operator
End Class
End Namespace
diff --git a/ComponentModel/System.Collections.Generic/KeyDictionary.vb b/ComponentModel/System.Collections.Generic/KeyDictionary.vb
index 14891a9d..b15ad615 100644
--- a/ComponentModel/System.Collections.Generic/KeyDictionary.vb
+++ b/ComponentModel/System.Collections.Generic/KeyDictionary.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::236e26fa514031145c6e91dcd119e08b, ComponentModel\System.Collections.Generic\KeyDictionary.vb"
+#Region "Microsoft.VisualBasic::96de3680f1c003d276cb4347540c5482, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\KeyDictionary.vb"
' Author:
'
@@ -272,11 +272,11 @@ Namespace ComponentModel.Collection
'''
''' 假若目标元素不存在于本字典之中,则会返回False
'''
- '''
+ '''
'''
- Public Overloads Function Remove(x As V) As Boolean
- If Me.ContainsKey(x.Key) Then
- Return Me.Remove(x.Key)
+ Public Overloads Function Remove(vec As V) As Boolean
+ If Me.ContainsKey(vec.Key) Then
+ Return Me.Remove(vec.Key)
Else
Return False
End If
diff --git a/ComponentModel/System.Collections.Generic/MapsHelper.vb b/ComponentModel/System.Collections.Generic/MapsHelper.vb
index c7603454..5c3bd7d0 100644
--- a/ComponentModel/System.Collections.Generic/MapsHelper.vb
+++ b/ComponentModel/System.Collections.Generic/MapsHelper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::92731cf4f0f1ec25a156c62baa4adfb4, ComponentModel\System.Collections.Generic\MapsHelper.vb"
+#Region "Microsoft.VisualBasic::92731cf4f0f1ec25a156c62baa4adfb4, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\MapsHelper.vb"
' Author:
'
diff --git a/ComponentModel/System.Collections.Generic/PriorityQueue/Abstract.vb b/ComponentModel/System.Collections.Generic/PriorityQueue/Abstract.vb
index cd1c0cfc..2fb25647 100644
--- a/ComponentModel/System.Collections.Generic/PriorityQueue/Abstract.vb
+++ b/ComponentModel/System.Collections.Generic/PriorityQueue/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::bca0d86dd22bc409d262feb73d47f50b, ComponentModel\System.Collections.Generic\PriorityQueue\Abstract.vb"
+#Region "Microsoft.VisualBasic::bca0d86dd22bc409d262feb73d47f50b, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\PriorityQueue\Abstract.vb"
' Author:
'
diff --git a/ComponentModel/System.Collections.Generic/PriorityQueue/BinaryPriorityQueue.vb b/ComponentModel/System.Collections.Generic/PriorityQueue/BinaryPriorityQueue.vb
index b05a98d3..3a3a94e2 100644
--- a/ComponentModel/System.Collections.Generic/PriorityQueue/BinaryPriorityQueue.vb
+++ b/ComponentModel/System.Collections.Generic/PriorityQueue/BinaryPriorityQueue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7ea121c6ee5b5da0ea643b7db0334da4, ComponentModel\System.Collections.Generic\PriorityQueue\BinaryPriorityQueue.vb"
+#Region "Microsoft.VisualBasic::7ea121c6ee5b5da0ea643b7db0334da4, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\PriorityQueue\BinaryPriorityQueue.vb"
' Author:
'
diff --git a/ComponentModel/System.Collections.Generic/PriorityQueue/PairingHeap.vb b/ComponentModel/System.Collections.Generic/PriorityQueue/PairingHeap.vb
index 6a5ada95..095546ab 100644
--- a/ComponentModel/System.Collections.Generic/PriorityQueue/PairingHeap.vb
+++ b/ComponentModel/System.Collections.Generic/PriorityQueue/PairingHeap.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c73bfb90554e5410139e2ebb022e563b, ComponentModel\System.Collections.Generic\PriorityQueue\PairingHeap.vb"
+#Region "Microsoft.VisualBasic::c73bfb90554e5410139e2ebb022e563b, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\PriorityQueue\PairingHeap.vb"
' Author:
'
diff --git a/ComponentModel/System.Collections.Generic/PriorityQueue/PriorityQueue.vb b/ComponentModel/System.Collections.Generic/PriorityQueue/PriorityQueue.vb
index 108740bc..b9c65b17 100644
--- a/ComponentModel/System.Collections.Generic/PriorityQueue/PriorityQueue.vb
+++ b/ComponentModel/System.Collections.Generic/PriorityQueue/PriorityQueue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5ace0d2cf316361ee4908b71b18ba6dd, ComponentModel\System.Collections.Generic\PriorityQueue\PriorityQueue.vb"
+#Region "Microsoft.VisualBasic::6cebe2b568d1eae0cf3b03702280aa9c, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\PriorityQueue\PriorityQueue.vb"
' Author:
'
@@ -61,9 +61,6 @@ Namespace ComponentModel.Collection
Dim lessThan As Func(Of T, T, Boolean)
'''
- ''' ������캯���IJ�����һ���Ƚϵı��ʽ�������Ƚ���������֮������ȶȹ�ϵ
- ''' ���������������ϵ��
- '''
''' ```
''' priority = a < b
''' ```
@@ -81,12 +78,8 @@ Namespace ComponentModel.Collection
Next
End Sub
- '*
- ' * @method top
- ' * @return the top element (the min element as defined by lessThan)
- '
'''
- ''' �൱��Stack��Peek����
+ ''' the top element (the min element as defined by lessThan)
'''
'''
Public Function top() As T
diff --git a/ComponentModel/TimeSpan.vb b/ComponentModel/TimeSpan.vb
index 87ed3d71..ba03c6a0 100644
--- a/ComponentModel/TimeSpan.vb
+++ b/ComponentModel/TimeSpan.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::cdf4edfa1d484a1bfe9c77f0aab04e58, ComponentModel\TimeSpan.vb"
+#Region "Microsoft.VisualBasic::cdf4edfa1d484a1bfe9c77f0aab04e58, Microsoft.VisualBasic.Core\ComponentModel\TimeSpan.vb"
' Author:
'
diff --git a/ComponentModel/Uid.vb b/ComponentModel/Uid.vb
index a19b5c18..b742e174 100644
--- a/ComponentModel/Uid.vb
+++ b/ComponentModel/Uid.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c5dec718721c6b50c72a06dfd4dbecbb, ComponentModel\Uid.vb"
+#Region "Microsoft.VisualBasic::c5dec718721c6b50c72a06dfd4dbecbb, Microsoft.VisualBasic.Core\ComponentModel\Uid.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/Binding.vb b/ComponentModel/ValuePair/Binding.vb
index f25ece17..d61adddd 100644
--- a/ComponentModel/ValuePair/Binding.vb
+++ b/ComponentModel/ValuePair/Binding.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::00ff821a099908e75295b177c069fae6, ComponentModel\ValuePair\Binding.vb"
+#Region "Microsoft.VisualBasic::00ff821a099908e75295b177c069fae6, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\Binding.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/GenericAbstract.vb b/ComponentModel/ValuePair/GenericAbstract.vb
index d51be0f1..0d2c23da 100644
--- a/ComponentModel/ValuePair/GenericAbstract.vb
+++ b/ComponentModel/ValuePair/GenericAbstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6bac3abad158dee19713f863974f75ae, ComponentModel\ValuePair\GenericAbstract.vb"
+#Region "Microsoft.VisualBasic::6bac3abad158dee19713f863974f75ae, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\GenericAbstract.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/NamedTuple.vb b/ComponentModel/ValuePair/NamedTuple.vb
index 8d1e8789..d130a5e0 100644
--- a/ComponentModel/ValuePair/NamedTuple.vb
+++ b/ComponentModel/ValuePair/NamedTuple.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::7fcc9d024b07357353ddd681a28a6080, ComponentModel\ValuePair\NamedTuple.vb"
+#Region "Microsoft.VisualBasic::7fcc9d024b07357353ddd681a28a6080, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\NamedTuple.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/TagData/FactorValue.vb b/ComponentModel/ValuePair/TagData/FactorValue.vb
index cbc8d25c..89c59733 100644
--- a/ComponentModel/ValuePair/TagData/FactorValue.vb
+++ b/ComponentModel/ValuePair/TagData/FactorValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e5f6f962adb352ccd0e7877755b9c8e5, ComponentModel\ValuePair\TagData\FactorValue.vb"
+#Region "Microsoft.VisualBasic::e5f6f962adb352ccd0e7877755b9c8e5, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\TagData\FactorValue.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/TagData/Indexing.vb b/ComponentModel/ValuePair/TagData/Indexing.vb
index 6d13c9ea..dbcbe560 100644
--- a/ComponentModel/ValuePair/TagData/Indexing.vb
+++ b/ComponentModel/ValuePair/TagData/Indexing.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5fde000ea39b59dbe36acf5e98f7f01c, ComponentModel\ValuePair\TagData\Indexing.vb"
+#Region "Microsoft.VisualBasic::5fde000ea39b59dbe36acf5e98f7f01c, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\TagData\Indexing.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/TagData/LineValue.vb b/ComponentModel/ValuePair/TagData/LineValue.vb
index b52c57dd..5d360bc0 100644
--- a/ComponentModel/ValuePair/TagData/LineValue.vb
+++ b/ComponentModel/ValuePair/TagData/LineValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ed5ba19c67abf11edf0e3844aef51abf, ComponentModel\ValuePair\TagData\LineValue.vb"
+#Region "Microsoft.VisualBasic::ed5ba19c67abf11edf0e3844aef51abf, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\TagData\LineValue.vb"
' Author:
'
diff --git a/ComponentModel/ValuePair/TagData/TagData.vb b/ComponentModel/ValuePair/TagData/TagData.vb
index c27abb60..f0671277 100644
--- a/ComponentModel/ValuePair/TagData/TagData.vb
+++ b/ComponentModel/ValuePair/TagData/TagData.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::68b027c2426ee954592b66c111ef89b7, ComponentModel\ValuePair\TagData\TagData.vb"
+#Region "Microsoft.VisualBasic::68b027c2426ee954592b66c111ef89b7, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\TagData\TagData.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Abstract.vb b/Data/Abstract.vb
similarity index 96%
rename from ComponentModel/DataSource/Abstract.vb
rename to Data/Abstract.vb
index a52e6a02..5a14477b 100644
--- a/ComponentModel/DataSource/Abstract.vb
+++ b/Data/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9e217abf5ba3f2929fef576bfb42c6e8, ComponentModel\DataSource\Abstract.vb"
+#Region "Microsoft.VisualBasic::9e217abf5ba3f2929fef576bfb42c6e8, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Abstract.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/DataFramework.vb b/Data/DataFramework.vb
similarity index 82%
rename from ComponentModel/DataSource/DataFramework.vb
rename to Data/DataFramework.vb
index 70b4f100..da051ba9 100644
--- a/ComponentModel/DataSource/DataFramework.vb
+++ b/Data/DataFramework.vb
@@ -1,54 +1,53 @@
-#Region "Microsoft.VisualBasic::2ffe6881ea86a4bcf64f0d7d7f8e9ec9, ComponentModel\DataSource\DataFramework.vb"
+#Region "Microsoft.VisualBasic::38800f3dcbb663b37b43bab7bfcd361f, Microsoft.VisualBasic.Core\ComponentModel\DataSource\DataFramework.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Module DataFramework
- '
- ' Properties: Flags, StringBuilders, StringParsers
- '
- ' Constructor: (+1 Overloads) Sub New
- ' Function: DictionaryTable, getOrCache, (+2 Overloads) Schema, ValueTable
- ' Delegate Function
- '
- ' Function: __initSchema, CreateObject, GetValue, IsComplexType, IsNumericType
- ' IsPrimitive, valueToString
- '
- '
- '
- ' /********************************************************************************/
+' Module DataFramework
+'
+' Properties: Flags, StringBuilders, StringParsers
+'
+' Constructor: (+1 Overloads) Sub New
+' Function: DictionaryTable, getOrCache, (+2 Overloads) Schema, ValueTable
+' Delegate Function
+'
+' Function: CreateObject, GetValue, IsComplexType, IsNumericType, IsPrimitive
+' ParseSchemaInternal, valueToString
+'
+'
+'
+' /********************************************************************************/
#End Region
-Imports System.Data
Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel.SchemaMaps
@@ -240,6 +239,11 @@ Namespace ComponentModel.DataSourceModel
''' Object methods.
'''
'''
+ '''
+ ''' 在这个和Scripting命名空间下的基础类型的判断不一样
+ ''' 在这里只会判断.NET框架中的基础类型
+ ''' 在Scripting命名空间下的基础类型,是规定为所有包含有类型和字符串值之间的隐式转换的类型
+ '''
Public ReadOnly Property StringBuilders As New Dictionary(Of Type, IStringBuilder) From {
_
{GetType(String), Function(s) If(s Is Nothing, "", CStr(s))},
@@ -319,7 +323,7 @@ Namespace ComponentModel.DataSourceModel
'''
'''
Public Function CreateObject(Of T)(source As IEnumerable(Of T)) As DataTable
- Dim columns = __initSchema(GetType(T))
+ Dim columns = ParseSchemaInternal(GetType(T))
Dim table As New DataTable
Dim type As Type
@@ -348,17 +352,16 @@ Namespace ComponentModel.DataSourceModel
''' Retrive data from a specific datatable object.(从目标数据表中获取数据)
'''
'''
- '''
+ '''
'''
'''
- Public Function GetValue(Of T)(DataTable As DataTable) As T()
- Dim Columns = __initSchema(GetType(T))
- Dim rtvlData As T() = New T(DataTable.Rows.Count - 1) {}
+ Public Function GetValue(Of T)(dataTable As DataTable) As T()
+ Dim Columns = ParseSchemaInternal(GetType(T))
+ Dim rtvlData As T() = New T(dataTable.Rows.Count - 1) {}
Dim i As Integer = 0
- Dim Schema As List(Of KeyValuePair(Of Integer, PropertyInfo)) =
- New List(Of KeyValuePair(Of Integer, PropertyInfo))
- For Each column As DataColumn In DataTable.Columns
+ Dim schema As List(Of KeyValuePair(Of Integer, PropertyInfo)) = New List(Of KeyValuePair(Of Integer, PropertyInfo))
+ For Each column As DataColumn In dataTable.Columns
Dim LQuery As BindProperty(Of DataFrameColumnAttribute) =
LinqAPI.DefaultFirst(Of BindProperty(Of DataFrameColumnAttribute)) <=
From schemaColumn As BindProperty(Of DataFrameColumnAttribute)
@@ -367,13 +370,13 @@ Namespace ComponentModel.DataSourceModel
Select schemaColumn
If Not LQuery.IsNull Then
- Call Schema.Add(New KeyValuePair(Of Integer, PropertyInfo)(column.Ordinal, LQuery.member))
+ Call schema.Add(New KeyValuePair(Of Integer, PropertyInfo)(column.Ordinal, LQuery.member))
End If
Next
- For Each row As DataRow In DataTable.Rows
+ For Each row As DataRow In dataTable.Rows
Dim obj As T = Activator.CreateInstance(Of T)()
- For Each column In Schema
+ For Each column In schema
Dim value = row.Item(column.Key)
If IsDBNull(value) OrElse value Is Nothing Then
Continue For
@@ -387,10 +390,10 @@ Namespace ComponentModel.DataSourceModel
Return rtvlData
End Function
- Private Function __initSchema(type As Type) As Dictionary(Of String, BindProperty(Of DataFrameColumnAttribute))
+ Private Function ParseSchemaInternal(type As Type) As Dictionary(Of String, BindProperty(Of DataFrameColumnAttribute))
Dim dataType As Type = GetType(DataFrameColumnAttribute)
Dim props As PropertyInfo() = type.GetProperties
- Dim Columns = (From [property] As PropertyInfo
+ Dim columns = (From [property] As PropertyInfo
In props
Let attrs As Object() = [property].GetCustomAttributes(dataType, True)
Where Not attrs.IsNullOrEmpty
@@ -398,26 +401,29 @@ Namespace ComponentModel.DataSourceModel
DirectCast(attrs.First, DataFrameColumnAttribute), [property]
Order By colMaps.Index Ascending).AsList
- For Each column In Columns
+ For Each column In columns
If String.IsNullOrEmpty(column.colMaps.Name) Then
Call column.colMaps.SetNameValue(column.property.Name)
End If
Next
Dim unIndexColumn = (From col
- In Columns
+ In columns
Where col.colMaps.Index <= 0
Select col ' 未建立索引的对象按照名称排序
Order By col.colMaps.Name Ascending).ToArray ' 由于在后面会涉及到修改list对象,所以在这里使用ToArray来隔绝域list的关系,避免出现冲突
+ ' 将未建立索引的对象放置到列表的最末尾
For Each col In unIndexColumn
- Call Columns.Remove(col)
- Call Columns.Add(col) '将未建立索引的对象放置到列表的最末尾
+ Call columns.Remove(col)
+ Call columns.Add(col)
Next
- Return Columns.ToDictionary(
+ Return columns.ToDictionary(
Function(x) x.colMaps.Name,
- Function(x) New BindProperty(Of DataFrameColumnAttribute)(x.colMaps, x.property))
+ Function(x)
+ Return New BindProperty(Of DataFrameColumnAttribute)(x.colMaps, x.property)
+ End Function)
End Function
End Module
End Namespace
diff --git a/ComponentModel/DataSource/DefaultAttribute.vb b/Data/DefaultAttribute.vb
similarity index 97%
rename from ComponentModel/DataSource/DefaultAttribute.vb
rename to Data/DefaultAttribute.vb
index d46101a4..20503534 100644
--- a/ComponentModel/DataSource/DefaultAttribute.vb
+++ b/Data/DefaultAttribute.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8f5dc2d2723bf368ee62ccf0148ba17d, ComponentModel\DataSource\DefaultAttribute.vb"
+#Region "Microsoft.VisualBasic::8f5dc2d2723bf368ee62ccf0148ba17d, Microsoft.VisualBasic.Core\ComponentModel\DataSource\DefaultAttribute.vb"
' Author:
'
diff --git a/Data/NamespaceDoc.vb b/Data/NamespaceDoc.vb
new file mode 100644
index 00000000..6c3093ee
--- /dev/null
+++ b/Data/NamespaceDoc.vb
@@ -0,0 +1,8 @@
+Namespace Data
+
+ '''
+ ''' The sciBASIC.NET data handling module
+ '''
+ Module NamespaceDoc
+ End Module
+End Namespace
\ No newline at end of file
diff --git a/Data/Repository/RepositoryFileSystem.vb b/Data/Repository/RepositoryFileSystem.vb
new file mode 100644
index 00000000..546a96f1
--- /dev/null
+++ b/Data/Repository/RepositoryFileSystem.vb
@@ -0,0 +1,220 @@
+Imports System.Runtime.CompilerServices
+Imports Microsoft.VisualBasic.CommandLine.Reflection
+Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
+Imports Microsoft.VisualBasic.FileIO.Path
+Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Language.Default
+Imports Microsoft.VisualBasic.Language.UnixBash
+Imports Microsoft.VisualBasic.Linq.Extensions
+Imports Microsoft.VisualBasic.Scripting.MetaData
+
+Namespace Data.Repository
+
+ '''
+ ''' Using file system as repository system provider
+ '''
+ Public Module RepositoryFileSystem
+
+ '''
+ '''
+ '''
+ '''
+ '''
+ ''' 元素的排布是有顺序的
+ '''
+ '''
+ '''
+
+ Public Function GetFile(DIR As String,
+ keyword As String,
+ ParamArray ext As String()) _
+ As String()
+
+ Dim Files As IEnumerable(Of String) = ls - l - wildcards(ext) <= DIR
+ Dim matches = (From Path As String
+ In Files.AsParallel
+ Let NameID = BaseName(Path)
+ Where InStr(NameID, keyword, CompareMethod.Text) > 0
+ Let ExtValue = Path.Split("."c).Last
+ Select Path,
+ ExtValue)
+ Dim LQuery =
+ From extType As String
+ In ext
+ Select From path
+ In matches
+ Where InStr(extType, path.ExtValue, CompareMethod.Text) > 0
+ Select path.Path
+ Return LQuery.IteratesALL.Distinct.ToArray
+ End Function
+
+ '''
+ ''' Load the file from a specific directory from the source parameter as the resource entry list.
+ '''
+ ''' [,这个函数会扫描目标文件夹下面的所有文件。]
+ ''' 请注意,本方法是不能够产生具有相同的主文件名的数据的。假若目标GBK是使用本模块之中的方法保存或者导出来的,
+ ''' 则可以使用本方法生成Entry列表;(在返回的结果之中,KEY为文件名,没有拓展名,VALUE为文件的路径)
+ '''
+ '''
+ '''
+ '''
+ '''
+
+
+ Public Function LoadSourceEntryList( source As String,
+ ext As String(),
+ Optional topLevel As Boolean = True) As Dictionary(Of String, String)
+
+ If ext.IsNullOrEmpty Then
+ ext = {"*.*"}
+ End If
+
+ Dim LQuery = (From path As String
+ In If(topLevel, ls - l, ls - l - r) - wildcards(ext) <= source
+ Select ID = BaseName(path),
+ path
+ Group By ID Into Group).ToArray
+
+ ext = LinqAPI.Exec(Of String) <= From value As String
+ In ext
+ Select value.Split(CChar(".")).Last.ToLower
+
+ Dim res As Dictionary(Of String, String) = LQuery _
+ .ToDictionary(Function(x) x.ID,
+ Function(x)
+
+ Return LinqAPI.DefaultFirst(Of String) _
+ _
+ () <= From path
+ In x.Group
+ Let pathValue = path.path
+ Let extValue As String = pathValue.Split("."c).Last.ToLower
+ Where Array.IndexOf(ext, extValue) > -1
+ Select pathValue
+
+ End Function)
+
+ With From entry
+ In res
+ Where Not String.IsNullOrEmpty(entry.Value)
+ Select entry
+
+ res = .ToDictionary(Function(x) x.Key,
+ Function(x) x.Value)
+ End With
+
+ Call $"{NameOf(ProgramPathSearchTool)} load {res.Count} source entry...".__DEBUG_ECHO
+
+ Return res
+ End Function
+
+ '''
+ ''' 可以使用本方法生成Entry列表;(在返回的结果之中,KEY为文件名,没有拓展名,VALUE为文件的路径)
+ ''' 请注意,这个函数会搜索目标文件夹下面的所有的文件夹的
+ '''
+ '''
+ ''' 文件类型的拓展名称
+ '''
+ '''
+ Public Function LoadSourceEntryList(source$, ParamArray ext$()) As Dictionary(Of String, String)
+ If Not FileIO.FileSystem.DirectoryExists(source) Then
+ Return New Dictionary(Of String, String)
+ End If
+
+ Dim LQuery = From path As String
+ In FileIO.FileSystem.GetFiles(source, FileIO.SearchOption.SearchAllSubDirectories, ext)
+ Select ID = BaseName(path),
+ path
+ Group By ID Into Group
+ Dim dict As Dictionary(Of String, String) =
+ LQuery.ToDictionary(Function(x) x.ID,
+ Function(x) x.Group.First.path)
+ Return dict
+ End Function
+
+ '''
+ ''' 允许有重复的数据
+ '''
+ '''
+ '''
+ '''
+ '''
+
+
+ Public Function LoadEntryList( DIR$, ParamArray exts$()) As NamedValue(Of String)()
+ Return LinqAPI.Exec(Of NamedValue(Of String)) _
+ _
+ () <= From path As String
+ In ls - l - ShellSyntax.r - wildcards(exts) <= DIR
+ Select New NamedValue(Of String) With {
+ .Name = path.BaseName,
+ .Value = path
+ }
+
+ End Function
+
+ '''
+ ''' Load the file from a specific directory from the source parameter as the resource entry list.
+ '''
+ '''
+ '''
+
+
+ Public Function LoadSourceEntryList(source As IEnumerable(Of String)) As Dictionary(Of String, String)
+ Dim LQuery = From path As String
+ In source
+ Select ID = BaseName(path),
+ path
+ Group By ID Into Group
+ Dim res As Dictionary(Of String, String) =
+ LQuery.ToDictionary(Function(x) x.ID,
+ Function(x) x.Group.First.path)
+ Return res
+ End Function
+
+ '''
+ ''' Copy the file in the source list into the copyto directory, function returns the failed operation list.
+ ''' (将不同来源的文件复制到目标文件夹之中)
+ '''
+ '''
+ '''
+ ''' 返回失败的文件列表
+ '''
+
+ Public Function SourceCopy(source As IEnumerable(Of String), CopyTo As String, Optional [Overrides] As Boolean = False) As String()
+ Dim failedList As New List(Of String)
+
+ For Each file As String In source
+ Try
+ Call FileIO.FileSystem.CopyFile(file, CopyTo & "/" & FileIO.FileSystem.GetFileInfo(file).Name, [Overrides])
+ Catch ex As Exception
+ Call failedList.Add(file)
+ Call App.LogException(New Exception(file, ex))
+ End Try
+ Next
+
+ Return failedList.ToArray
+ End Function
+
+ '''
+ ''' Gets a directory path which is most frequent appeared in the file list.
+ '''
+ '''
+ '''
+
+ Public Function GetMostAppreancePath(files As IEnumerable(Of String)) As String
+ If files Is Nothing Then
+ Return ""
+ End If
+
+ Dim LQuery = From strPath As String
+ In files
+ Select FileIO.FileSystem.GetParentPath(strPath)
+ Return LQuery _
+ .TokenCount(ignoreCase:=True) _
+ .OrderByDescending(Function(x) x.Value) _
+ .FirstOrDefault _
+ .Key
+ End Function
+ End Module
+End Namespace
\ No newline at end of file
diff --git a/Extensions/Trinity/Expression.vb b/Data/Trinity/Expression.vb
similarity index 97%
rename from Extensions/Trinity/Expression.vb
rename to Data/Trinity/Expression.vb
index 5dfeb08d..68de06b2 100644
--- a/Extensions/Trinity/Expression.vb
+++ b/Data/Trinity/Expression.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::252bfaa89ee13252e7c43a4b3ae4f611, Extensions\Trinity\Expression.vb"
+#Region "Microsoft.VisualBasic::252bfaa89ee13252e7c43a4b3ae4f611, Microsoft.VisualBasic.Core\Extensions\Trinity\Expression.vb"
' Author:
'
diff --git a/Extensions/Trinity/Extensions.vb b/Data/Trinity/Extensions.vb
similarity index 96%
rename from Extensions/Trinity/Extensions.vb
rename to Data/Trinity/Extensions.vb
index 41d4f263..ae4ba85a 100644
--- a/Extensions/Trinity/Extensions.vb
+++ b/Data/Trinity/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ebc0acb27e6002bb75c2f03711b0f9ac, Extensions\Trinity\Extensions.vb"
+#Region "Microsoft.VisualBasic::ebc0acb27e6002bb75c2f03711b0f9ac, Microsoft.VisualBasic.Core\Extensions\Trinity\Extensions.vb"
' Author:
'
diff --git a/Extensions/Trinity/NLP/TextTokens.vb b/Data/Trinity/NLP/TextTokens.vb
similarity index 98%
rename from Extensions/Trinity/NLP/TextTokens.vb
rename to Data/Trinity/NLP/TextTokens.vb
index b69a9898..4aa11111 100644
--- a/Extensions/Trinity/NLP/TextTokens.vb
+++ b/Data/Trinity/NLP/TextTokens.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::db9f5269029f591c99930ac9cf93e10f, Extensions\Trinity\NLP\TextTokens.vb"
+#Region "Microsoft.VisualBasic::db9f5269029f591c99930ac9cf93e10f, Microsoft.VisualBasic.Core\Extensions\Trinity\NLP\TextTokens.vb"
' Author:
'
diff --git a/Extensions/Trinity/Word.vb b/Data/Trinity/Word.vb
similarity index 97%
rename from Extensions/Trinity/Word.vb
rename to Data/Trinity/Word.vb
index 8bfade62..19c72033 100644
--- a/Extensions/Trinity/Word.vb
+++ b/Data/Trinity/Word.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d50d0ba2fcaaee407553abd3d8e34a41, Extensions\Trinity\Word.vb"
+#Region "Microsoft.VisualBasic::d50d0ba2fcaaee407553abd3d8e34a41, Microsoft.VisualBasic.Core\Extensions\Trinity\Word.vb"
' Author:
'
diff --git a/Extensions/Trinity/WordClass.vb b/Data/Trinity/WordClass.vb
similarity index 97%
rename from Extensions/Trinity/WordClass.vb
rename to Data/Trinity/WordClass.vb
index facc1808..85d80c99 100644
--- a/Extensions/Trinity/WordClass.vb
+++ b/Data/Trinity/WordClass.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5723dc4e4812a32ed1a2cb43dabb24e9, Extensions\Trinity\WordClass.vb"
+#Region "Microsoft.VisualBasic::5723dc4e4812a32ed1a2cb43dabb24e9, Microsoft.VisualBasic.Core\Extensions\Trinity\WordClass.vb"
' Author:
'
diff --git a/ComponentModel/DataSource/Tsv.vb b/Data/Tsv.vb
similarity index 99%
rename from ComponentModel/DataSource/Tsv.vb
rename to Data/Tsv.vb
index 41f50eb8..726d607d 100644
--- a/ComponentModel/DataSource/Tsv.vb
+++ b/Data/Tsv.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f64e58f8c379ac5d5e872027beeaadd4, ComponentModel\DataSource\Tsv.vb"
+#Region "Microsoft.VisualBasic::f64e58f8c379ac5d5e872027beeaadd4, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Tsv.vb"
' Author:
'
diff --git a/Data/TypeCaster.vb b/Data/TypeCaster.vb
new file mode 100644
index 00000000..690e7961
--- /dev/null
+++ b/Data/TypeCaster.vb
@@ -0,0 +1,213 @@
+#Region "Microsoft.VisualBasic::4c129a449557dee3f9aea51c4e14c1d3, Microsoft.VisualBasic.Core\ComponentModel\DataSource\TypeCaster.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Module Extensions
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ ' Sub: Add
+ '
+ ' Interface ITypeCaster
+ '
+ ' Properties: type
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ ' Class TypeCaster
+ '
+ ' Properties: sizeOf, type
+ '
+ ' Class StringCaster
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ ' Class IntegerCaster
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ ' Class DoubleCaster
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ ' Class DateCaster
+ '
+ ' Function: GetBytes, GetString, ParseObject, ToObject
+ '
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Runtime.CompilerServices
+Imports System.Runtime.InteropServices
+Imports System.Text
+Imports Microsoft.VisualBasic.Text
+
+Namespace ComponentModel.DataSourceModel.Caster
+
+ Public Module Extensions
+
+ ReadOnly typeCaster As New Dictionary(Of Type, ITypeCaster) From {
+ New StringCaster, New IntegerCaster, New DoubleCaster, New DateCaster
+ }
+
+
+ Private Sub Add(table As Dictionary(Of Type, ITypeCaster), caster As ITypeCaster)
+ Call table.Add(caster.type, caster)
+ End Sub
+
+
+
+ Public Function GetBytes(type As Type) As Func(Of Object, Byte())
+ Return AddressOf typeCaster(type).GetBytes
+ End Function
+
+
+
+ Public Function GetString(type As Type) As Func(Of Object, String)
+ Return AddressOf typeCaster(type).GetString
+ End Function
+
+
+
+ Public Function ToObject(type As Type) As Func(Of Byte(), Object)
+ Return AddressOf typeCaster(type).ToObject
+ End Function
+
+
+
+ Public Function ParseObject(type As Type) As Func(Of String, Object)
+ Return AddressOf typeCaster(type).ParseObject
+ End Function
+ End Module
+
+ Public Interface ITypeCaster
+
+ ReadOnly Property type As Type
+
+ Function GetBytes(value As Object) As Byte()
+ Function GetString(value As Object) As String
+ Function ToObject(bytes As Byte()) As Object
+ Function ParseObject(str As String) As Object
+ End Interface
+
+ Public MustInherit Class TypeCaster(Of T) : Implements ITypeCaster
+
+ Public ReadOnly Property sizeOf As Integer = Marshal.SizeOf(type)
+ Public ReadOnly Property type As Type = GetType(T) Implements ITypeCaster.type
+
+ Public MustOverride Function GetBytes(value As Object) As Byte() Implements ITypeCaster.GetBytes
+ Public MustOverride Function GetString(value As Object) As String Implements ITypeCaster.GetString
+ Public MustOverride Function ToObject(bytes As Byte()) As Object Implements ITypeCaster.ToObject
+ Public MustOverride Function ParseObject(str As String) As Object Implements ITypeCaster.ParseObject
+
+ End Class
+
+ Public Class StringCaster : Inherits TypeCaster(Of String)
+
+ ReadOnly utf8 As Encoding = Encodings.UTF8WithoutBOM.CodePage
+
+ Public Overrides Function GetBytes(value As Object) As Byte()
+ Return utf8.GetBytes(DirectCast(value, String))
+ End Function
+
+ Public Overrides Function GetString(value As Object) As String
+ Return value
+ End Function
+
+ Public Overrides Function ToObject(bytes() As Byte) As Object
+ Return utf8.GetString(bytes, Scan0, bytes.Length)
+ End Function
+
+ Public Overrides Function ParseObject(str As String) As Object
+ Return str
+ End Function
+ End Class
+
+ Public Class IntegerCaster : Inherits TypeCaster(Of Integer)
+
+ Public Overrides Function GetBytes(value As Object) As Byte()
+ Return BitConverter.GetBytes(DirectCast(value, Integer))
+ End Function
+
+ Public Overrides Function GetString(value As Object) As String
+ Return DirectCast(value, Integer).ToString
+ End Function
+
+ Public Overrides Function ToObject(bytes() As Byte) As Object
+ Return BitConverter.ToInt32(bytes, Scan0)
+ End Function
+
+ Public Overrides Function ParseObject(str As String) As Object
+ Return Integer.Parse(str)
+ End Function
+ End Class
+
+ Public Class DoubleCaster : Inherits TypeCaster(Of Double)
+
+ Public Overrides Function GetBytes(value As Object) As Byte()
+ Return BitConverter.GetBytes(DirectCast(value, Double))
+ End Function
+
+ Public Overrides Function GetString(value As Object) As String
+ Return DirectCast(value, Double).ToString
+ End Function
+
+ Public Overrides Function ToObject(bytes() As Byte) As Object
+ Return BitConverter.ToDouble(bytes, Scan0)
+ End Function
+
+ Public Overrides Function ParseObject(str As String) As Object
+ Return Double.Parse(str)
+ End Function
+ End Class
+
+ Public Class DateCaster : Inherits TypeCaster(Of Date)
+
+ Public Overrides Function GetBytes(value As Object) As Byte()
+ Return BitConverter.GetBytes(DirectCast(value, Date).ToBinary)
+ End Function
+
+ Public Overrides Function GetString(value As Object) As String
+ Return DirectCast(value, Date).ToString
+ End Function
+
+ Public Overrides Function ToObject(bytes() As Byte) As Object
+ Return Date.FromBinary(BitConverter.ToInt64(bytes, Scan0))
+ End Function
+
+ Public Overrides Function ParseObject(str As String) As Object
+ Return Date.Parse(str)
+ End Function
+ End Class
+End Namespace
diff --git a/Extensions/CodeDOM/CodeDOM.vb b/Extensions/CodeDOM/CodeDOM.vb
index 78161526..8ef9260d 100644
--- a/Extensions/CodeDOM/CodeDOM.vb
+++ b/Extensions/CodeDOM/CodeDOM.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e99753ec5166b18cdaceb4e0fe015449, Extensions\CodeDOM\CodeDOM.vb"
+#Region "Microsoft.VisualBasic::e99753ec5166b18cdaceb4e0fe015449, Microsoft.VisualBasic.Core\Extensions\CodeDOM\CodeDOM.vb"
' Author:
'
diff --git a/Extensions/CodeDOM/CodeDOMExpressions.vb b/Extensions/CodeDOM/CodeDOMExpressions.vb
index cd9acd26..741aa79b 100644
--- a/Extensions/CodeDOM/CodeDOMExpressions.vb
+++ b/Extensions/CodeDOM/CodeDOMExpressions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::062abf9170cbd65288b462d737aac04f, Extensions\CodeDOM\CodeDOMExpressions.vb"
+#Region "Microsoft.VisualBasic::062abf9170cbd65288b462d737aac04f, Microsoft.VisualBasic.Core\Extensions\CodeDOM\CodeDOMExpressions.vb"
' Author:
'
diff --git a/Extensions/CodeDOM/CodeHelper.vb b/Extensions/CodeDOM/CodeHelper.vb
index 4335d072..dd753341 100644
--- a/Extensions/CodeDOM/CodeHelper.vb
+++ b/Extensions/CodeDOM/CodeHelper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a932a3b98d366ee02de011c3b4c836eb, Extensions\CodeDOM\CodeHelper.vb"
+#Region "Microsoft.VisualBasic::a932a3b98d366ee02de011c3b4c836eb, Microsoft.VisualBasic.Core\Extensions\CodeDOM\CodeHelper.vb"
' Author:
'
diff --git a/Extensions/CodeDOM/References.vb b/Extensions/CodeDOM/References.vb
index 8c5ec881..608a95fd 100644
--- a/Extensions/CodeDOM/References.vb
+++ b/Extensions/CodeDOM/References.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::17fb9b3d17c8919d3b11a0521564013d, Extensions\CodeDOM\References.vb"
+#Region "Microsoft.VisualBasic::17fb9b3d17c8919d3b11a0521564013d, Microsoft.VisualBasic.Core\Extensions\CodeDOM\References.vb"
' Author:
'
diff --git a/Extensions/CodeDOM/VBC.vb b/Extensions/CodeDOM/VBC.vb
index 4b7415d1..9e36fdf7 100644
--- a/Extensions/CodeDOM/VBC.vb
+++ b/Extensions/CodeDOM/VBC.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6a37b6f937164793150a19d2d292c16e, Extensions\CodeDOM\VBC.vb"
+#Region "Microsoft.VisualBasic::6a37b6f937164793150a19d2d292c16e, Microsoft.VisualBasic.Core\Extensions\CodeDOM\VBC.vb"
' Author:
'
diff --git a/Extensions/Collection/AnonymousTypeHelper.vb b/Extensions/Collection/AnonymousTypeHelper.vb
index ec031a88..95234b01 100644
--- a/Extensions/Collection/AnonymousTypeHelper.vb
+++ b/Extensions/Collection/AnonymousTypeHelper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d4f476bccb1fc043519be1073163b50f, Extensions\Collection\AnonymousTypeHelper.vb"
+#Region "Microsoft.VisualBasic::d4f476bccb1fc043519be1073163b50f, Microsoft.VisualBasic.Core\Extensions\Collection\AnonymousTypeHelper.vb"
' Author:
'
diff --git a/Extensions/Collection/BucketExtensions.vb b/Extensions/Collection/BucketOperators.vb
similarity index 84%
rename from Extensions/Collection/BucketExtensions.vb
rename to Extensions/Collection/BucketOperators.vb
index 92ce560f..022f729c 100644
--- a/Extensions/Collection/BucketExtensions.vb
+++ b/Extensions/Collection/BucketOperators.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b2874cf966dde9b3b6b71e903cf32a2d, Extensions\Collection\BucketExtensions.vb"
+#Region "Microsoft.VisualBasic::051df9d9d951aea29e194e13c8232320, Microsoft.VisualBasic.Core\Extensions\Collection\BucketOperators.vb"
' Author:
'
@@ -31,7 +31,7 @@
' Summaries:
- ' Module BucketExtensions
+ ' Module BucketOperators
'
' Function: (+4 Overloads) Join, Split, SplitIterator
'
@@ -42,40 +42,43 @@
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Language
- Public Module BucketExtensions
+'''
+''' 进行集合分块切割或者合并等操作
+'''
+Public Module BucketOperators
'''
''' Data partitioning function.
- ''' (将目标集合之中的数据按照参数分配到子集合之中,
+ ''' (将目标集合之中的数据按照参数分配到子集合之中,
''' 这个函数之中不能够使用并行化Linq拓展,以保证元素之间的相互原有的顺序,
- ''' 每一个子集和之中的元素数量为)
+ ''' 每一个子集和之中的元素数量为)
'''
'''
'''
- ''' 每一个子集合之中的元素的数目
+ ''' 每一个子集合之中的元素的数目
'''
'''
- Public Function Split(Of T)(source As IEnumerable(Of T), parTokens As Integer) As T()()
- Return source.SplitIterator(parTokens).ToArray
+ Public Function Split(Of T)(source As IEnumerable(Of T), partitionSize As Integer) As T()()
+ Return source.SplitIterator(partitionSize).ToArray
End Function
'''
''' Performance the partitioning operation on the input sequence.
- ''' (请注意,这个函数只适用于数量较少的序列。对所输入的序列进行分区操作,函数参数是每一个分区里面的元素的数量)
+ ''' (请注意,这个函数只适用于数量较少的序列。对所输入的序列进行分区操作,函数参数是每一个分区里面的元素的数量)
'''
'''
'''
- '''
+ '''
'''
- Public Iterator Function SplitIterator(Of T)(source As IEnumerable(Of T), parTokens As Integer) As IEnumerable(Of T())
- Dim buffer As New List(Of T)(capacity:=parTokens)
+ Public Iterator Function SplitIterator(Of T)(source As IEnumerable(Of T), partitionSize As Integer) As IEnumerable(Of T())
+ Dim buffer As New List(Of T)(capacity:=partitionSize)
For Each item As T In source
- Call buffer.Add(item)
+ buffer += item
- If buffer >= parTokens Then
+ If buffer >= partitionSize Then
Yield buffer.ToArray
buffer *= 0
diff --git a/Extensions/Collection/ByteStreamExtensions.vb b/Extensions/Collection/ByteStreamExtensions.vb
index 62a4040f..270f23e1 100644
--- a/Extensions/Collection/ByteStreamExtensions.vb
+++ b/Extensions/Collection/ByteStreamExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8d13c139900788629b8facfbad71157c, Extensions\Collection\ByteStreamExtensions.vb"
+#Region "Microsoft.VisualBasic::8d13c139900788629b8facfbad71157c, Microsoft.VisualBasic.Core\Extensions\Collection\ByteStreamExtensions.vb"
' Author:
'
diff --git a/Extensions/Collection/CategoryOperations.vb b/Extensions/Collection/CategoryOperations.vb
new file mode 100644
index 00000000..8970c233
--- /dev/null
+++ b/Extensions/Collection/CategoryOperations.vb
@@ -0,0 +1,103 @@
+#Region "Microsoft.VisualBasic::434db169458d24f2d89ad4536406db44, Microsoft.VisualBasic.Core\Extensions\Collection\CategoryOperations.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 .
+
+
+
+ ' /********************************************************************************/
+
+ ' Summaries:
+
+ ' Module CategoryOperations
+ '
+ ' Function: AsGroups, AsNamedVector, CategoryValues, IGrouping
+ '
+ ' /********************************************************************************/
+
+#End Region
+
+Imports System.Collections.Specialized
+Imports System.Runtime.CompilerServices
+Imports Microsoft.VisualBasic.CommandLine.Reflection
+Imports Microsoft.VisualBasic.ComponentModel
+Imports Microsoft.VisualBasic.ComponentModel.Collection
+Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic
+Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
+Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Linq
+Imports Microsoft.VisualBasic.Serialization.JSON
+Imports Microsoft.VisualBasic.Text
+Imports Microsoft.VisualBasic.Text.Xml.Models
+Imports r = System.Text.RegularExpressions.Regex
+
+Public Module CategoryOperations
+
+
+ Public Function AsGroups(Of T)(table As Dictionary(Of String, T())) As IEnumerable(Of NamedCollection(Of T))
+ Return table.Select(Function(item)
+ Return New NamedCollection(Of T) With {
+ .Name = item.Key,
+ .Value = item.Value
+ }
+ End Function)
+ End Function
+
+
+
+ Public Function IGrouping(Of T)(source As IEnumerable(Of NamedCollection(Of T))) As IEnumerable(Of IGrouping(Of String, T))
+ Return source.Select(Function(x) DirectCast(x, IGrouping(Of String, T)))
+ End Function
+
+
+ Public Function AsNamedVector(Of T)(groups As IEnumerable(Of IGrouping(Of String, T))) As IEnumerable(Of NamedCollection(Of T))
+ Return groups.Select(Function(group)
+ Return New NamedCollection(Of T) With {
+ .Name = group.Key,
+ .Value = group.ToArray
+ }
+ End Function)
+ End Function
+
+ '''
+ ''' transform ``[category => items]`` to ``[item -> category][]``
+ '''
+ '''
+ '''
+ '''
+
+ Public Function CategoryValues(Of T)(categories As IEnumerable(Of NamedCollection(Of T))) As Dictionary(Of T, String)
+ Return categories _
+ .Select(Function(category)
+ Return category.Select(Function(item) (item, category.name))
+ End Function) _
+ .IteratesALL _
+ .ToDictionary(Function(val) val.Item1,
+ Function(category)
+ Return category.Item2
+ End Function)
+ End Function
+End Module
+
diff --git a/Extensions/Collection/Enumerable.vb b/Extensions/Collection/Enumerable.vb
index 9f4208ba..1f9412ce 100644
--- a/Extensions/Collection/Enumerable.vb
+++ b/Extensions/Collection/Enumerable.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1dd37d36153684f17defa3b71c50f41e, Extensions\Collection\Enumerable.vb"
+#Region "Microsoft.VisualBasic::1dd37d36153684f17defa3b71c50f41e, Microsoft.VisualBasic.Core\Extensions\Collection\Enumerable.vb"
' Author:
'
diff --git a/Extensions/Collection/IsNullOrEmptyExtensions.vb b/Extensions/Collection/IsNullOrEmptyExtensions.vb
index 6285b43a..2fce3835 100644
--- a/Extensions/Collection/IsNullOrEmptyExtensions.vb
+++ b/Extensions/Collection/IsNullOrEmptyExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d5e16014c313463cfdc1db5fb83d1bfd, Extensions\Collection\IsNullOrEmptyExtensions.vb"
+#Region "Microsoft.VisualBasic::624954b0d976d4ee1ecf713953a6fcc5, Microsoft.VisualBasic.Core\Extensions\Collection\IsNullOrEmptyExtensions.vb"
' Author:
'
@@ -48,6 +48,7 @@ Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.Vectorization
+
Public Module IsNullOrEmptyExtensions
diff --git a/Extensions/Collection/KeyValuePair.vb b/Extensions/Collection/KeyValuePair.vb
index c74ce610..f8bdde31 100644
--- a/Extensions/Collection/KeyValuePair.vb
+++ b/Extensions/Collection/KeyValuePair.vb
@@ -1,50 +1,50 @@
-#Region "Microsoft.VisualBasic::be6da859a70b35c56d45b6240422e30a, Extensions\Collection\KeyValuePair.vb"
+#Region "Microsoft.VisualBasic::4c34fe7ef695119d13070eda59ef9163, Microsoft.VisualBasic.Core\Extensions\Collection\KeyValuePair.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Module KeyValuePairExtensions
- '
- ' Function: (+3 Overloads) [Select], (+2 Overloads) Add, AsEnumerable, AsGroups, AsNamedValueTuples
- ' AsNamedVector, AsTable, ComputeIfAbsent, (+3 Overloads) ContainsKey, DictionaryData
- ' (+2 Overloads) EnumerateTuples, EnumParser, FlatTable, (+2 Overloads) GetByKey, GetValueOrDefault
- ' GroupByKey, HaveData, IGrouping, IterateNameCollections, IterateNameValues
- ' IteratesAll, Join, KeyItem, (+2 Overloads) Keys, (+2 Overloads) NamedValues
- ' (+3 Overloads) NameValueCollection, ParserDictionary, RemoveAndGet, ReverseMaps, (+2 Overloads) Selects
- ' SetOfKeyValuePairs, (+2 Overloads) Subset, tableInternal, Takes, (+3 Overloads) ToDictionary
- ' Tsv, Tuple, (+2 Overloads) Values, XMLModel
- '
- ' Sub: SortByKey, SortByValue
- '
- ' /********************************************************************************/
+' Module KeyValuePairExtensions
+'
+' Function: (+3 Overloads) [Select], (+2 Overloads) Add, AsEnumerable, AsNamedValueTuples, AsTable
+' ComputeIfAbsent, (+3 Overloads) ContainsKey, DictionaryData, (+2 Overloads) EnumerateTuples, EnumParser
+' FlatTable, (+2 Overloads) GetByKey, GetValueOrDefault, GroupByKey, HaveData
+' IterateNameCollections, IterateNameValues, IteratesAll, Join, KeyItem
+' (+2 Overloads) Keys, (+2 Overloads) NamedValues, (+3 Overloads) NameValueCollection, ParserDictionary, RemoveAndGet
+' ReverseMaps, (+2 Overloads) Selects, SetOfKeyValuePairs, (+2 Overloads) Subset, tableInternal
+' Takes, (+3 Overloads) ToDictionary, ToLower, ToUpper, Tsv
+' Tuple, (+2 Overloads) Values, XMLModel
+'
+' Sub: SortByKey, SortByValue
+'
+' /********************************************************************************/
#End Region
@@ -65,8 +65,52 @@ Imports r = System.Text.RegularExpressions.Regex
'''
''' KeyValue pair data related extensions API.
'''
+'''
+
Public Module KeyValuePairExtensions
+ '''
+ ''' 从目标字典中按照给定的键名称获取值然后删除给定的键名称对应的数据
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+
+ Public Function Popout(Of K, V)(table As Dictionary(Of K, V), key As K) As V
+ If table.ContainsKey(key) Then
+ Dim value As V = table(key)
+ table.Remove(key)
+ Return value
+ Else
+ Return Nothing
+ End If
+ End Function
+
+
+ Public Function TupleTable(tuple As (String(), String())) As Dictionary(Of String, String)
+ Dim table As New Dictionary(Of String, String)
+
+ For i As Integer = 0 To tuple.Item1.Length - 1
+ Call table.Add(tuple.Item1(i), tuple.Item2(i))
+ Next
+
+ Return table
+ End Function
+
+
+
+ Public Function ToLower(Of T)(table As Dictionary(Of String, T)) As Dictionary(Of String, T)
+ Return table.ToDictionary(Function(k) k.Key.ToLower, Function(k) k.Value)
+ End Function
+
+
+
+ Public Function ToUpper(Of T)(table As Dictionary(Of String, T)) As Dictionary(Of String, T)
+ Return table.ToDictionary(Function(k) k.Key.ToUpper, Function(k) k.Value)
+ End Function
+
'''
''' 这个拓展函数主要是针对值得构建比较耗时的操作,主要应用于数据缓存场景
'''
@@ -93,7 +137,7 @@ Public Module KeyValuePairExtensions
- Public Function Selects(Of K, V)(table As Dictionary(Of K, V), ParamArray keys As K()) As IEnumerable
+ Public Function Selects(Of K, V)(table As Dictionary(Of K, V), ParamArray keys As K()) As IEnumerable(Of V)
Return From key As K In keys Select table(key)
End Function
@@ -217,13 +261,20 @@ Public Module KeyValuePairExtensions
'''
- Public Function Subset(Of T)(table As Dictionary(Of String, T), keys$()) As Dictionary(Of String, T)
- Return keys _
- .Select(Function(key)
- Return (key:=key, val:=table(key))
- End Function) _
- .ToDictionary(Function(o) o.key,
- Function(o) o.val)
+ Public Function Subset(Of T)(table As Dictionary(Of String, T), keys$(), Optional ignoreMissing As Boolean = False) As Dictionary(Of String, T)
+ If ignoreMissing Then
+ Return keys _
+ .Where(AddressOf table.ContainsKey) _
+ .ToDictionary(Function(key) key,
+ Function(key)
+ Return table(key)
+ End Function)
+ Else
+ Return keys.ToDictionary(Function(key) key,
+ Function(key)
+ Return table(key)
+ End Function)
+ End If
End Function
@@ -283,37 +334,12 @@ Public Module KeyValuePairExtensions
Next
End Function
- Public Function AsNamedVector(Of T)(groups As IEnumerable(Of IGrouping(Of String, T))) As IEnumerable(Of NamedCollection(Of T))
- Return groups.Select(Function(group)
- Return New NamedCollection(Of T) With {
- .Name = group.Key,
- .Value = group.ToArray
- }
- End Function)
- End Function
-
Public Function AsNamedValueTuples(Of T)(tuples As IEnumerable(Of KeyValuePair(Of String, T))) As IEnumerable(Of NamedValue(Of T))
Return tuples.Select(Function(p) New NamedValue(Of T)(p.Key, p.Value))
End Function
-
- Public Function AsGroups(Of T)(table As Dictionary(Of String, T())) As IEnumerable(Of NamedCollection(Of T))
- Return table.Select(Function(item)
- Return New NamedCollection(Of T) With {
- .Name = item.Key,
- .Value = item.Value
- }
- End Function)
- End Function
-
-
-
- Public Function IGrouping(Of T)(source As IEnumerable(Of NamedCollection(Of T))) As IEnumerable(Of IGrouping(Of String, T))
- Return source.Select(Function(x) DirectCast(x, IGrouping(Of String, T)))
- End Function
-
'''
''' Removes the target key in the dictionary table, and then gets the removed value.
''' (删除字典之中的指定的键值对,然后返回被删除的数据值)
@@ -338,7 +364,7 @@ Public Module KeyValuePairExtensions
'''
Public Function IteratesAll(Of T As INamedValue)(source As IEnumerable(Of NamedCollection(Of T))) As T()
- Return source.Select(Function(c) c.Value).IteratesALL.ToArray
+ Return source.Select(Function(c) c.value).IteratesALL.ToArray
End Function
'''
@@ -353,8 +379,8 @@ Public Module KeyValuePairExtensions
.GroupBy(Function(o) o.Key) _
.Select(Function(g)
Return New NamedCollection(Of T) With {
- .Name = g.Key,
- .Value = g.ToArray
+ .name = g.Key,
+ .value = g.ToArray
}
End Function) _
.ToArray
diff --git a/Extensions/Collection/Linq/Enumeration.vb b/Extensions/Collection/Linq/Enumeration.vb
index 8595ea92..dae191fd 100644
--- a/Extensions/Collection/Linq/Enumeration.vb
+++ b/Extensions/Collection/Linq/Enumeration.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c3aab7de20209777ad612db67e2ee059, Extensions\Collection\Linq\Enumeration.vb"
+#Region "Microsoft.VisualBasic::207b8c7e8f905170be918a69f5f6cc7f, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Enumeration.vb"
' Author:
'
@@ -37,7 +37,7 @@
'
' Module EnumerationExtensions
'
- ' Function: AsEnumerable
+ ' Function: AsEnumerable, AsObjectEnumerator
' Class Enumerator
'
' Function: GetEnumerator, IEnumerable_GetEnumerator
@@ -98,6 +98,36 @@ Namespace Linq
End Function
End Class
+ '''
+ ''' 将一个对象转换为一个对象的枚举序列
+ '''
+ '''
+ '''
+ '''
+ ''' 使用这个拓展函数的原因是对象不能够产生对象的枚举序列用于Linq拓展函数
+ '''
+
+ Public Iterator Function AsObjectEnumerator(enums As Array) As IEnumerable(Of Object)
+ For Each element As Object In enums
+ Yield element
+ Next
+ End Function
+
+ '''
+ ''' 将一个对象转换为一个对象的枚举序列
+ '''
+ '''
+ '''
+ '''
+ ''' 使用这个拓展函数的原因是对象不能够产生对象的枚举序列用于Linq拓展函数
+ '''
+
+ Public Iterator Function AsObjectEnumerator(Of T)(enums As Array) As IEnumerable(Of T)
+ For Each element As Object In enums
+ Yield DirectCast(element, T)
+ Next
+ End Function
+
'''
''' Returns the input typed as .
'''
@@ -108,7 +138,13 @@ Namespace Linq
Public Function AsEnumerable(Of T)(enums As Enumeration(Of T)) As IEnumerable(Of T)
- Return New Enumerator(Of T) With {.Enumeration = enums}
+ If enums Is Nothing Then
+ Return {}
+ Else
+ Return New Enumerator(Of T) With {
+ .Enumeration = enums
+ }
+ End If
End Function
End Module
End Namespace
diff --git a/Extensions/Collection/Linq/Iterator.vb b/Extensions/Collection/Linq/Iterator.vb
index 3dd2993d..b035a3af 100644
--- a/Extensions/Collection/Linq/Iterator.vb
+++ b/Extensions/Collection/Linq/Iterator.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4f967b32a35764690c19ec884768c35f, Extensions\Collection\Linq\Iterator.vb"
+#Region "Microsoft.VisualBasic::bb00189b6576ae1fa45c9498bd125215, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Iterator.vb"
' Author:
'
@@ -46,6 +46,7 @@ Imports Microsoft.VisualBasic.Language
Namespace Linq
+
Public Module IteratorExtensions
diff --git a/Extensions/Collection/Linq/Linq.vb b/Extensions/Collection/Linq/Linq.vb
index 2a60c781..c57de360 100644
--- a/Extensions/Collection/Linq/Linq.vb
+++ b/Extensions/Collection/Linq/Linq.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::157301c28eb348f8edfe58d6477fadcb, Extensions\Collection\Linq\Linq.vb"
+#Region "Microsoft.VisualBasic::4d437d0440fa9495dffb10e273c2b53b, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Linq.vb"
' Author:
'
@@ -60,6 +60,7 @@ Namespace Linq
'''
+
Public Module Extensions
'''
@@ -87,6 +88,12 @@ Namespace Linq
Return New DataValue(Of T)(src)
End Function
+ '''
+ ''' DirectCast of the sequence into T() array.
+ '''
+ '''
+ '''
+ '''
Public Function ToArray(Of T)(source As IEnumerable(Of Object)) As T()
If source Is Nothing Then
@@ -115,6 +122,15 @@ Namespace Linq
End If
End Function
+
+ Public Function SafeQuery(Of T)(source As Enumeration(Of T)) As IEnumerable(Of T)
+ If source Is Nothing Then
+ Return {}
+ Else
+ Return source.AsEnumerable
+ End If
+ End Function
+
Public Delegate Sub DoWith(Of T)(obj As T)
'''
diff --git a/Extensions/Collection/Linq/NumericSequence.vb b/Extensions/Collection/Linq/NumericSequence.vb
index 6e069998..251a7f37 100644
--- a/Extensions/Collection/Linq/NumericSequence.vb
+++ b/Extensions/Collection/Linq/NumericSequence.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::95155070099b2ba9b2814538e446dacd, Extensions\Collection\Linq\NumericSequence.vb"
+#Region "Microsoft.VisualBasic::95155070099b2ba9b2814538e446dacd, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\NumericSequence.vb"
' Author:
'
diff --git a/Extensions/Collection/Linq/Pipeline.vb b/Extensions/Collection/Linq/Pipeline.vb
index c6c80776..185e1713 100644
--- a/Extensions/Collection/Linq/Pipeline.vb
+++ b/Extensions/Collection/Linq/Pipeline.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d9677feaaf50ab1429a4c83031821160, Extensions\Collection\Linq\Pipeline.vb"
+#Region "Microsoft.VisualBasic::abed2ce454022b1fc8bd07931ab2dc5c, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Pipeline.vb"
' Author:
'
@@ -33,7 +33,7 @@
' Module PipelineExtensions
'
- ' Function: DoCall
+ ' Function: DoCall, PipeOf
'
' Sub: DoCall
'
@@ -46,7 +46,7 @@ Imports System.Runtime.CompilerServices
Namespace Linq
- Public Module PipelineExtensions
+ Public Module PipelineExtensions
'''
''' Delegate pipeline function
@@ -73,5 +73,10 @@ Namespace Linq
Public Sub DoCall(Of T)(input As T, apply As Action(Of T))
Call apply(input)
End Sub
+
+
+ Public Function PipeOf(Of T, Rest)(input As T, task As Action(Of T, Rest)) As Action(Of Rest)
+ Return Sub(a) task(input, a)
+ End Function
End Module
End Namespace
diff --git a/Extensions/Collection/Linq/SeqValue.vb b/Extensions/Collection/Linq/SeqValue.vb
index 248e9ca3..79b054fc 100644
--- a/Extensions/Collection/Linq/SeqValue.vb
+++ b/Extensions/Collection/Linq/SeqValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::14c04f9e275fa69452350d6e3f26a155, Extensions\Collection\Linq\SeqValue.vb"
+#Region "Microsoft.VisualBasic::14c04f9e275fa69452350d6e3f26a155, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\SeqValue.vb"
' Author:
'
diff --git a/Extensions/Collection/Linq/SetValue.vb b/Extensions/Collection/Linq/SetValue.vb
index b142496c..2a748cb9 100644
--- a/Extensions/Collection/Linq/SetValue.vb
+++ b/Extensions/Collection/Linq/SetValue.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fb23f87e901dbe3b09902ba28ad2c6d1, Extensions\Collection\Linq\SetValue.vb"
+#Region "Microsoft.VisualBasic::fb23f87e901dbe3b09902ba28ad2c6d1, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\SetValue.vb"
' Author:
'
diff --git a/Extensions/Collection/Linq/Takes.vb b/Extensions/Collection/Linq/Takes.vb
index e01736a0..b91ac97f 100644
--- a/Extensions/Collection/Linq/Takes.vb
+++ b/Extensions/Collection/Linq/Takes.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5bb371dabfa029b99aea6eec5d9d3744, Extensions\Collection\Linq\Takes.vb"
+#Region "Microsoft.VisualBasic::c2368b41d83cc9e285798beca0da0501, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Takes.vb"
' Author:
'
@@ -71,15 +71,11 @@ Namespace Linq
'''
'''
'''
+ '''
+
- Public Iterator Function Takes(Of T)(source As IEnumerable(Of T), flags As Boolean()) As IEnumerable(Of T)
- Dim i As VBInteger = 0
-
- For Each obj As T In source
- If flags(++i) Then
- Yield obj
- End If
- Next
+ Public Function Takes(Of T)(source As IEnumerable(Of T), flags As Boolean()) As IEnumerable(Of T)
+ Return source.Where(Function(obj, i) flags(i))
End Function
'''
diff --git a/Extensions/Collection/Linq/VectorAssertExtensions.vb b/Extensions/Collection/Linq/VectorAssertExtensions.vb
index 7ccee9f1..e7768678 100644
--- a/Extensions/Collection/Linq/VectorAssertExtensions.vb
+++ b/Extensions/Collection/Linq/VectorAssertExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2aa1d595aa123f2c055f05a31040cfd1, Extensions\Collection\Linq\VectorAssertExtensions.vb"
+#Region "Microsoft.VisualBasic::30f0809533229e3dc85abb86041f8892, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\VectorAssertExtensions.vb"
' Author:
'
@@ -46,6 +46,7 @@ Imports Microsoft.VisualBasic.Linq
Namespace Linq
+
Public Module VectorAssertExtensions
'''
diff --git a/Extensions/Collection/Linq/VectorAssertor.vb b/Extensions/Collection/Linq/VectorAssertor.vb
index 2dd79d1a..789ab6fe 100644
--- a/Extensions/Collection/Linq/VectorAssertor.vb
+++ b/Extensions/Collection/Linq/VectorAssertor.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::730427f4a9abf5b32dc2a672b92d2ec2, Extensions\Collection\Linq\VectorAssertor.vb"
+#Region "Microsoft.VisualBasic::730427f4a9abf5b32dc2a672b92d2ec2, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\VectorAssertor.vb"
' Author:
'
diff --git a/Extensions/Collection/Linq/Which.vb b/Extensions/Collection/Linq/Which.vb
index 7f784a34..d7138e8a 100644
--- a/Extensions/Collection/Linq/Which.vb
+++ b/Extensions/Collection/Linq/Which.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f46156ba68fd9ebc213a08670dd4b462, Extensions\Collection\Linq\Which.vb"
+#Region "Microsoft.VisualBasic::f46156ba68fd9ebc213a08670dd4b462, Microsoft.VisualBasic.Core\Extensions\Collection\Linq\Which.vb"
' Author:
'
diff --git a/Extensions/Collection/ListExtensions.vb b/Extensions/Collection/ListExtensions.vb
index abc6da4f..a4269dce 100644
--- a/Extensions/Collection/ListExtensions.vb
+++ b/Extensions/Collection/ListExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b8f5d35527c282e7618a88f09171b0a6, Extensions\Collection\ListExtensions.vb"
+#Region "Microsoft.VisualBasic::60fb88c016e2a1f955bfe3846e73a073, Microsoft.VisualBasic.Core\Extensions\Collection\ListExtensions.vb"
' Author:
'
@@ -150,29 +150,38 @@ Public Module ListExtensions
Dim list2 As New List(Of T)
Dim internalGet_geneObj =
Function(id As String)
- Dim query = From x
+ ' 假若是对基因组进行排序,可能getkey函数只获取得到的是编号,而customOrder之中还会包含有全称,所以用InStr判断一下?
+ Dim query = From element As T
In ls.AsParallel
- Let key As String = getKey(x)
- Where key.TextEquals(id) OrElse
- InStr(key, id, CompareMethod.Text) > 0 ' 假若是对基因组进行排序,可能getkey函数只获取得到的是编号,而customOrder之中还会包含有全称,所以用InStr判断一下?
- Select x '
+ Let key As String = getKey(element)
+ Where key.TextEquals(id) OrElse InStr(key, id, CompareMethod.Text) > 0
+ Select element
+
Return query.FirstOrDefault
End Function
For Each ID As String In customOrder
Dim selectedItem As T = internalGet_geneObj(ID)
- If Not selectedItem Is Nothing Then ' 由于是倒序的,故而将对象移动到最后一个元素即可
+ ' 由于是倒序的,故而将对象移动到最后一个元素即可
+ If Not selectedItem Is Nothing Then
Call list2.Add(selectedItem)
Call ls.Remove(selectedItem)
End If
Next
- Call list2.AddRange(ls) ' 添加剩余的没有在customOrder之中找到的数据
+ ' 添加剩余的没有在customOrder之中找到的数据
+ Call list2.AddRange(ls)
Return list2
End Function
+ '''
+ ''' 从一个对象集合中创建索引,请注意,传递进入这个函数的参数应该是经过去重操作之后的数据
+ '''
+ '''
+ '''
+ '''
Public Function Indexing(Of T)(source As IEnumerable(Of T)) As Index(Of T)
diff --git a/Extensions/Collection/Matrix.vb b/Extensions/Collection/Matrix.vb
index 78915507..dfc13b49 100644
--- a/Extensions/Collection/Matrix.vb
+++ b/Extensions/Collection/Matrix.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::44bec93731efa49cd5c9e88b17824d27, Extensions\Collection\Matrix.vb"
+#Region "Microsoft.VisualBasic::2ceabba60966867b6989805e5fac6abd, Microsoft.VisualBasic.Core\Extensions\Collection\Matrix.vb"
' Author:
'
@@ -33,9 +33,9 @@
' Module MatrixExtensions
'
- ' Function: DATA, GetCol, GetRow, GetSize, MAT
- ' (+2 Overloads) Matrix, Rectangle, RowIterator, SetCol, SetRow
- ' SizeOf, ToFloatMatrix, ToMatrix, ToVectorList
+ ' Function: DATA, DimensionSizeOf, GetCol, GetRow, GetSize
+ ' MAT, (+2 Overloads) Matrix, Rectangle, RowIterator, SetCol
+ ' SetRow, ToFloatMatrix, ToMatrix, ToVectorList
'
' /********************************************************************************/
@@ -158,9 +158,15 @@ Public Module MatrixExtensions
Return newMatrix
End Function
+ '''
+ ''' Measure the dimension size of the rectangle array.
+ '''
+ '''
+ '''
+ '''
- Public Function SizeOf(Of T)(rect As T()()) As Size
+ Public Function DimensionSizeOf(Of T)(rect As T()()) As Size
Return New Size With {
.Width = rect(Scan0).Length,
.Height = rect.Length
diff --git a/Extensions/Collection/Vector.vb b/Extensions/Collection/Vector.vb
index 78e6f118..87a93994 100644
--- a/Extensions/Collection/Vector.vb
+++ b/Extensions/Collection/Vector.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::30a099d1490b4b86e4a02b1e6d2f963d, Extensions\Collection\Vector.vb"
+#Region "Microsoft.VisualBasic::ce2df7a59972d694106c33828b71d099, Microsoft.VisualBasic.Core\Extensions\Collection\Vector.vb"
' Author:
'
@@ -35,7 +35,7 @@
'
' Function: (+2 Overloads) After, Append, Coalesce, (+3 Overloads) Delete, (+2 Overloads) Fill
' GetRange, IndexOf, Last, LoadAsNumericVector, MappingData
- ' Midv, RepeatCalls, Replicate, (+2 Overloads) Sort, Split
+ ' Midv, RepeatCalls, Replicate, (+3 Overloads) Sort, Split
' VectorShadows
'
' Sub: (+4 Overloads) Add, InsertAt, (+2 Overloads) Memset
@@ -64,12 +64,37 @@ Imports Microsoft.VisualBasic.Language.Vectorization
Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Linq.Extensions
Imports Microsoft.VisualBasic.Linq.IteratorExtensions
+Imports Microsoft.VisualBasic.My.JavaScript.Linq
'''
''' Extension methods for the .NET object sequence
'''
+'''
+
Public Module VectorExtensions
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
+ ''' 是否修改原始输入的序列? 否则会创建一个新的数组序列返回
+ '''
+
+
+ Public Function Sort(Of T)(ByRef a As T(), compares As Comparison(Of T), Optional modification As Boolean = True) As T()
+ If modification Then
+ Call Array.Sort(a, compares)
+ Else
+ Return a.AsEnumerable _
+ .Sort(compares) _
+ .ToArray
+ End If
+
+ Return a
+ End Function
+
'''
''' 使用产生一个长度元素的目标序列
'''
@@ -100,12 +125,13 @@ Public Module VectorExtensions
End Function
'''
- ''' Dynamics add a element into the target array.
+ ''' Dynamics add a element into the target array.(注意:不推荐使用这个函数来频繁的向数组中添加元素,这个函数会频繁的分配内存,效率非常低)
'''
'''
'''
'''
- Public Sub Add(Of T)(ByRef vector As T(), value As T)
+
+ Public Sub Add(Of T)(ByRef vector As T(), value As T)
If vector.IsNullOrEmpty Then
vector = {value}
Else
@@ -224,7 +250,7 @@ Public Module VectorExtensions
Public Function Fill(Of T)(ByRef vector As T(),
data As IEnumerable(Of T),
- start As VBInteger,
+ start As i32,
Optional reverse As Boolean = False) As T()
If start < 0 Then
start = vector.Length + start.Value
diff --git a/Extensions/Doc/LargeTextFile.vb b/Extensions/Doc/LargeTextFile.vb
index 23bc1a97..fb41ff5e 100644
--- a/Extensions/Doc/LargeTextFile.vb
+++ b/Extensions/Doc/LargeTextFile.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::35b98f098b8ac4571c78e8ce214c30ae, Extensions\Doc\LargeTextFile.vb"
+#Region "Microsoft.VisualBasic::35b98f098b8ac4571c78e8ce214c30ae, Microsoft.VisualBasic.Core\Extensions\Doc\LargeTextFile.vb"
' Author:
'
diff --git a/Extensions/Doc/PartitionedStream.vb b/Extensions/Doc/PartitionedStream.vb
index cd88c5cc..46741d35 100644
--- a/Extensions/Doc/PartitionedStream.vb
+++ b/Extensions/Doc/PartitionedStream.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::349dba59af30a71bbdc1a237da4f671c, Extensions\Doc\PartitionedStream.vb"
+#Region "Microsoft.VisualBasic::349dba59af30a71bbdc1a237da4f671c, Microsoft.VisualBasic.Core\Extensions\Doc\PartitionedStream.vb"
' Author:
'
diff --git a/Extensions/Doc/Text.vb b/Extensions/Doc/Text.vb
index 57ad61c3..93539727 100644
--- a/Extensions/Doc/Text.vb
+++ b/Extensions/Doc/Text.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::400f086acc384a348306716fc505f3ed, Extensions\Doc\Text.vb"
+#Region "Microsoft.VisualBasic::e5a620c86564678f819b3f227ef922bf, Microsoft.VisualBasic.Core\Extensions\Doc\Text.vb"
' Author:
'
@@ -214,6 +214,10 @@ Public Module TextDoc
'''
'''
Public Function ReadFirstLine(path$, Optional encoding As Encoding = Nothing) As String
+ If path.FileLength <= 0 Then
+ Return ""
+ End If
+
Using file As New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)
Using reader As New StreamReader(file, encoding Or DefaultEncoding)
Dim first$ = reader.ReadLine
diff --git a/Extensions/Doc/XmlExtensions.vb b/Extensions/Doc/XmlExtensions.vb
index 55282148..f8f3308c 100644
--- a/Extensions/Doc/XmlExtensions.vb
+++ b/Extensions/Doc/XmlExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0f0a1457babe6094d042d9534c9a9e52, Extensions\Doc\XmlExtensions.vb"
+#Region "Microsoft.VisualBasic::0f0a1457babe6094d042d9534c9a9e52, Microsoft.VisualBasic.Core\Extensions\Doc\XmlExtensions.vb"
' Author:
'
diff --git a/Extensions/Extensions.vb b/Extensions/Extensions.vb
index bcee97b6..21783d4a 100644
--- a/Extensions/Extensions.vb
+++ b/Extensions/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::6433d6d8b6a514a8f1ff9c7a7624890b, Extensions\Extensions.vb"
+#Region "Microsoft.VisualBasic::6433d6d8b6a514a8f1ff9c7a7624890b, Microsoft.VisualBasic.Core\Extensions\Extensions.vb"
' Author:
'
diff --git a/Extensions/IO/Extensions/Extensions.vb b/Extensions/IO/Extensions/Extensions.vb
index 5d85db69..3926e8d6 100644
--- a/Extensions/IO/Extensions/Extensions.vb
+++ b/Extensions/IO/Extensions/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dd2a158234e426a88e2e3a25a1b611e3, Extensions\IO\Extensions\Extensions.vb"
+#Region "Microsoft.VisualBasic::525b40766f7173a3cc12d8a1d5ef9a88, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\Extensions.vb"
' Author:
'
@@ -55,7 +55,8 @@ Namespace FileIO
''' 会和产生冲突,
''' 使用这个单独的拓展模块,但是位于不同的命名空间来解决这个问题。
'''
- Public Module Extensions
+ '''
+ Public Module Extensions
'''
''' Write all object into a text file by using its method.
diff --git a/Extensions/IO/Extensions/IO.vb b/Extensions/IO/Extensions/IO.vb
index e4c02a74..5720f71b 100644
--- a/Extensions/IO/Extensions/IO.vb
+++ b/Extensions/IO/Extensions/IO.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2fc962b5cafdc719056489d0069a2859, Extensions\IO\Extensions\IO.vb"
+#Region "Microsoft.VisualBasic::246ec7fd648a0710c153cd510e397a3e, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\IO.vb"
' Author:
'
@@ -58,7 +58,7 @@ Imports Microsoft.VisualBasic.Text
Public Module IOExtensions
- ReadOnly UTF8 As [Default](Of Encoding) = Encoding.UTF8
+ Public ReadOnly UTF8 As [Default](Of Encoding) = Encoding.UTF8
'''
''' Open text writer interface from a given .
@@ -164,6 +164,10 @@ Public Module IOExtensions
End If
End With
+ If path.FileName.Length > 200 Then
+ Throw New PathTooLongException(path)
+ End If
+
If doClear Then
' 在这里调用FlushStream函数的话会导致一个循环引用的问题
ClearFileBytes(path)
diff --git a/Extensions/IO/Extensions/NetFile.vb b/Extensions/IO/Extensions/NetFile.vb
index b2865384..cbf0f52d 100644
--- a/Extensions/IO/Extensions/NetFile.vb
+++ b/Extensions/IO/Extensions/NetFile.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::765d3616374e97c0d4ce0e6392c22f29, Extensions\IO\Extensions\NetFile.vb"
+#Region "Microsoft.VisualBasic::765d3616374e97c0d4ce0e6392c22f29, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\NetFile.vb"
' Author:
'
diff --git a/Extensions/IO/Extensions/PathExtensions.vb b/Extensions/IO/Extensions/PathExtensions.vb
index 0d12b012..2bb6ed4a 100644
--- a/Extensions/IO/Extensions/PathExtensions.vb
+++ b/Extensions/IO/Extensions/PathExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::4f5d0dea545dc27fb96d0c4b194c8f5d, Extensions\IO\Extensions\PathExtensions.vb"
+#Region "Microsoft.VisualBasic::4f5d0dea545dc27fb96d0c4b194c8f5d, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\PathExtensions.vb"
' Author:
'
@@ -54,10 +54,7 @@ Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports System.Text
Imports Microsoft.VisualBasic.CommandLine.Reflection
-Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.FileIO
-Imports Microsoft.VisualBasic.FileIO.Path
-Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Language.Default
Imports Microsoft.VisualBasic.Language.UnixBash
Imports Microsoft.VisualBasic.Linq.Extensions
@@ -333,7 +330,7 @@ Public Module PathExtensions
'''
'''
'''
-
+
Public Function ToFileURL(path As String) As String
If String.IsNullOrEmpty(path) Then
Return ""
@@ -553,7 +550,7 @@ Public Module PathExtensions
'''
'''
#If FRAMEWORD_CORE Then
-
+
Public Function FileExists(path$, Optional ZERO_Nonexists As Boolean = False) As Boolean
#Else
Public Function FileExists(path As String) As Boolean
@@ -590,7 +587,7 @@ Public Module PathExtensions
'''
'''
'''
-
+
Public Function DirectoryExists(DIR As String) As Boolean
@@ -618,7 +615,7 @@ Public Module PathExtensions
'''
'''
-
+
Public Function FileOpened(FileName As String) As Boolean
Try
Using FileOpenDetect As New FileStream(
@@ -649,7 +646,7 @@ Public Module PathExtensions
''' 所以在这里为了更加方便的兼容文件夹或者文件路径,在这使用字符串的方法来
''' 进行截取
'''
-
+
Public Function BaseName(fsObj$, Optional allowEmpty As Boolean = False) As String
If fsObj.StringEmpty Then
If allowEmpty Then
@@ -677,17 +674,6 @@ Public Module PathExtensions
Return name
End Function
- '''
- ''' shortcuts extension.
- '''
- '''
- '''
- '''
-
- Public Function GetBaseName(path As String) As String
- Return BaseName(path)
- End Function
-
'''
''' Gets the name of the file's parent directory, returns value is a name, not path.
''' (获取目标文件的父文件夹的文件夹名称,是名称而非路径)
@@ -746,205 +732,14 @@ Public Module PathExtensions
End Function
'''
- '''
- '''
- '''
- '''
- ''' 元素的排布是有顺序的
- '''
- '''
- '''
-
- Public Function GetFile(DIR As String,
- keyword As String,
- ParamArray ext As String()) _
- As String()
-
- Dim Files As IEnumerable(Of String) = ls - l - wildcards(ext) <= DIR
- Dim matches = (From Path As String
- In Files.AsParallel
- Let NameID = BaseName(Path)
- Where InStr(NameID, keyword, CompareMethod.Text) > 0
- Let ExtValue = Path.Split("."c).Last
- Select Path,
- ExtValue)
- Dim LQuery =
- From extType As String
- In ext
- Select From path
- In matches
- Where InStr(extType, path.ExtValue, CompareMethod.Text) > 0
- Select path.Path
- Return LQuery.IteratesALL.Distinct.ToArray
- End Function
-
- '''
- ''' [,这个函数会扫描目标文件夹下面的所有文件。]
- ''' 请注意,本方法是不能够产生具有相同的主文件名的数据的。假若目标GBK是使用本模块之中的方法保存或者导出来的,
- ''' 则可以使用本方法生成Entry列表;(在返回的结果之中,KEY为文件名,没有拓展名,VALUE为文件的路径)
- '''
- '''
- '''
- '''
- '''
-
-
- Public Function LoadSourceEntryList( source As String,
- ext As String(),
- Optional topLevel As Boolean = True) As Dictionary(Of String, String)
-
- If ext.IsNullOrEmpty Then
- ext = {"*.*"}
- End If
-
- Dim LQuery = (From path As String
- In If(topLevel, ls - l, ls - l - r) - wildcards(ext) <= source
- Select ID = BaseName(path),
- path
- Group By ID Into Group).ToArray
-
- ext = LinqAPI.Exec(Of String) <= From value As String
- In ext
- Select value.Split(CChar(".")).Last.ToLower
-
- Dim res As Dictionary(Of String, String) = LQuery _
- .ToDictionary(Function(x) x.ID,
- Function(x)
-
- Return LinqAPI.DefaultFirst(Of String) _
- _
- () <= From path
- In x.Group
- Let pathValue = path.path
- Let extValue As String = pathValue.Split("."c).Last.ToLower
- Where Array.IndexOf(ext, extValue) > -1
- Select pathValue
-
- End Function)
-
- With From entry
- In res
- Where Not String.IsNullOrEmpty(entry.Value)
- Select entry
-
- res = .ToDictionary(Function(x) x.Key,
- Function(x) x.Value)
- End With
-
- Call $"{NameOf(ProgramPathSearchTool)} load {res.Count} source entry...".__DEBUG_ECHO
-
- Return res
- End Function
-
- '''
- ''' 可以使用本方法生成Entry列表;(在返回的结果之中,KEY为文件名,没有拓展名,VALUE为文件的路径)
- ''' 请注意,这个函数会搜索目标文件夹下面的所有的文件夹的
- '''
- '''
- ''' 文件类型的拓展名称
- '''
- '''
- Public Function LoadSourceEntryList(source$, ParamArray ext$()) As Dictionary(Of String, String)
- If Not FileIO.FileSystem.DirectoryExists(source) Then
- Return New Dictionary(Of String, String)
- End If
-
- Dim LQuery = From path As String
- In FileIO.FileSystem.GetFiles(source, FileIO.SearchOption.SearchAllSubDirectories, ext)
- Select ID = BaseName(path),
- path
- Group By ID Into Group
- Dim dict As Dictionary(Of String, String) =
- LQuery.ToDictionary(Function(x) x.ID,
- Function(x) x.Group.First.path)
- Return dict
- End Function
-
- '''
- ''' 允许有重复的数据
- '''
- '''
- '''
- '''
- '''
-
-
- Public Function LoadEntryList( DIR$, ParamArray exts$()) As NamedValue(Of String)()
- Return LinqAPI.Exec(Of NamedValue(Of String)) _
- _
- () <= From path As String
- In ls - l - ShellSyntax.r - wildcards(exts) <= DIR
- Select New NamedValue(Of String) With {
- .Name = path.BaseName,
- .Value = path
- }
-
- End Function
-
-
-
- Public Function LoadSourceEntryList(source As IEnumerable(Of String)) As Dictionary(Of String, String)
- Dim LQuery = From path As String
- In source
- Select ID = BaseName(path),
- path
- Group By ID Into Group
- Dim res As Dictionary(Of String, String) =
- LQuery.ToDictionary(Function(x) x.ID,
- Function(x) x.Group.First.path)
- Return res
- End Function
-
- '''
- ''' 将不同来源的文件复制到目标文件夹之中
- '''
- '''
- '''
- ''' 返回失败的文件列表
- '''
-
- Public Function SourceCopy(source As IEnumerable(Of String), CopyTo As String, Optional [Overrides] As Boolean = False) As String()
- Dim failedList As New List(Of String)
-
- For Each file As String In source
- Try
- Call FileIO.FileSystem.CopyFile(file, CopyTo & "/" & FileIO.FileSystem.GetFileInfo(file).Name, [Overrides])
- Catch ex As Exception
- Call failedList.Add(file)
- Call App.LogException(New Exception(file, ex))
- End Try
- Next
-
- Return failedList.ToArray
- End Function
-
-
- Public Function GetMostAppreancePath(files As IEnumerable(Of String)) As String
- If files Is Nothing Then
- Return ""
- End If
-
- Dim LQuery = From strPath As String
- In files
- Select FileIO.FileSystem.GetParentPath(strPath)
- Return LQuery _
- .TokenCount(ignoreCase:=True) _
- .OrderByDescending(Function(x) x.Value) _
- .FirstOrDefault _
- .Key
- End Function
-
- '''
- ''' 获取相对于本应用程序的目标文件的相对路径(请注意,所生成的相对路径之中的字符串最后是没有文件夹的分隔符\或者/的)
+ ''' Get the specific file system object its relative path to the application base directory.
+ '''
+ ''' (获取相对于本应用程序的目标文件的相对路径(请注意,所生成的相对路径之中的字符串最后是没有文件夹的分隔符\或者/的))
'''
'''
'''
-
+
Public Function RelativePath(path As String) As String
Return RelativePath(App.HOME, path)
End Function
@@ -957,8 +752,7 @@ Public Module PathExtensions
''' 所需要生成相对路径的目标文件系统对象的绝对路径或者相对路径
''' 是否将父目录的路径也添加进入相对路径之中?默认是
'''
-
+
Public Function RelativePath(pcFrom$, pcTo$,
Optional appendParent As Boolean = True,
Optional fixZipPath As Boolean = False) As String
@@ -1042,7 +836,7 @@ Public Module PathExtensions
'''
'''
-
+
Public Function GetFullPath(file As String) As String
Return FileIO.FileSystem.GetFileInfo(file).FullName.Replace("\", "/")
End Function
@@ -1054,7 +848,7 @@ Public Module PathExtensions
'''
''' 当程序出错误的时候记录进入日志的一个追踪目标参数,调试用
'''
-
+
Public Function GetDirectoryFullPath(dir$, Optional stack$ = Nothing) As String
Try
Return FileIO.FileSystem _
diff --git a/Extensions/IO/Extensions/SerializationIO.vb b/Extensions/IO/Extensions/SerializationIO.vb
index ff85316a..f04597ff 100644
--- a/Extensions/IO/Extensions/SerializationIO.vb
+++ b/Extensions/IO/Extensions/SerializationIO.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::f289b2fab36ed193256bcd8c3ed7652c, Extensions\IO\Extensions\SerializationIO.vb"
+#Region "Microsoft.VisualBasic::f289b2fab36ed193256bcd8c3ed7652c, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\SerializationIO.vb"
' Author:
'
diff --git a/Extensions/IO/Extensions/StreamHelper.vb b/Extensions/IO/Extensions/StreamHelper.vb
index a3b6d356..26ff9f16 100644
--- a/Extensions/IO/Extensions/StreamHelper.vb
+++ b/Extensions/IO/Extensions/StreamHelper.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::0e0b7f03fe5774e8e50fcc26f1552a74, Extensions\IO\Extensions\StreamHelper.vb"
+#Region "Microsoft.VisualBasic::183798cdc52877a3e30613de432c2d50, Microsoft.VisualBasic.Core\Extensions\IO\Extensions\StreamHelper.vb"
' Author:
'
@@ -64,7 +64,7 @@ Public Module StreamHelper
End If
Dim buffer As Byte() = New Byte(bufferSize - 1) {}
- Dim i As VBInteger = Scan0
+ Dim i As i32 = Scan0
With target Or DirectCast(New MemoryStream(), Stream).AsDefault
Do While (i = stream.Read(buffer, 0, buffer.Length)) > 0
diff --git a/Extensions/IO/IOStream.vb b/Extensions/IO/IOStream.vb
index 6929be00..665596be 100644
--- a/Extensions/IO/IOStream.vb
+++ b/Extensions/IO/IOStream.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2c8ada758c08c77859df0312c0e4ba02, Extensions\IO\IOStream.vb"
+#Region "Microsoft.VisualBasic::35513d1acd839863747dd88607d9ea23, Microsoft.VisualBasic.Core\Extensions\IO\IOStream.vb"
' Author:
'
@@ -46,8 +46,8 @@
#End Region
Imports System.Runtime.CompilerServices
-Imports Microsoft.VisualBasic.ApplicationServices
-Imports Microsoft.VisualBasic.ApplicationServices.IOHandler
+Imports Microsoft.VisualBasic.My.FrameworkInternal
+Imports Microsoft.VisualBasic.My.FrameworkInternal.IOHandler
Imports Microsoft.VisualBasic.Text
Namespace FileIO
@@ -81,6 +81,8 @@ Namespace FileIO
End Class
+
+
Public Module IOStreamExtensions
diff --git a/Extensions/IO/Path/CopyDirectory.vb b/Extensions/IO/Path/CopyDirectory.vb
index bd5c2917..ea8a536a 100644
--- a/Extensions/IO/Path/CopyDirectory.vb
+++ b/Extensions/IO/Path/CopyDirectory.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b62bde2bf71d64669151efc2987e6471, Extensions\IO\Path\CopyDirectory.vb"
+#Region "Microsoft.VisualBasic::b62bde2bf71d64669151efc2987e6471, Microsoft.VisualBasic.Core\Extensions\IO\Path\CopyDirectory.vb"
' Author:
'
diff --git a/Extensions/IO/Path/Directory.vb b/Extensions/IO/Path/Directory.vb
index 1498ccf2..4117f3ab 100644
--- a/Extensions/IO/Path/Directory.vb
+++ b/Extensions/IO/Path/Directory.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::63cbc4dd9aec4e57d75e98e7437fe50d, Extensions\IO\Path\Directory.vb"
+#Region "Microsoft.VisualBasic::63cbc4dd9aec4e57d75e98e7437fe50d, Microsoft.VisualBasic.Core\Extensions\IO\Path\Directory.vb"
' Author:
'
diff --git a/Extensions/IO/Path/Extensions.vb b/Extensions/IO/Path/Extensions.vb
index d37541bf..98b692b2 100644
--- a/Extensions/IO/Path/Extensions.vb
+++ b/Extensions/IO/Path/Extensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1b9aad55631216c0693df3837adeb35e, Extensions\IO\Path\Extensions.vb"
+#Region "Microsoft.VisualBasic::1b9aad55631216c0693df3837adeb35e, Microsoft.VisualBasic.Core\Extensions\IO\Path\Extensions.vb"
' Author:
'
diff --git a/Extensions/IO/Path/Includes.vb b/Extensions/IO/Path/Includes.vb
index b5a88cb2..018e4f35 100644
--- a/Extensions/IO/Path/Includes.vb
+++ b/Extensions/IO/Path/Includes.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b7202c8182af67db8c9484cd28e50bfd, Extensions\IO\Path\Includes.vb"
+#Region "Microsoft.VisualBasic::b7202c8182af67db8c9484cd28e50bfd, Microsoft.VisualBasic.Core\Extensions\IO\Path\Includes.vb"
' Author:
'
diff --git a/Extensions/IO/Path/PathMatch.vb b/Extensions/IO/Path/PathMatch.vb
index f2922f9d..e3dac1cf 100644
--- a/Extensions/IO/Path/PathMatch.vb
+++ b/Extensions/IO/Path/PathMatch.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::61ebdc47db0f1d4716597be0889e90ec, Extensions\IO\Path\PathMatch.vb"
+#Region "Microsoft.VisualBasic::61ebdc47db0f1d4716597be0889e90ec, Microsoft.VisualBasic.Core\Extensions\IO\Path\PathMatch.vb"
' Author:
'
diff --git a/Extensions/IO/Path/ProgramPathSearchTool.vb b/Extensions/IO/Path/ProgramPathSearchTool.vb
index d06da59d..a0297175 100644
--- a/Extensions/IO/Path/ProgramPathSearchTool.vb
+++ b/Extensions/IO/Path/ProgramPathSearchTool.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::69ea48bcfccd3737ab9c2660a4589dd6, Extensions\IO\Path\ProgramPathSearchTool.vb"
+#Region "Microsoft.VisualBasic::69ea48bcfccd3737ab9c2660a4589dd6, Microsoft.VisualBasic.Core\Extensions\IO\Path\ProgramPathSearchTool.vb"
' Author:
'
diff --git a/Extensions/IO/Path/TemporaryEnvironment.vb b/Extensions/IO/Path/TemporaryEnvironment.vb
index 83ea6023..d811054c 100644
--- a/Extensions/IO/Path/TemporaryEnvironment.vb
+++ b/Extensions/IO/Path/TemporaryEnvironment.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::652e836aa26b48201bf557c4ff71967b, Extensions\IO\Path\TemporaryEnvironment.vb"
+#Region "Microsoft.VisualBasic::652e836aa26b48201bf557c4ff71967b, Microsoft.VisualBasic.Core\Extensions\IO\Path\TemporaryEnvironment.vb"
' Author:
'
diff --git a/Extensions/IO/SymLinker/HardLink.vb b/Extensions/IO/SymLinker/HardLink.vb
index f7df0460..0bef0d4a 100644
--- a/Extensions/IO/SymLinker/HardLink.vb
+++ b/Extensions/IO/SymLinker/HardLink.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::11141ac6b69c11c3cc556ac585589f7e, Extensions\IO\SymLinker\HardLink.vb"
+#Region "Microsoft.VisualBasic::11141ac6b69c11c3cc556ac585589f7e, Microsoft.VisualBasic.Core\Extensions\IO\SymLinker\HardLink.vb"
' Author:
'
diff --git a/Extensions/IO/SymLinker/JunctionPoint.vb b/Extensions/IO/SymLinker/JunctionPoint.vb
index 1d1d64a6..b41aff6b 100644
--- a/Extensions/IO/SymLinker/JunctionPoint.vb
+++ b/Extensions/IO/SymLinker/JunctionPoint.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::45cba76eb3740ed7b4fc2419ff4ccfe9, Extensions\IO\SymLinker\JunctionPoint.vb"
+#Region "Microsoft.VisualBasic::45cba76eb3740ed7b4fc2419ff4ccfe9, Microsoft.VisualBasic.Core\Extensions\IO\SymLinker\JunctionPoint.vb"
' Author:
'
diff --git a/Extensions/IO/SymLinker/SymbolicLink.vb b/Extensions/IO/SymLinker/SymbolicLink.vb
index a0d2f178..a2576ee2 100644
--- a/Extensions/IO/SymLinker/SymbolicLink.vb
+++ b/Extensions/IO/SymLinker/SymbolicLink.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3657912b74e191d47455cc60f5792cc7, Extensions\IO\SymLinker\SymbolicLink.vb"
+#Region "Microsoft.VisualBasic::3657912b74e191d47455cc60f5792cc7, Microsoft.VisualBasic.Core\Extensions\IO\SymLinker\SymbolicLink.vb"
' Author:
'
diff --git a/Extensions/Image/Bitmap/BitmapBuffer.vb b/Extensions/Image/Bitmap/BitmapBuffer.vb
index 93042349..2552b8b2 100644
--- a/Extensions/Image/Bitmap/BitmapBuffer.vb
+++ b/Extensions/Image/Bitmap/BitmapBuffer.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::1a312091558bad2f52a060f5e955bf87, Extensions\Image\Bitmap\BitmapBuffer.vb"
+#Region "Microsoft.VisualBasic::1a312091558bad2f52a060f5e955bf87, Microsoft.VisualBasic.Core\Extensions\Image\Bitmap\BitmapBuffer.vb"
' Author:
'
diff --git a/Extensions/Image/Bitmap/BitmapScale.vb b/Extensions/Image/Bitmap/BitmapScale.vb
index e32a4ffc..3cd3f3d3 100644
--- a/Extensions/Image/Bitmap/BitmapScale.vb
+++ b/Extensions/Image/Bitmap/BitmapScale.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8558b2fb94b68822f62a8bb63df7db18, Extensions\Image\Bitmap\BitmapScale.vb"
+#Region "Microsoft.VisualBasic::8558b2fb94b68822f62a8bb63df7db18, Microsoft.VisualBasic.Core\Extensions\Image\Bitmap\BitmapScale.vb"
' Author:
'
diff --git a/Extensions/Image/Bitmap/Effects.vb b/Extensions/Image/Bitmap/Effects.vb
index 2f3627ef..c502a806 100644
--- a/Extensions/Image/Bitmap/Effects.vb
+++ b/Extensions/Image/Bitmap/Effects.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::06ec40e2ebe79f96f8ab8b90ec897f42, Extensions\Image\Bitmap\Effects.vb"
+#Region "Microsoft.VisualBasic::06ec40e2ebe79f96f8ab8b90ec897f42, Microsoft.VisualBasic.Core\Extensions\Image\Bitmap\Effects.vb"
' Author:
'
diff --git a/Extensions/Image/Bitmap/Utils.vb b/Extensions/Image/Bitmap/Utils.vb
index fc337fd5..1c681e2a 100644
--- a/Extensions/Image/Bitmap/Utils.vb
+++ b/Extensions/Image/Bitmap/Utils.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b2be756d6700b2f582a7f0b902cbff76, Extensions\Image\Bitmap\Utils.vb"
+#Region "Microsoft.VisualBasic::b2be756d6700b2f582a7f0b902cbff76, Microsoft.VisualBasic.Core\Extensions\Image\Bitmap\Utils.vb"
' Author:
'
diff --git a/Extensions/Image/Colors/ColorCube.vb b/Extensions/Image/Colors/ColorCube.vb
index 254c89b6..d08011f5 100644
--- a/Extensions/Image/Colors/ColorCube.vb
+++ b/Extensions/Image/Colors/ColorCube.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fd36d3ab4ddefc487b00cea0e137e762, Extensions\Image\Colors\ColorCube.vb"
+#Region "Microsoft.VisualBasic::fd36d3ab4ddefc487b00cea0e137e762, Microsoft.VisualBasic.Core\Extensions\Image\Colors\ColorCube.vb"
' Author:
'
diff --git a/Extensions/Image/Colors/ColorMap.vb b/Extensions/Image/Colors/ColorMap.vb
index 0e231fd9..69633f51 100644
--- a/Extensions/Image/Colors/ColorMap.vb
+++ b/Extensions/Image/Colors/ColorMap.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e7063b31bfaa6a47452dfdac198c6b7a, Extensions\Image\Colors\ColorMap.vb"
+#Region "Microsoft.VisualBasic::cba66bc5764906a8c76972e977bc71f2, Microsoft.VisualBasic.Core\Extensions\Image\Colors\ColorMap.vb"
' Author:
'
@@ -33,7 +33,7 @@
' Module ColorMapsExtensions
'
- ' Function: (+2 Overloads) ColorSequence
+ ' Function: (+2 Overloads) ColorSequence, IsBlackOrWhite
' Delegate Function
'
'
@@ -69,6 +69,20 @@ Namespace Imaging
Public Module ColorMapsExtensions
+ '''
+ ''' Is this given color value is near black or white
+ '''
+ '''
+ '''
+
+ Public Function IsBlackOrWhite(c As Color, Optional offset As Integer = 5) As Boolean
+ Dim upperBound As Integer = 255 - offset
+ Dim isblack As Boolean = c.R <= offset AndAlso c.G <= offset AndAlso c.B <= offset
+ Dim isWhite As Boolean = c.R >= upperBound AndAlso c.G >= upperBound AndAlso c.B >= upperBound
+
+ Return isblack Or isWhite
+ End Function
+
'''
''' 大小写不敏感
'''
diff --git a/Extensions/Image/Colors/CytoscapeColor.vb b/Extensions/Image/Colors/CytoscapeColor.vb
index 3df82ff0..f5d46142 100644
--- a/Extensions/Image/Colors/CytoscapeColor.vb
+++ b/Extensions/Image/Colors/CytoscapeColor.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::aebebc4ce521646ce5bd60853ad3a50c, Extensions\Image\Colors\CytoscapeColor.vb"
+#Region "Microsoft.VisualBasic::aebebc4ce521646ce5bd60853ad3a50c, Microsoft.VisualBasic.Core\Extensions\Image\Colors\CytoscapeColor.vb"
' Author:
'
diff --git a/Extensions/Image/Colors/GDIColors.vb b/Extensions/Image/Colors/GDIColors.vb
index ca80ed1e..7a8be460 100644
--- a/Extensions/Image/Colors/GDIColors.vb
+++ b/Extensions/Image/Colors/GDIColors.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::016bef5581fc7390f7a604ca047bcbdd, Extensions\Image\Colors\GDIColors.vb"
+#Region "Microsoft.VisualBasic::016bef5581fc7390f7a604ca047bcbdd, Microsoft.VisualBasic.Core\Extensions\Image\Colors\GDIColors.vb"
' Author:
'
diff --git a/Extensions/Image/Colors/HSLColor.vb b/Extensions/Image/Colors/HSLColor.vb
index 331e2466..1073b2dd 100644
--- a/Extensions/Image/Colors/HSLColor.vb
+++ b/Extensions/Image/Colors/HSLColor.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::45855f7d800a11f96a3687251100b5fa, Extensions\Image\Colors\HSLColor.vb"
+#Region "Microsoft.VisualBasic::45855f7d800a11f96a3687251100b5fa, Microsoft.VisualBasic.Core\Extensions\Image\Colors\HSLColor.vb"
' Author:
'
diff --git a/Extensions/Image/Colors/HexColor.vb b/Extensions/Image/Colors/HexColor.vb
index d39a37ff..c61a0b6a 100644
--- a/Extensions/Image/Colors/HexColor.vb
+++ b/Extensions/Image/Colors/HexColor.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ef41705e254d691dbb8f24e0267176a3, Extensions\Image\Colors\HexColor.vb"
+#Region "Microsoft.VisualBasic::ef41705e254d691dbb8f24e0267176a3, Microsoft.VisualBasic.Core\Extensions\Image\Colors\HexColor.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/FontFace.vb b/Extensions/Image/GDI+/FontFace.vb
index 7f3988d1..59bb4d2a 100644
--- a/Extensions/Image/GDI+/FontFace.vb
+++ b/Extensions/Image/GDI+/FontFace.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::196f606a0eab968477bea059d0ec3ace, Extensions\Image\GDI+\FontFace.vb"
+#Region "Microsoft.VisualBasic::196f606a0eab968477bea059d0ec3ace, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\FontFace.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/GDICanvas.vb b/Extensions/Image/GDI+/GDICanvas.vb
index 7f15d963..a8ecf0b3 100644
--- a/Extensions/Image/GDI+/GDICanvas.vb
+++ b/Extensions/Image/GDI+/GDICanvas.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::ec414b409ccfae2670da0d33969d8b8b, Extensions\Image\GDI+\GDICanvas.vb"
+#Region "Microsoft.VisualBasic::0d97c15df631518b75bb0b2755879fe0, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\GDICanvas.vb"
' Author:
'
@@ -68,6 +68,9 @@ Imports System.Runtime.CompilerServices
Namespace Imaging
+ '''
+ ''' 这个对象是以及公用的基础类型
+ '''
Public MustInherit Class GDICanvas : Inherits IGraphics
Implements IDisposable
@@ -3909,49 +3912,27 @@ Namespace Imaging
Public Overrides Sub FillEllipse(brush As Brush, x As Integer, y As Integer, width As Integer, height As Integer)
Call Graphics.FillEllipse(brush, x, y, width, height)
End Sub
- '
- ' Summary:
- ' Fills the interior of an ellipse defined by a bounding rectangle specified by
- ' a pair of coordinates, a width, and a height.
- '
- ' Parameters:
- ' brush:
- ' System.Drawing.Brush that determines the characteristics of the fill.
- '
- ' x:
- ' The x-coordinate of the upper-left corner of the bounding rectangle that defines
- ' the ellipse.
- '
- ' y:
- ' The y-coordinate of the upper-left corner of the bounding rectangle that defines
- ' the ellipse.
- '
- ' width:
- ' Width of the bounding rectangle that defines the ellipse.
- '
- ' height:
- ' Height of the bounding rectangle that defines the ellipse.
- '
- ' Exceptions:
- ' T:System.ArgumentNullException:
- ' brush is null.
+
+ '''
+ ''' Fills the interior of an ellipse defined by a bounding rectangle specified by
+ ''' a pair of coordinates, a width, and a height.
+ '''
+ ''' System.Drawing.Brush that determines the characteristics of the fill.
+ ''' The x-coordinate of the upper-left corner of the bounding rectangle that defines
+ ''' the ellipse.
+ ''' The y-coordinate of the upper-left corner of the bounding rectangle that defines
+ ''' the ellipse.
+ ''' Width of the bounding rectangle that defines the ellipse.
+ ''' Height of the bounding rectangle that defines the ellipse.
Public Overrides Sub FillEllipse(brush As Brush, x As Single, y As Single, width As Single, height As Single)
Call Graphics.FillEllipse(brush, x, y, width, height)
End Sub
- '
- ' Summary:
- ' Fills the interior of a System.Drawing.Drawing2D.GraphicsPath.
- '
- ' Parameters:
- ' brush:
- ' System.Drawing.Brush that determines the characteristics of the fill.
- '
- ' path:
- ' System.Drawing.Drawing2D.GraphicsPath that represents the path to fill.
- '
- ' Exceptions:
- ' T:System.ArgumentNullException:
- ' brush is null.-or-path is null.
+
+ '''
+ ''' Fills the interior of a System.Drawing.Drawing2D.GraphicsPath.
+ '''
+ ''' System.Drawing.Brush that determines the characteristics of the fill.
+ ''' System.Drawing.Drawing2D.GraphicsPath that represents the path to fill.
Public Overrides Sub FillPath(brush As Brush, path As GraphicsPath)
Call Graphics.FillPath(brush, path)
End Sub
@@ -5150,10 +5131,11 @@ Namespace Imaging
#End Region
'''
- ''' Releases all resources used by this .
+ ''' Releases all resources used by this .
'''
Public Overrides Sub Dispose() Implements IDisposable.Dispose
- Call Graphics.Dispose() ' 在这里不应该将图片资源给消灭掉,只需要释放掉gdi+资源就行了
+ ' 在这里不应该将图片资源给消灭掉,只需要释放掉gdi+资源就行了
+ Call Graphics.Dispose()
End Sub
End Class
End Namespace
diff --git a/Extensions/Image/GDI+/Graphics2D.vb b/Extensions/Image/GDI+/Graphics2D.vb
index 7a98339d..b899ecb8 100644
--- a/Extensions/Image/GDI+/Graphics2D.vb
+++ b/Extensions/Image/GDI+/Graphics2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9b690cd5e7f1be5c84ee19be5d0532b1, Extensions\Image\GDI+\Graphics2D.vb"
+#Region "Microsoft.VisualBasic::9b690cd5e7f1be5c84ee19be5d0532b1, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Graphics2D.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/GraphicsExtensions.vb b/Extensions/Image/GDI+/GraphicsExtensions.vb
index e9d8a624..8e217c5c 100644
--- a/Extensions/Image/GDI+/GraphicsExtensions.vb
+++ b/Extensions/Image/GDI+/GraphicsExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dcfdfa610e8d4062f28ff78bce86805c, Extensions\Image\GDI+\GraphicsExtensions.vb"
+#Region "Microsoft.VisualBasic::29d28d1c9bf75616c338a4fb4db3decc, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\GraphicsExtensions.vb"
' Author:
'
@@ -47,6 +47,7 @@
#End Region
+Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
@@ -72,6 +73,7 @@ Namespace Imaging
Publisher:="xie.guigang@gmail.com",
Revision:=58,
Url:="http://gcmodeller.org")>
+
Public Module GraphicsExtensions
@@ -332,7 +334,10 @@ Namespace Imaging
''' 则使用这个函数则没有这个问题,在图片加载之后会立即释放掉文件句柄)
'''
'''
- '''
+ '''
+ ''' 当参数为false时候,函数返回空值的话,说明图片文件错误
+ ''' 例如文件未下载完成或者发生了二进制移码
+ '''
Public Function LoadImage(path$,
Optional base64 As Boolean = False,
@@ -387,7 +392,8 @@ Namespace Imaging
End With
End Function
-
+
+
Public Function CreateGrayBitmap(res As Image) As Image
Using g As Graphics2D = DirectCast(res.Clone, Image).CreateCanvas2D
With g
@@ -438,11 +444,13 @@ Namespace Imaging
'''
- Public Function CreateGDIDevice(r As SizeF, Optional filled As Color = Nothing) As Graphics2D
+
+ Public Function CreateGDIDevice(r As SizeF, Optional filled As Color = Nothing) As Graphics2D
Return (New Size(CInt(r.Width), CInt(r.Height))).CreateGDIDevice(filled)
End Function
- Public Function OpenDevice(ctrl As Control) As Graphics2D
+
+ Public Function OpenDevice(ctrl As Control) As Graphics2D
Dim img As Image = New Bitmap(ctrl.Width, ctrl.Height)
Dim canvas = img.CreateCanvas2D
diff --git a/Extensions/Image/GDI+/Interface.vb b/Extensions/Image/GDI+/Interface.vb
index e5ad9bcf..723dcfb0 100644
--- a/Extensions/Image/GDI+/Interface.vb
+++ b/Extensions/Image/GDI+/Interface.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::2f63e51e93c6d27b742043386c10d5bd, Extensions\Image\GDI+\Interface.vb"
+#Region "Microsoft.VisualBasic::cbf1fe46bf239d552640ce7a2ea8bd89, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Interface.vb"
' Author:
'
@@ -3463,20 +3463,12 @@ Namespace Imaging
' T:System.ArgumentNullException:
' brush is null.
Public MustOverride Sub FillEllipse(brush As Brush, x As Integer, y As Integer, width As Integer, height As Integer)
- '
- ' Summary:
- ' Fills the interior of a System.Drawing.Drawing2D.GraphicsPath.
- '
- ' Parameters:
- ' brush:
- ' System.Drawing.Brush that determines the characteristics of the fill.
- '
- ' path:
- ' System.Drawing.Drawing2D.GraphicsPath that represents the path to fill.
- '
- ' Exceptions:
- ' T:System.ArgumentNullException:
- ' brush is null.-or-path is null.
+
+ '''
+ ''' Fills the interior of a System.Drawing.Drawing2D.GraphicsPath.
+ '''
+ ''' System.Drawing.Brush that determines the characteristics of the fill.
+ ''' System.Drawing.Drawing2D.GraphicsPath that represents the path to fill.
Public MustOverride Sub FillPath(brush As Brush, path As GraphicsPath)
'
' Summary:
diff --git a/Extensions/Image/GDI+/Layouts/Abstract.vb b/Extensions/Image/GDI+/Layouts/Abstract.vb
index b85b6719..79472db8 100644
--- a/Extensions/Image/GDI+/Layouts/Abstract.vb
+++ b/Extensions/Image/GDI+/Layouts/Abstract.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::8e6a85756b8c22b42bc9fa0cfce08b6b, Extensions\Image\GDI+\Layouts\Abstract.vb"
+#Region "Microsoft.VisualBasic::8e6a85756b8c22b42bc9fa0cfce08b6b, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Layouts\Abstract.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/Layouts/ColaExtensions.vb b/Extensions/Image/GDI+/Layouts/ColaExtensions.vb
index 0b58d53c..8c00e6cc 100644
--- a/Extensions/Image/GDI+/Layouts/ColaExtensions.vb
+++ b/Extensions/Image/GDI+/Layouts/ColaExtensions.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::52d1fd2850cb177372a640f45ef31dbe, Extensions\Image\GDI+\Layouts\ColaExtensions.vb"
+#Region "Microsoft.VisualBasic::52d1fd2850cb177372a640f45ef31dbe, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Layouts\ColaExtensions.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/Layouts/Point2D.vb b/Extensions/Image/GDI+/Layouts/Point2D.vb
index 2577b60a..f6dbb1d3 100644
--- a/Extensions/Image/GDI+/Layouts/Point2D.vb
+++ b/Extensions/Image/GDI+/Layouts/Point2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::fd2474b995447806862f811aef5684ff, Extensions\Image\GDI+\Layouts\Point2D.vb"
+#Region "Microsoft.VisualBasic::fd2474b995447806862f811aef5684ff, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Layouts\Point2D.vb"
' Author:
'
diff --git a/Extensions/Image/GDI+/Layouts/Rectangle2D.vb b/Extensions/Image/GDI+/Layouts/Rectangle2D.vb
index 85c5ab12..11c44d4c 100644
--- a/Extensions/Image/GDI+/Layouts/Rectangle2D.vb
+++ b/Extensions/Image/GDI+/Layouts/Rectangle2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::36e514099caeeb4140f6a8ab98e877ea, Extensions\Image\GDI+\Layouts\Rectangle2D.vb"
+#Region "Microsoft.VisualBasic::36e514099caeeb4140f6a8ab98e877ea, Microsoft.VisualBasic.Core\Extensions\Image\GDI+\Layouts\Rectangle2D.vb"
' Author:
'
diff --git a/Extensions/Image/ImageFormat.vb b/Extensions/Image/ImageFormat.vb
index 5bfb3b75..d664d60b 100644
--- a/Extensions/Image/ImageFormat.vb
+++ b/Extensions/Image/ImageFormat.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::c57640bb26193712eea10857990983d5, Extensions\Image\ImageFormat.vb"
+#Region "Microsoft.VisualBasic::c57640bb26193712eea10857990983d5, Microsoft.VisualBasic.Core\Extensions\Image\ImageFormat.vb"
' Author:
'
diff --git a/Extensions/Image/Math/GeomTransform.vb b/Extensions/Image/Math/GeomTransform.vb
index 3e6678e3..1f7fa3f0 100644
--- a/Extensions/Image/Math/GeomTransform.vb
+++ b/Extensions/Image/Math/GeomTransform.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::11501b66fa7bf72a5a64efd475ccad78, Extensions\Image\Math\GeomTransform.vb"
+#Region "Microsoft.VisualBasic::d8bd1c6a0fc7d93851919387150272dc, Microsoft.VisualBasic.Core\Extensions\Image\Math\GeomTransform.vb"
' Author:
'
@@ -35,8 +35,8 @@
'
' Function: Angle, Area, (+2 Overloads) CalculateAngle, CenterAlign, (+2 Overloads) CentralOffset
' (+4 Overloads) Centre, CircleRectangle, (+4 Overloads) Distance, (+2 Overloads) GetBounds, GetCenter
- ' (+2 Overloads) InRegion, MirrorX, MirrorY, (+5 Overloads) OffSet2D, Offsets
- ' (+4 Overloads) Scale, ShapePoints, SquareSize
+ ' (+2 Overloads) InRegion, MirrorX, MirrorY, (+8 Overloads) OffSet2D, Offsets
+ ' (+5 Overloads) Scale, ShapePoints, SquareSize
'
'
' /********************************************************************************/
@@ -136,6 +136,33 @@ Namespace Imaging.Math2D
Return New Point(size.Width / 2, size.Height / 2)
End Function
+
+
+ Public Function OffSet2D(rect As Rectangle, offset As Point) As Rectangle
+ Return New Rectangle With {
+ .Location = rect.Location.OffSet2D(offset),
+ .Size = rect.Size
+ }
+ End Function
+
+
+
+ Public Function OffSet2D(rect As Rectangle, offset As PointF) As Rectangle
+ Return New Rectangle With {
+ .Location = rect.Location.OffSet2D(offset),
+ .Size = rect.Size
+ }
+ End Function
+
+
+
+ Public Function OffSet2D(rect As Rectangle, offsetX!, offsetY!) As Rectangle
+ Return New Rectangle With {
+ .Location = rect.Location.OffSet2D(offsetX, offsetY),
+ .Size = rect.Size
+ }
+ End Function
+
'''
''' 返回位移的新的点位置值
'''
@@ -249,6 +276,14 @@ Namespace Imaging.Math2D
Return New PointF(x, y)
End Function
+ '''
+ ''' 计算两个二维坐标的欧几里得距离
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
Public Function Distance(x1#, y1#, x2#, y2#) As Double
Return sys.Sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
@@ -354,6 +389,7 @@ Namespace Imaging.Math2D
Dim ymax = array.Max(Function(pt) pt.Y)
Dim topLeft As New PointF(xmin, ymin)
Dim size As New SizeF(xmax - xmin, ymax - ymin)
+
Return New RectangleF(topLeft, size)
End Function
@@ -414,6 +450,15 @@ Namespace Imaging.Math2D
End With
End Function
+
+ Public Function Scale(rect As Rectangle, factorX!, factorY!) As Rectangle
+ With rect
+ With New RectangleF(.Location.PointF, .Size.SizeF).Scale(New SizeF(factorX, factorY))
+ Return New Rectangle(.Location.ToPoint, .Size.ToSize)
+ End With
+ End With
+ End Function
+
'''
''' 获取目标多边形对象的中心点的坐标位置
'''
diff --git a/Extensions/Image/Math/GeometryMath.vb b/Extensions/Image/Math/GeometryMath.vb
index 845ef978..7a704a2a 100644
--- a/Extensions/Image/Math/GeometryMath.vb
+++ b/Extensions/Image/Math/GeometryMath.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::75fcb2ed92ecb1f1f378a569027e730a, Extensions\Image\Math\GeometryMath.vb"
+#Region "Microsoft.VisualBasic::75fcb2ed92ecb1f1f378a569027e730a, Microsoft.VisualBasic.Core\Extensions\Image\Math\GeometryMath.vb"
' Author:
'
diff --git a/Extensions/Image/Math/Models/Line.vb b/Extensions/Image/Math/Models/Line.vb
index 04bfcd26..714abac6 100644
--- a/Extensions/Image/Math/Models/Line.vb
+++ b/Extensions/Image/Math/Models/Line.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d95835778349348f609695497b663a28, Extensions\Image\Math\Models\Line.vb"
+#Region "Microsoft.VisualBasic::d95835778349348f609695497b663a28, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\Line.vb"
' Author:
'
diff --git a/Extensions/Image/Math/Models/PolarPoint.vb b/Extensions/Image/Math/Models/PolarPoint.vb
index 9e224a9c..9d1846bd 100644
--- a/Extensions/Image/Math/Models/PolarPoint.vb
+++ b/Extensions/Image/Math/Models/PolarPoint.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b00ccfe620212184b72ad7e8ea8c600f, Extensions\Image\Math\Models\PolarPoint.vb"
+#Region "Microsoft.VisualBasic::b00ccfe620212184b72ad7e8ea8c600f, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\PolarPoint.vb"
' Author:
'
diff --git a/Extensions/Image/Math/Models/Polygon.vb b/Extensions/Image/Math/Models/Polygon.vb
index 1c41d825..4f1d1f77 100644
--- a/Extensions/Image/Math/Models/Polygon.vb
+++ b/Extensions/Image/Math/Models/Polygon.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::bc27bc9c60f7442636caa239ab5ce94f, Extensions\Image\Math\Models\Polygon.vb"
+#Region "Microsoft.VisualBasic::bc27bc9c60f7442636caa239ab5ce94f, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\Polygon.vb"
' Author:
'
diff --git a/Extensions/Image/Math/Models/Vector2D.vb b/Extensions/Image/Math/Models/Vector2D.vb
index da45dc8e..0fd0ad9f 100644
--- a/Extensions/Image/Math/Models/Vector2D.vb
+++ b/Extensions/Image/Math/Models/Vector2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::69ceea95906ed80e045120aa58ab0bf6, Extensions\Image\Math\Models\Vector2D.vb"
+#Region "Microsoft.VisualBasic::69ceea95906ed80e045120aa58ab0bf6, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\Vector2D.vb"
' Author:
'
diff --git a/Extensions/Image/Math/Polygon2D.vb b/Extensions/Image/Math/Polygon2D.vb
index ea8f8cd7..8199af50 100644
--- a/Extensions/Image/Math/Polygon2D.vb
+++ b/Extensions/Image/Math/Polygon2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::3de1704040fc26424f9297c075be7162, Extensions\Image\Math\Polygon2D.vb"
+#Region "Microsoft.VisualBasic::3de1704040fc26424f9297c075be7162, Microsoft.VisualBasic.Core\Extensions\Image\Math\Polygon2D.vb"
' Author:
'
diff --git a/Extensions/Image/Math/VectorMath2D.vb b/Extensions/Image/Math/VectorMath2D.vb
index 41f53394..67bea3d6 100644
--- a/Extensions/Image/Math/VectorMath2D.vb
+++ b/Extensions/Image/Math/VectorMath2D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::5d5f0bd2478a6e520928f570ff53c5b5, Extensions\Image\Math\VectorMath2D.vb"
+#Region "Microsoft.VisualBasic::5d5f0bd2478a6e520928f570ff53c5b5, Microsoft.VisualBasic.Core\Extensions\Image\Math\VectorMath2D.vb"
' Author:
'
diff --git a/Extensions/Image/PointF3D.vb b/Extensions/Image/PointF3D.vb
index bfa1a312..1a7eb28d 100644
--- a/Extensions/Image/PointF3D.vb
+++ b/Extensions/Image/PointF3D.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::b70ed42a2afa9a49564dac1214e5d1c3, Extensions\Image\PointF3D.vb"
+#Region "Microsoft.VisualBasic::b70ed42a2afa9a49564dac1214e5d1c3, Microsoft.VisualBasic.Core\Extensions\Image\PointF3D.vb"
' Author:
'
diff --git a/Extensions/Image/TiffWriter.vb b/Extensions/Image/TiffWriter.vb
index 3a876be4..a6150319 100644
--- a/Extensions/Image/TiffWriter.vb
+++ b/Extensions/Image/TiffWriter.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::03ff858003686cc92d3eab5acd654e71, Extensions\Image\TiffWriter.vb"
+#Region "Microsoft.VisualBasic::057fc5da2dcf25d977dd52a55e858a9a, Microsoft.VisualBasic.Core\Extensions\Image\TiffWriter.vb"
' Author:
'
@@ -35,26 +35,22 @@
'
' Constructor: (+1 Overloads) Sub New
'
- ' Function: __bitmaps, __getPageNumber, ConvertToBitonal, ExistingFileSave, GetCodec
- ' GetEnumerator, IEnumerable_GetEnumerator, MultipageTiffSave, SaveMultipage, SaveToExistingFile
+ ' Function: ConvertToBitonal, ExistingFileSave, GetCodec, GetEnumerator, getPageNumber
+ ' IEnumerable_GetEnumerator, layers2Bitmaps, MultipageTiffSave, SaveMultipage, SaveToExistingFile
'
- ' Sub: __saveImageExistingMultiplePage, __saveImageExistingSinglePage, __saveMultipage, __saveToExistingFile, Add
+ ' Sub: __saveImageExistingMultiplePage, __saveImageExistingSinglePage, Add, doSaveToExistingFile, saveMultipage
'
'
' /********************************************************************************/
#End Region
-Imports System.ComponentModel
-Imports System.Data
Imports System.Drawing
-Imports System.Collections
-Imports System.Windows.Forms
Imports System.Drawing.Imaging
-Imports System.Runtime.InteropServices
-Imports System.Runtime.InteropServices.Marshal
Imports System.IO
+Imports System.Runtime.InteropServices.Marshal
Imports Microsoft.VisualBasic.Language
+Imports Microsoft.VisualBasic.Linq
Namespace Imaging
@@ -86,6 +82,8 @@ Namespace Imaging
Public Function MultipageTiffSave(path As String) As Boolean
If _imageLayers.Count = 0 Then
Return False
+ ElseIf path.FileLength > 0 Then
+ Return ExistingFileSave(path)
Else
Return SaveMultipage(_imageLayers, path, "TIFF")
End If
@@ -94,36 +92,42 @@ Namespace Imaging
Public Function ExistingFileSave(path As String) As Boolean
If _imageLayers.IsNullOrEmpty Then
Return False
+ Else
+ Return _imageLayers _
+ .DoCall(AddressOf layers2Bitmaps) _
+ .DoCall(Function(layers)
+ Return SaveToExistingFile(path, layers, "TIFF")
+ End Function)
End If
-
- Dim Res = SaveToExistingFile(path, __bitmaps(_imageLayers), "TIFF")
- Return Res
End Function
Public Shared Function SaveMultipage(bmp As List(Of Image), location As String, type As String) As Boolean
If bmp Is Nothing Then Return False
Try
- Call __saveMultipage(__bitmaps(bmp), location, type)
+ Call location.ParentPath.MkDIR
+ Call saveMultipage(layers2Bitmaps(bmp), location, type)
Return True
Catch ex As Exception
- ex = New Exception(location.ToFileURL & " ===> " & type, ex)
+ ex = New Exception(location.ToFileURL, ex)
Call App.LogException(ex)
+ Call ex.PrintException
End Try
Return False
End Function
- Private Shared Function __bitmaps(bmps As IEnumerable(Of Image)) As Image()
- Return LinqAPI.Exec(Of Image) <=
- From image As Image
- In bmps
- Where Not image Is Nothing
- Let bitonal = ConvertToBitonal(DirectCast(image, Bitmap))
- Select DirectCast(bitonal, Image)
+ Private Shared Function layers2Bitmaps(bmps As IEnumerable(Of Image)) As Image()
+ Return LinqAPI.Exec(Of Image) _
+ _
+ () <= From image As Image
+ In bmps
+ Where Not image Is Nothing
+ Let bitonal = ConvertToBitonal(DirectCast(image, Bitmap))
+ Select DirectCast(bitonal, Image)
End Function
- Private Shared Sub __saveMultipage(bmp As Image(), location As String, type As String)
+ Private Shared Sub saveMultipage(bmp As Image(), location As String, type As String)
Dim codecInfo As ImageCodecInfo = GetCodec(type)
If bmp.Length = 1 Then
@@ -189,7 +193,7 @@ Namespace Imaging
'''
Public Shared Function SaveToExistingFile(fileName As String, bmp As Image(), type As String) As Boolean
Try
- Call __saveToExistingFile(fileName, bmp, type)
+ Call doSaveToExistingFile(fileName, bmp, type)
Return True
Catch ex As Exception
Call App.LogException(ex)
@@ -197,21 +201,21 @@ Namespace Imaging
End Try
End Function
- Private Shared Sub __saveToExistingFile(fileName As String, bmp As Image(), type As String)
- 'bmp[0] is containing Image from Existing file on which we will append newly scanned Images
- 'SO first we will dicide wheter existing file is single page or multipage
- Dim fr As FileStream = IO.File.Open(fileName, FileMode.Open, FileAccess.ReadWrite)
- Dim origionalFile As Image = Image.FromStream(fr)
- Dim PageNumber As Integer = __getPageNumber(origionalFile)
+ Private Shared Sub doSaveToExistingFile(fileName As String, bmp As Image(), type As String)
+ ' bmp[0] is containing Image from Existing file on which we will append newly scanned Images
+ ' SO first we will dicide wheter existing file is single page or multipage
+ Using fr As FileStream = IO.File.Open(fileName, FileMode.Open, FileAccess.ReadWrite)
+ Dim origionalFile As Image = Image.FromStream(fr)
+ Dim PageNumber As Integer = getPageNumber(origionalFile)
- If PageNumber > 1 Then 'Existing File is multi page tiff file
- __saveImageExistingMultiplePage(bmp, origionalFile, type, PageNumber, "shreeTemp.tif")
- ElseIf PageNumber = 1 Then 'Existing file is single page file
- __saveImageExistingSinglePage(bmp, origionalFile, type, "shreeTemp.tif")
- End If
+ If PageNumber > 1 Then 'Existing File is multi page tiff file
+ __saveImageExistingMultiplePage(bmp, origionalFile, type, PageNumber, "shreeTemp.tif")
+ ElseIf PageNumber = 1 Then 'Existing file is single page file
+ __saveImageExistingSinglePage(bmp, origionalFile, type, "shreeTemp.tif")
+ End If
- Call fr.Flush()
- Call fr.Close()
+ Call fr.Flush()
+ End Using
Call IO.File.Replace("shreeTemp.tif", fileName, "Backup.tif", True)
End Sub
@@ -301,7 +305,7 @@ Namespace Imaging
pages.SaveAdd(EncoderParams)
End Sub
- Private Shared Function __getPageNumber(img As Image) As Integer
+ Private Shared Function getPageNumber(img As Image) As Integer
Dim objGuid As Guid = img.FrameDimensionsList(0)
Dim objDimension As New FrameDimension(objGuid)
'Gets the total number of frames in the .tiff file
diff --git a/Extensions/Image/Wmf.vb b/Extensions/Image/Wmf.vb
index 55609e12..aa1e6408 100644
--- a/Extensions/Image/Wmf.vb
+++ b/Extensions/Image/Wmf.vb
@@ -1,45 +1,45 @@
-#Region "Microsoft.VisualBasic::eadbd4efb1d726b1fd5f590f37e528e8, Extensions\Image\Wmf.vb"
+#Region "Microsoft.VisualBasic::eadbd4efb1d726b1fd5f590f37e528e8, Microsoft.VisualBasic.Core\Extensions\Image\Wmf.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 .
+' 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 .
- ' /********************************************************************************/
+' /********************************************************************************/
- ' Summaries:
+' Summaries:
- ' Class Wmf
- '
- ' Properties: FilePath, Size
- '
- ' Constructor: (+1 Overloads) Sub New
- ' Sub: __release, Dispose, DrawCircle
- '
- '
- ' /********************************************************************************/
+' Class Wmf
+'
+' Properties: FilePath, Size
+'
+' Constructor: (+1 Overloads) Sub New
+' Sub: __release, Dispose, DrawCircle
+'
+'
+' /********************************************************************************/
#End Region
@@ -77,16 +77,24 @@ Namespace Imaging
Public Class Wmf : Inherits GDICanvas
Implements IDisposable
- ReadOnly curMetafile As Metafile
- ReadOnly gSource As Graphics
+ '''
+ ''' 矢量图的数据存储在这个元数据文件里面
+ '''
+ ReadOnly vectorMetafile As Metafile
ReadOnly hdc As IntPtr
+ ReadOnly bounds As Size
'''
''' The file path of the target wmf image file.
'''
'''
- Public ReadOnly Property FilePath As String
+ Public ReadOnly Property wmfFile As String
+
Public Overrides ReadOnly Property Size As Size
+ Get
+ Return bounds
+ End Get
+ End Property
'''
''' The WMF format was designed to be executed by the Windows GDI layer in order to restore the image, but as
@@ -102,28 +110,45 @@ Namespace Imaging
'''
Sub New(size As Size, save$, Optional backgroundColor$ = NameOf(Color.Transparent))
Dim bitmap As New Bitmap(size.Width, size.Height)
+ Dim bounds As New RectangleF(0, 0, size.Width, size.Height)
- gSource = Graphics.FromImage(bitmap)
- gSource.Clear(backgroundColor.TranslateColor)
+ ' Make a Graphics object so we can use its hDC as a reference.
+ Dim gSource = Graphics.FromImage(bitmap)
+ Dim hdc As IntPtr = gSource.GetHdc()
- hdc = gSource.GetHdc()
- size = bitmap.Size
- curMetafile = New Metafile(save, hdc)
- Graphics = Graphics.FromImage(curMetafile)
- Graphics.SmoothingMode = SmoothingMode.HighQuality
+ Me.hdc = hdc
+ Me.bounds = bounds.Size.ToSize
- FilePath = save
+ ' Make the Metafile, using the reference hDC.
+ save.ParentPath.MkDIR
+ vectorMetafile = New Metafile(save, hdc, bounds, MetafileFrameUnit.Pixel)
+ gSource.ReleaseHdc(hdc)
+
+ ' Make a Graphics object and draw.
+ g = Graphics.FromImage(vectorMetafile)
+ g.SmoothingMode = SmoothingMode.HighQuality
+ g.PageUnit = GraphicsUnit.Pixel
+ g.CompositingQuality = CompositingQuality.HighQuality
+ g.CompositingMode = CompositingMode.SourceOver
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic
+ g.PixelOffsetMode = PixelOffsetMode.HighQuality
+ g.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
+ g.Clear(backgroundColor.TranslateColor)
+
+ wmfFile = save
End Sub
- Private Sub __release()
- Call gSource.ReleaseHdc(hdc)
+ '''
+ ''' Close the metafile and free resources.
+ '''
+ Private Sub releaseInternal()
Call Graphics.Dispose()
- Call gSource.Dispose()
+ Call vectorMetafile.Dispose()
End Sub
Public Overrides Sub Dispose()
- Call __release()
- MyBase.Dispose()
+ Call releaseInternal()
+ Call MyBase.Dispose()
End Sub
Public Overrides Sub DrawCircle(center As PointF, fill As Color, stroke As Pen, radius As Single)
diff --git a/Extensions/Math/Correlations/Beta.vb b/Extensions/Math/Correlations/Beta.vb
index e4490781..a6cbb4d5 100644
--- a/Extensions/Math/Correlations/Beta.vb
+++ b/Extensions/Math/Correlations/Beta.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::10435732b5abf83eaebf8ff01a0c3905, Extensions\Math\Correlations\Beta.vb"
+#Region "Microsoft.VisualBasic::10435732b5abf83eaebf8ff01a0c3905, Microsoft.VisualBasic.Core\Extensions\Math\Correlations\Beta.vb"
' Author:
'
diff --git a/Extensions/Math/Correlations/Correlations.vb b/Extensions/Math/Correlations/Correlations.vb
index 961d7f9d..2616d176 100644
--- a/Extensions/Math/Correlations/Correlations.vb
+++ b/Extensions/Math/Correlations/Correlations.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::9c11dc0f1c9e9d6407961c01820bf2f7, Extensions\Math\Correlations\Correlations.vb"
+#Region "Microsoft.VisualBasic::9c11dc0f1c9e9d6407961c01820bf2f7, Microsoft.VisualBasic.Core\Extensions\Math\Correlations\Correlations.vb"
' Author:
'
diff --git a/Extensions/Math/Correlations/Ranking.vb b/Extensions/Math/Correlations/Ranking.vb
index aa9611ca..e1a6189c 100644
--- a/Extensions/Math/Correlations/Ranking.vb
+++ b/Extensions/Math/Correlations/Ranking.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::a525089530604eb2b0647ab829289f61, Extensions\Math\Correlations\Ranking.vb"
+#Region "Microsoft.VisualBasic::a4d7e0eff926a6a46c5ed05c2935484d, Microsoft.VisualBasic.Core\Extensions\Math\Correlations\Ranking.vb"
' Author:
'
@@ -86,6 +86,14 @@ Namespace Math.Correlations
FractionalRanking = 1 + 2.5 + 2.5 + 4
End Enum
+ '''
+ ''' 函数返回与输入的序列中的元素相同顺序的排序的得分
+ '''
+ '''
+ '''
+ '''
+ '''
+ '''
Public Function Ranking(Of C As IComparable)(list As IEnumerable(Of C), Optional strategy As Strategies = Strategies.OrdinalRanking, Optional desc As Boolean = False) As Double()
@@ -137,8 +145,13 @@ Namespace Math.Correlations
.Keys _
.GroupBy(Function(x) x.value) _
.ToDictionary(Function(x) x.First.value,
- Function(g) g.Count)
- Dim previous As C = asc.Last.value ' 使用Nothing的时候,对于数字而言,会是0,则会和0冲突,使用最大的值则完全可以避免这个问题了
+ Function(g)
+ Return g.Count
+ End Function)
+
+ ' 使用Nothing的时候,对于数字而言,会是0,则会和0冲突,
+ ' 使用最大的值则完全可以避免这个问题了
+ Dim previous As C = asc.Last.value
For i As Integer = 0 To asc.Length - 1
' obj -> original_i -> rank
@@ -324,7 +337,9 @@ Namespace Math.Correlations
Dim equals = array.GroupBy(Function(x) x.value)
For Each g As IGrouping(Of C, SeqValue(Of C)) In equals
- Dim avgRanks# = Aggregate i In g Into Average(ranks(i))
+ Dim avgRanks# = Aggregate i
+ In g
+ Into Average(ranks(i))
For Each i As SeqValue(Of C) In g
ranks(i.i) = avgRanks
diff --git a/Extensions/Math/Correlations/Ranks.vb b/Extensions/Math/Correlations/Ranks.vb
index 6f2a3d57..62ecd33c 100644
--- a/Extensions/Math/Correlations/Ranks.vb
+++ b/Extensions/Math/Correlations/Ranks.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::e1202199871dd4ca34776ef09c46824e, Extensions\Math\Correlations\Ranks.vb"
+#Region "Microsoft.VisualBasic::e1202199871dd4ca34776ef09c46824e, Microsoft.VisualBasic.Core\Extensions\Math\Correlations\Ranks.vb"
' Author:
'
diff --git a/Extensions/Math/Correlations/Scripting.vb b/Extensions/Math/Correlations/Scripting.vb
index db1cdc60..4da8ef9e 100644
--- a/Extensions/Math/Correlations/Scripting.vb
+++ b/Extensions/Math/Correlations/Scripting.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::529ef937f9a73e22edebef9c23f1bcd8, Extensions\Math\Correlations\Scripting.vb"
+#Region "Microsoft.VisualBasic::529ef937f9a73e22edebef9c23f1bcd8, Microsoft.VisualBasic.Core\Extensions\Math\Correlations\Scripting.vb"
' Author:
'
diff --git a/Extensions/Math/Information/Entropy.vb b/Extensions/Math/Information/Entropy.vb
index baa4e193..928782c9 100644
--- a/Extensions/Math/Information/Entropy.vb
+++ b/Extensions/Math/Information/Entropy.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::d08fd8dfce6d983445bbe9711dc16bb2, Extensions\Math\Information\Entropy.vb"
+#Region "Microsoft.VisualBasic::d08fd8dfce6d983445bbe9711dc16bb2, Microsoft.VisualBasic.Core\Extensions\Math\Information\Entropy.vb"
' Author:
'
diff --git a/Extensions/Math/Information/UncheckHelpers.vb b/Extensions/Math/Information/UncheckHelpers.vb
index 59c38239..0fb3f751 100644
--- a/Extensions/Math/Information/UncheckHelpers.vb
+++ b/Extensions/Math/Information/UncheckHelpers.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::dae89f686d7e481105d44408dc3ba7fc, Extensions\Math\Information\UncheckHelpers.vb"
+#Region "Microsoft.VisualBasic::dae89f686d7e481105d44408dc3ba7fc, Microsoft.VisualBasic.Core\Extensions\Math\Information\UncheckHelpers.vb"
' Author:
'
diff --git a/Extensions/Math/Math.vb b/Extensions/Math/Math.vb
index 3d2fc178..8b9da488 100644
--- a/Extensions/Math/Math.vb
+++ b/Extensions/Math/Math.vb
@@ -1,4 +1,4 @@
-#Region "Microsoft.VisualBasic::23bfca6cd869b18336b2081c03ddf765, Extensions\Math\Math.vb"
+#Region "Microsoft.VisualBasic::7995a8959bcd3d358a5b82d40806ed93, Microsoft.VisualBasic.Core\Extensions\Math\Math.vb"
' Author:
'
@@ -39,7 +39,7 @@
' Factorial, FactorialSequence, (+2 Overloads) Floor, FormatNumeric, Hypot
' IEEERemainder, IsPowerOf2, (+2 Overloads) Log, Log10, (+2 Overloads) Log2
' LogN, (+12 Overloads) Max, (+11 Overloads) Min, PoissonPDF, Pow
- ' Pow2, (+3 Overloads) ProductALL, (+3 Overloads) RangesAt, RMS, (+8 Overloads) Round
+ ' Pow2, (+3 Overloads) ProductALL, (+3 Overloads) RangesAt, (+2 Overloads) RMS, (+8 Overloads) Round
' RSD, (+4 Overloads) SD, (+2 Overloads) seq, (+7 Overloads) Sign, Sin
' Sinh, Sqrt, (+5 Overloads) Sum, Tan, Tanh
' (+2 Overloads) Truncate, WeighedAverage
@@ -57,7 +57,7 @@ Imports Microsoft.VisualBasic.ComponentModel.Ranges.Model
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Scripting.MetaData
-Imports sys = System.Math
+Imports stdNum = System.Math
Namespace Math
@@ -73,11 +73,11 @@ Namespace Math
''' Represents the ratio of the circumference of a circle to its diameter, specified
''' by the constant, π.
'''
- Public Const PI# = sys.PI
+ Public Const PI# = stdNum.PI
'''
''' Represents the natural logarithmic base, specified by the constant, e.
'''
- Public Const E# = sys.E
+ Public Const E# = stdNum.E
#Region "Imports System.Math"
@@ -442,7 +442,7 @@ Namespace Math
' The number containing the product of the specified numbers.
Public Function BigMul(a As Integer, b As Integer) As Long
- Return sys.BigMul(a, b)
+ Return stdNum.BigMul(a, b)
End Function
'
' Summary:
@@ -466,23 +466,17 @@ Namespace Math
Return 0
End If
End Function
- '
- ' Summary:
- ' Returns an integer that indicates the sign of a double-precision floating-point
- ' number.
- '
- ' Parameters:
- ' value:
- ' A signed number.
- '
- ' Returns:
- ' A number that indicates the sign of value, as shown in the following table.Return
- ' value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value is
- ' greater than zero.
- '
- ' Exceptions:
- ' T:System.ArithmeticException:
- ' value is equal to System.Double.NaN.
+
+ '''
+ ''' Returns an integer that indicates the sign of a double-precision floating-point
+ ''' number.
+ '''
+ ''' A signed number.
+ '''
+ ''' A number that indicates the sign of value, as shown in the following table.Return
+ ''' value Meaning -1 value is less than zero. 0 value is equal to zero. 1 value is
+ ''' greater than zero.
+ '''
Public Function Sign(value As Double) As Integer
If value > 0 Then
@@ -617,7 +611,7 @@ Namespace Math
'''
Public Function Log(a#, newBase#) As Double
- Return sys.Log(a, newBase)
+ Return stdNum.Log(a, newBase)
End Function
'''
@@ -816,7 +810,7 @@ Namespace Math
Public Function Tanh(value As Double) As Double
- Return sys.Tanh(value)
+ Return stdNum.Tanh(value)
End Function
'
' Summary:
@@ -833,7 +827,7 @@ Namespace Math
Public Function Sinh(value As Double) As Double
- Return sys.Sinh(value)
+ Return stdNum.Sinh(value)
End Function
'
' Summary:
@@ -849,7 +843,7 @@ Namespace Math
Public Function Tan(a As Double) As Double
- Return sys.Tan(a)
+ Return stdNum.Tan(a)
End Function
'
' Summary:
@@ -865,7 +859,7 @@ Namespace Math
Public Function Sin(a As Double) As Double
- Return sys.Sin(a)
+ Return stdNum.Sin(a)
End Function
'
' Summary:
@@ -883,7 +877,7 @@ Namespace Math
Public Function Floor(d As Double) As Double
- Return sys.Floor(d)
+ Return stdNum.Floor(d)
End Function
@@ -900,7 +894,7 @@ Namespace Math
' integral value of type System.Math.
Public Function Floor(d As Decimal) As Decimal
- Return sys.Floor(d)
+ Return stdNum.Floor(d)
End Function
'
@@ -918,7 +912,7 @@ Namespace Math
Public Function Round(a As Double) As Double
- Return sys.Round(a)
+ Return stdNum.Round(a)
End Function
'''
@@ -933,7 +927,7 @@ Namespace Math
Public Function Cosh(value As Double) As Double
- Return sys.Cosh(value)
+ Return stdNum.Cosh(value)
End Function
'
' Summary:
@@ -952,7 +946,7 @@ Namespace Math
Public Function Ceiling(a As Double) As Double
- Return sys.Ceiling(a)
+ Return stdNum.Ceiling(a)
End Function
'
' Summary:
@@ -968,7 +962,7 @@ Namespace Math
' method returns a System.Decimal instead of an integral type.
Public Function Ceiling(d As Decimal) As Decimal
- Return sys.Ceiling(d)
+ Return stdNum.Ceiling(d)
End Function
'
' Summary:
@@ -994,7 +988,7 @@ Namespace Math
Public Function Atan2(y As Double, x As Double) As Double
- Return sys.Atan2(y, x)
+ Return stdNum.Atan2(y, x)
End Function
'
' Summary:
@@ -1012,7 +1006,7 @@ Namespace Math
Public Function Atan(d As Double) As Double
- Return sys.Atan(d)
+ Return stdNum.Atan(d)
End Function
'
' Summary:
@@ -1029,7 +1023,7 @@ Namespace Math
Public Function Asin(d As Double) As Double
- Return sys.Asin(d)
+ Return stdNum.Asin(d)
End Function
'
' Summary:
@@ -1046,23 +1040,18 @@ Namespace Math
Public Function Acos(d As Double) As Double
- Return sys.Acos(d)
+ Return stdNum.Acos(d)
End Function
- '
- ' Summary:
- ' Returns the cosine of the specified angle.
- '
- ' Parameters:
- ' d:
- ' An angle, measured in radians.
- '
- ' Returns:
- ' The cosine of d. If d is equal to System.Double.NaN, System.Double.NegativeInfinity,
- ' or System.Double.PositiveInfinity, this method returns System.Double.NaN.
+
+ '''
+ ''' Returns the cosine of the specified angle.
+ '''
+ ''' An angle, measured in radians.
+ '''
Public Function Cos(d As Double) As Double
- Return sys.Cos(d)
+ Return stdNum.Cos(d)
End Function
'
' Summary:
@@ -1087,7 +1076,7 @@ Namespace Math
' b is zero.
Public Function DivRem(a As Integer, b As Integer, ByRef result As Integer) As Integer
- Return sys.DivRem(a, b, result)
+ Return stdNum.DivRem(a, b, result)
End Function
'''
@@ -1101,7 +1090,7 @@ Namespace Math
'''
Public Function Round(value As Double, digits As Integer) As Double
- Return sys.Round(value, digits)
+ Return stdNum.Round(value, digits)
End Function
'
' Summary:
@@ -1131,7 +1120,7 @@ Namespace Math
' mode is not a valid value of System.MidpointRounding.
Public Function Round(value As Double, digits As Integer, mode As MidpointRounding) As Double
- Return sys.Round(value, digits, mode)
+ Return stdNum.Round(value, digits, mode)
End Function
'
' Summary:
@@ -1199,7 +1188,7 @@ Namespace Math
' or -0 if x is negative.If y = 0, System.Double.NaN is returned.
Public Function IEEERemainder(x As Double, y As Double) As Double
- Return sys.IEEERemainder(x, y)
+ Return stdNum.IEEERemainder(x, y)
End Function
'''
@@ -1223,7 +1212,7 @@ Namespace Math
Public Function Exp(d As Double) As Double
- Return sys.Exp(d)
+ Return stdNum.Exp(d)
End Function
'
' Summary:
@@ -1240,7 +1229,7 @@ Namespace Math
Public Function Log10(d As Double) As Double
- Return sys.Log10(d)
+ Return stdNum.Log10(d)
End Function
'
' Summary:
@@ -1263,7 +1252,7 @@ Namespace Math
' mode is not a valid value of System.MidpointRounding.
Public Function Round(value As Double, mode As MidpointRounding) As Double
- Return sys.Round(value, mode)
+ Return stdNum.Round(value, mode)
End Function
'
' Summary:
@@ -1280,7 +1269,7 @@ Namespace Math
Public Function Log(d As Double) As Double
- Return sys.Log(d)
+ Return stdNum.Log(d)
End Function
'''
@@ -1297,7 +1286,7 @@ Namespace Math
'''
Public Function Truncate(d As Double) As Double
- Return sys.Truncate(d)
+ Return stdNum.Truncate(d)
End Function
'
' Summary:
@@ -1312,7 +1301,7 @@ Namespace Math
' digits have been discarded.
Public Function Truncate(d As Decimal) As Decimal
- Return sys.Truncate(d)
+ Return stdNum.Truncate(d)
End Function
'
' Summary:
@@ -1344,7 +1333,7 @@ Namespace Math
' The result is outside the range of a System.Decimal.
Public Function Round(d As Decimal, decimals As Integer, mode As MidpointRounding) As Decimal
- Return sys.Round(d, decimals, mode)
+ Return stdNum.Round(d, decimals, mode)
End Function
'
' Summary:
@@ -1370,7 +1359,7 @@ Namespace Math
' The result is outside the range of a System.Decimal.
Public Function Round(d As Decimal, mode As MidpointRounding) As Decimal
- Return sys.Round(d, mode)
+ Return stdNum.Round(d, mode)
End Function
'
' Summary:
@@ -1395,7 +1384,7 @@ Namespace Math
' The result is outside the range of a System.Decimal.
Public Function Round(d As Decimal, decimals As Integer) As Decimal
- Return sys.Round(d, decimals)
+ Return stdNum.Round(d, decimals)
End Function
'
' Summary:
@@ -1416,7 +1405,7 @@ Namespace Math
' The result is outside the range of a System.Decimal.
Public Function Round(d As Decimal) As Decimal
- Return sys.Round(d)
+ Return stdNum.Round(d)
End Function
'''
@@ -1429,7 +1418,7 @@ Namespace Math