Skip to content

Commit ba44c05

Browse files
committed
refactoring, now everything seems to be ready to create new branch for old full locks
1 parent a4dcad5 commit ba44c05

File tree

7 files changed

+126
-110
lines changed

7 files changed

+126
-110
lines changed

ActiveRecord/Entity/DatabaseReader/Privates.vb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ Namespace ActiveRecord
4949
If columnsByDbNames.ContainsKey(readerColumnName) Then
5050
mi = columnsByDbNames(readerColumnName)
5151
rawValueTypeCode = Type.GetTypeCode(rawValue.GetType())
52-
If (rawValueTypeCode = Constants.StringTypeCode AndAlso mi.TrimChars.Length > 0) Then
53-
rawValue = rawValue.ToString().Trim(mi.TrimChars)
54-
ElseIf rawValueTypeCode = Type.GetTypeCode(mi.Type) Then
55-
targetValue = rawValue
56-
Else
57-
formatProvider = If(mi.FormatProvider, System.Globalization.CultureInfo.CurrentCulture)
52+
If (rawValueTypeCode = Constants.StringTypeCode AndAlso mi.TrimChars.Length > 0) Then
53+
rawValue = rawValue.ToString().Trim(mi.TrimChars)
54+
ElseIf rawValueTypeCode = Type.GetTypeCode(mi.Type) Then
55+
targetValue = rawValue
56+
ElseIf mi.Type.IsEnum Then
57+
targetValue = System.[Enum].Parse(mi.Type, rawValue.ToString())
58+
Else
59+
formatProvider = If(mi.FormatProvider, System.Globalization.CultureInfo.CurrentCulture)
5860
targetValue = If(TypeOf rawValue Is DBNull, Nothing, Convert.ChangeType(rawValue, mi.Type, formatProvider))
5961
End If
6062
If (mi.MemberInfoType = MemberInfoType.Prop) Then

Misc/Tools.vb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ Imports System.IO
33
Imports System.Reflection
44
Imports System.Threading
55

6-
Friend Class Tools
7-
Friend Shared Function GetEntryClassType() As Type
6+
Public Class Tools
7+
Public Shared Function GetEntryClassType() As Type
88
Return (New StackTrace(True)).GetFrames(2).GetMethod().DeclaringType
99
'Dim stackTrace As System.Diagnostics.StackTrace = New System.Diagnostics.StackTrace(True)
1010
'Dim caller = stackTrace.GetFrames(2)
1111
'Return caller.GetMethod().DeclaringType
1212
End Function
1313

14-
Friend Shared Function GetProcessAndThreadKey() As String
14+
Public Shared Function GetProcessAndThreadKey() As String
1515
Return String.Format("{0}_{1}", Process.GetCurrentProcess.Id, Thread.CurrentThread.ManagedThreadId)
1616
End Function
1717

@@ -20,7 +20,7 @@ Friend Class Tools
2020
''' </summary>
2121
''' <param name="fullClassName" type="String">"Full.Class.Name" or "AssemblyName:Full.Class.Name"</param>
2222
''' <returns type="Type">Desired type</returns>
23-
Friend Shared Function GetTypeGlobaly(ByVal fullClassName As String) As Type
23+
Public Shared Function GetTypeGlobaly(ByVal fullClassName As String) As Type
2424
Dim type As Type = Type.GetType(fullClassName)
2525
If type IsNot Nothing Then Return type
2626

@@ -43,7 +43,7 @@ Friend Class Tools
4343
''' <param name="assemblyName" type="String">"AssemblyName" for AssemblyName.dll</param>
4444
''' <param name="fullClassName" type="String">Full class name including namespace</param>
4545
''' <returns type="Type">Desired type</returns>
46-
Friend Shared Function GetTypeGlobaly(assemblyName As String, fullClassName As String) As Type
46+
Public Shared Function GetTypeGlobaly(assemblyName As String, fullClassName As String) As Type
4747
Dim type As Type = Nothing
4848
Try
4949
Dim assemblies As IEnumerable(Of Assembly) =
@@ -63,7 +63,7 @@ Friend Class Tools
6363

6464
End Function
6565

66-
Friend Shared Function GetConnectionIndexByClassAttr(type As Type, Optional throwException As Boolean = True) As Int32
66+
Public Shared Function GetConnectionIndexByClassAttr(type As Type, Optional throwException As Boolean = True) As Int32
6767
Dim connAttr As ConnectionAttribute = DirectCast(Attribute.GetCustomAttribute(type, Constants.ConnectionAttrType), ConnectionAttribute)
6868
If Not TypeOf connAttr Is ConnectionAttribute Then
6969
If throwException Then

My Project/Resources.Designer.vb

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

My Project/Resources.resx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
29+
3030
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
3232
@@ -63,41 +63,41 @@
6363
<xsd:element name="root" msdata:IsDataSet="true">
6464
<xsd:complexType>
6565
<xsd:choice maxOccurs="unbounded">
66-
<xsd:element name="metadata">
66+
<xsd:element name="metadata">
6767
<xsd:complexType>
68-
<xsd:sequence>
69-
<xsd:element name="value" type="xsd:string" minOccurs="0" />
70-
</xsd:sequence>
71-
<xsd:attribute name="name" type="xsd:string" />
72-
<xsd:attribute name="type" type="xsd:string" />
73-
<xsd:attribute name="mimetype" type="xsd:string" />
68+
<xsd:sequence>
69+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
70+
</xsd:sequence>
71+
<xsd:attribute name="name" type="xsd:string" />
72+
<xsd:attribute name="type" type="xsd:string" />
73+
<xsd:attribute name="mimetype" type="xsd:string" />
7474
</xsd:complexType>
75-
</xsd:element>
76-
<xsd:element name="assembly">
75+
</xsd:element>
76+
<xsd:element name="assembly">
7777
<xsd:complexType>
78-
<xsd:attribute name="alias" type="xsd:string" />
79-
<xsd:attribute name="name" type="xsd:string" />
78+
<xsd:attribute name="alias" type="xsd:string" />
79+
<xsd:attribute name="name" type="xsd:string" />
8080
</xsd:complexType>
81-
</xsd:element>
82-
<xsd:element name="data">
81+
</xsd:element>
82+
<xsd:element name="data">
8383
<xsd:complexType>
84-
<xsd:sequence>
85-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86-
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87-
</xsd:sequence>
88-
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89-
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90-
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
84+
<xsd:sequence>
85+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87+
</xsd:sequence>
88+
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
9191
</xsd:complexType>
92-
</xsd:element>
93-
<xsd:element name="resheader">
92+
</xsd:element>
93+
<xsd:element name="resheader">
9494
<xsd:complexType>
95-
<xsd:sequence>
96-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97-
</xsd:sequence>
98-
<xsd:attribute name="name" type="xsd:string" use="required" />
95+
<xsd:sequence>
96+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97+
</xsd:sequence>
98+
<xsd:attribute name="name" type="xsd:string" use="required" />
9999
</xsd:complexType>
100-
</xsd:element>
100+
</xsd:element>
101101
</xsd:choice>
102102
</xsd:complexType>
103103
</xsd:element>

My Project/Settings.Designer.vb

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Statement.vb

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,40 @@ Public MustInherit Class Statement
9999
Public Shared Function Prepare(sql As String, connection As Connection) As Statement
100100
Return Statement.PrepareLocal(sql, connection)
101101
End Function
102-
''' <summary>
103-
''' Create and prepare database SQL statement. Put '@' char before all param names in your SQL code.
104-
''' Created database statement will be executed in passed transaction.
105-
''' </summary>
106-
''' <param name="sql">SQL code for statement. Put '@' char before all param names in your SQL code.</param>
107-
''' <param name="transaction">Database transaction from current connection to execute this SQL statement inside.</param>
108-
''' <returns>New specificly typed SQL statement by connection.</returns>
109-
Public Shared Function Prepare(sql As String, transaction As Transaction) As Statement
110-
Return Statement.PrepareLocal(sql, transaction)
111-
End Function
112-
113-
114-
115-
116-
117-
''' <summary>
118-
''' Execute SQL statement and open data reader to get only first single row from select statement result.
119-
''' </summary>
120-
''' <returns>SQL statement instance with opened data reader.</returns>
121-
Public Function FetchOne() As Statement
102+
''' <summary>
103+
''' Create and prepare database SQL statement. Put '@' char before all param names in your SQL code.
104+
''' Created database statement will be executed in passed transaction.
105+
''' </summary>
106+
''' <param name="sql">SQL code for statement. Put '@' char before all param names in your SQL code.</param>
107+
''' <param name="transaction">Database transaction from current connection to execute this SQL statement inside.</param>
108+
''' <returns>New specificly typed SQL statement by connection.</returns>
109+
Public Shared Function Prepare(sql As String, transaction As Transaction) As Statement
110+
Return Statement.PrepareLocal(sql, transaction)
111+
End Function
112+
''' <summary>
113+
''' Create and prepare database SQL statement. Put '@' char before all param names in your SQL code.
114+
''' Created database statement will be executed in passed transaction.
115+
''' </summary>
116+
''' <param name="sql">SQL code for statement. Put '@' char before all param names in your SQL code.</param>
117+
''' <param name="connectionOrTransaction">Database connection or database transaction from current connection to execute this SQL statement inside.</param>
118+
''' <returns>New specificly typed SQL statement by connection.</returns>
119+
Public Shared Function Prepare(sql As String, connectionOrTransaction As Object) As Statement
120+
If TypeOf connectionOrTransaction Is Databasic.Connection Then
121+
Return Statement.PrepareLocal(sql, DirectCast(connectionOrTransaction, Databasic.Connection))
122+
Else
123+
Return Statement.PrepareLocal(sql, DirectCast(connectionOrTransaction, Databasic.Transaction))
124+
End If
125+
End Function
126+
127+
128+
129+
130+
131+
''' <summary>
132+
''' Execute SQL statement and open data reader to get only first single row from select statement result.
133+
''' </summary>
134+
''' <returns>SQL statement instance with opened data reader.</returns>
135+
Public Function FetchOne() As Statement
122136
Try
123137
Me.Reader = Me.Command.ExecuteReader(CommandBehavior.SingleRow)
124138
Catch ex As Exception

0 commit comments

Comments
 (0)