Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
9993204f
Commit
9993204f
authored
Apr 02, 2012
by
Brannon Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring GetTypeDeserializer. Removing unnecessary code, streamlining handling of enum values.
parent
3e6ff615
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
20 deletions
+7
-20
SqlMapper.cs
Dapper/SqlMapper.cs
+6
-19
Tests.cs
Tests/Tests.cs
+1
-1
No files found.
Dapper/SqlMapper.cs
View file @
9993204f
...
...
@@ -1584,33 +1584,22 @@ static List<FieldInfo> GetSettableFields(Type t)
il
.
Emit
(
OpCodes
.
Pop
);
// stack is now [target][target]
il
.
Emit
(
OpCodes
.
Ldtoken
,
unboxType
);
// stack is now [target][target][enum-type-token]
il
.
EmitCall
(
OpCodes
.
Call
,
typeof
(
Type
).
GetMethod
(
"GetTypeFromHandle"
),
null
);
// stack is now [target][target][enum-type]
il
.
Emit
(
OpCodes
.
Ldloc_2
);
// stack is now [target][target][enum-type][string]
il
.
Emit
(
OpCodes
.
Ldc_I4_1
);
// stack is now [target][target][enum-type][string][true]
il
.
EmitCall
(
OpCodes
.
Call
,
enumParse
,
null
);
// stack is now [target][target][enum-as-object]
il
.
MarkLabel
(
isNotString
);
il
.
Emit
(
OpCodes
.
Unbox_Any
,
unboxType
);
// stack is now [target][target][typed-value]
if
(
nullUnderlyingType
!=
null
)
{
il
.
Emit
(
OpCodes
.
Newobj
,
memberType
.
GetConstructor
(
new
[]
{
nullUnderlyingType
}));
}
if
(
item
.
Property
!=
null
)
{
il
.
Emit
(
OpCodes
.
Callvirt
,
item
.
Property
.
Setter
);
// stack is now [target]
}
else
{
il
.
Emit
(
OpCodes
.
Stfld
,
item
.
Field
);
// stack is now [target]
il
.
Emit
(
OpCodes
.
Newobj
,
memberType
.
GetConstructor
(
new
[]
{
nullUnderlyingType
}));
// stack is now [target][target][enum-value]
}
il
.
Emit
(
OpCodes
.
Br_S
,
finishLabel
);
il
.
MarkLabel
(
isNotString
);
}
if
(
memberType
.
FullName
==
LinqBinary
)
else
if
(
memberType
.
FullName
==
LinqBinary
)
{
il
.
Emit
(
OpCodes
.
Unbox_Any
,
typeof
(
byte
[]));
// stack is now [target][target][byte-array]
il
.
Emit
(
OpCodes
.
Newobj
,
memberType
.
GetConstructor
(
new
Type
[]
{
typeof
(
byte
[])
}));
// stack is now [target][target][binary]
...
...
@@ -1619,11 +1608,9 @@ static List<FieldInfo> GetSettableFields(Type t)
{
il
.
Emit
(
OpCodes
.
Unbox_Any
,
unboxType
);
// stack is now [target][target][typed-value]
}
if
(
nullUnderlyingType
!=
null
&&
nullUnderlyingType
.
IsEnum
)
{
il
.
Emit
(
OpCodes
.
Newobj
,
memberType
.
GetConstructor
(
new
[]
{
nullUnderlyingType
}));
}
}
// Store the value in the property/field
if
(
item
.
Property
!=
null
)
{
if
(
type
.
IsValueType
)
...
...
Tests/Tests.cs
View file @
9993204f
#
define
POSTGRESQL
//
#define POSTGRESQL
using
System
;
using
System.Collections.Generic
;
using
System.Data.SqlClient
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment