diff --git a/ApplicationServices/Debugger.vb b/ApplicationServices/Debugger.vb index c368538d..7ea5f3b9 100644 --- a/ApplicationServices/Debugger.vb +++ b/ApplicationServices/Debugger.vb @@ -222,12 +222,14 @@ Public Module VBDebugger Return Nothing End Function - Public Sub __INFO_ECHO(msg$) + Public Sub __INFO_ECHO(msg$, Optional silent As Boolean = False) If Not Mute AndAlso m_level < DebuggerLevels.Warning Then Dim head As String = $"INFOM {Now.ToString}" Dim str As String = " " & msg - Call My.Log4VB.Print(head, str, ConsoleColor.White, MSG_TYPES.INF) + If Not silent Then + Call My.Log4VB.Print(head, str, ConsoleColor.White, MSG_TYPES.INF) + End If #If DEBUG Then Call Debug.WriteLine($"[{head}]{str}") @@ -252,8 +254,17 @@ Public Module VBDebugger ''' ''' - Public Function PrintException(Of ex As Exception)(exception As ex, Optional memberName$ = "") As Boolean - Return New Exception(memberName, exception).ToString.PrintException(memberName) + + Public Function PrintException(Of ex As Exception)(exception As ex, Optional memberName$ = "") As Boolean + Dim lines = New Exception(memberName, exception).ToString.LineTokens + Dim exceptions$() = Strings.Split(lines.First, "--->") + Dim formats = exceptions(0) & vbCrLf & + vbCrLf & + exceptions.Skip(1).JoinBy(vbCrLf) & vbCrLf & + vbCrLf & + lines.Skip(1).JoinBy(vbCrLf) + + Return formats.PrintException(memberName) End Function ''' diff --git a/ComponentModel/System.Collections.Generic/KeyDictionary.vb b/ComponentModel/System.Collections.Generic/KeyDictionary.vb index b15ad615..e43695b5 100644 --- a/ComponentModel/System.Collections.Generic/KeyDictionary.vb +++ b/ComponentModel/System.Collections.Generic/KeyDictionary.vb @@ -1,53 +1,53 @@ #Region "Microsoft.VisualBasic::96de3680f1c003d276cb4347540c5482, Microsoft.VisualBasic.Core\ComponentModel\System.Collections.Generic\KeyDictionary.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 HashTable - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Class Dictionary - ' - ' Constructor: (+3 Overloads) Sub New - ' - ' Function: Find, GetValueList, Have, Remove, SafeGetValue - ' (+2 Overloads) TryGetValue - ' - ' Sub: Add, AddRange, InsertOrUpdate - ' - ' Operators: (+2 Overloads) -, ^, +, <=, >= - ' - ' - ' /********************************************************************************/ +' Class HashTable +' +' Constructor: (+1 Overloads) Sub New +' +' Class Dictionary +' +' Constructor: (+3 Overloads) Sub New +' +' Function: Find, GetValueList, Have, Remove, SafeGetValue +' (+2 Overloads) TryGetValue +' +' Sub: Add, AddRange, InsertOrUpdate +' +' Operators: (+2 Overloads) -, ^, +, <=, >= +' +' +' /********************************************************************************/ #End Region @@ -137,6 +137,7 @@ Namespace ComponentModel.Collection End Set End Property + Sub New() Call MyBase.New End Sub @@ -151,10 +152,13 @@ Namespace ComponentModel.Collection ''' The System.Collections.Generic.IDictionary`2 whose elements are copied to the ''' new System.Collections.Generic.SortedDictionary`2. ''' + ''' + Sub New(source As Dictionary(Of String, V)) Call MyBase.New(source) End Sub + Sub New(source As IEnumerable(Of V), Optional overridesDuplicateds As Boolean = False) Call Me.New @@ -169,6 +173,7 @@ Namespace ComponentModel.Collection End If End Sub + Public Function GetValueList() As List(Of V) Return Values.AsList End Function @@ -177,10 +182,13 @@ Namespace ComponentModel.Collection ''' Adds an element with the specified key and value into the System.Collections.Generic.SortedDictionary`2. ''' ''' + ''' + Public Overloads Sub Add(item As V) Call MyBase.Add(item.Key, item) End Sub + Public Sub AddRange(source As IEnumerable(Of V)) For Each x As V In source Call MyBase.Add(x.Key, x) @@ -222,6 +230,7 @@ Namespace ComponentModel.Collection ''' ''' + Public Function Have(item As V) As Boolean Return MyBase.ContainsKey(item.Key) End Function diff --git a/Extensions/Collection/KeyValuePair.vb b/Extensions/Collection/KeyValuePair.vb index c9f82dd7..84f20f81 100644 --- a/Extensions/Collection/KeyValuePair.vb +++ b/Extensions/Collection/KeyValuePair.vb @@ -754,6 +754,8 @@ Public Module KeyValuePairExtensions ''' Unique identifier provider ''' ''' + ''' + Public Function ToDictionary(Of T As INamedValue)(source As IEnumerable(Of T), Optional replaceOnDuplicate As Boolean = False) As Dictionary(Of T) If source Is Nothing Then @@ -776,6 +778,7 @@ Public Module KeyValuePairExtensions End If End Function + Private Function tableInternal(Of T As INamedValue)(source As IEnumerable(Of T), ByRef currentKey$, diff --git a/Extensions/IO/Extensions/PathExtensions.vb b/Extensions/IO/Extensions/PathExtensions.vb index 669fbc3a..020105c9 100644 --- a/Extensions/IO/Extensions/PathExtensions.vb +++ b/Extensions/IO/Extensions/PathExtensions.vb @@ -605,8 +605,7 @@ Public Module PathExtensions Public Function DirectoryExists(DIR As String) As Boolean - Return Not String.IsNullOrEmpty(DIR) AndAlso - FileIO.FileSystem.DirectoryExists(DIR) + Return Not String.IsNullOrEmpty(DIR) AndAlso FileIO.FileSystem.DirectoryExists(DIR) End Function ''' diff --git a/Language/Linq/List.vb b/Language/Linq/List.vb index c01941eb..5875c432 100644 --- a/Language/Linq/List.vb +++ b/Language/Linq/List.vb @@ -275,6 +275,8 @@ Namespace Language ''' (这是一个安全的构造函数,假若输入的参数为空值,则只会创建一个空的列表,而不会抛出错误) ''' ''' The collection whose elements are copied to the new list. + ''' + Sub New(source As IEnumerable(Of T)) Call MyBase.New(If(source Is Nothing, {}, source.ToArray)) End Sub @@ -285,6 +287,8 @@ Namespace Language ''' to accommodate the number of elements copied. ''' ''' The collection whose elements are copied to the new list. + ''' + Sub New(ParamArray x As T()) Call MyBase.New(If(x Is Nothing, {}, x)) End Sub @@ -293,6 +297,8 @@ Namespace Language ''' Initializes a new instance of the Microsoft VisualBasic language class ''' that is empty and has the default initial capacity. ''' + ''' + Public Sub New() Call MyBase.New End Sub @@ -302,10 +308,13 @@ Namespace Language ''' is empty and has the specified initial capacity. ''' ''' The number of elements that the new list can initially store. + ''' + Public Sub New(capacity As Integer) Call MyBase.New(capacity) End Sub + Public Sub New(size As Integer, fill As T) For i As Integer = 0 To size - 1 Call Add(fill) diff --git a/Language/Linq/Vectorization/Vector.vb b/Language/Linq/Vectorization/Vector.vb index aa03935a..cee3f2b3 100644 --- a/Language/Linq/Vectorization/Vector.vb +++ b/Language/Linq/Vectorization/Vector.vb @@ -323,9 +323,12 @@ Namespace Language.Vectorization #End Region #Region "Constructor" + + Public Sub New() End Sub + Sub New(capacity%) buffer = New T(capacity - 1) {} End Sub @@ -334,15 +337,19 @@ Namespace Language.Vectorization ''' 构建一个新的向量对象,这个向量对象只提供基本的数据存储和访问模型,并没有提供高级的动态处理和模式解析的操作 ''' ''' + ''' + Sub New(data As IEnumerable(Of T)) buffer = data.ToArray End Sub #End Region + Public Overrides Function ToString() As String Return $"{buffer.Length} @ {GetType(T).FullName}" End Function + Public Overridable Iterator Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator For Each element As T In buffer Yield element