-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support mapping fields (not just properties)
- Loading branch information
Showing
13 changed files
with
74 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,22 @@ | ||
using Ptixed.Sql.Impl; | ||
using System.Linq.Expressions; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Ptixed.Sql.Util | ||
{ | ||
internal static class Reflection | ||
public static class Reflection | ||
{ | ||
public static object GetValue(MemberInfo member, object owner) | ||
public static Type GetMemberType(this MemberInfo member) | ||
{ | ||
var accessor = TypeAccessor.Get(member.DeclaringType); | ||
switch (member) | ||
{ | ||
case FieldInfo fi: | ||
return accessor[owner, fi]; | ||
return fi.FieldType; | ||
case PropertyInfo pi: | ||
return accessor[owner, pi]; | ||
return pi.PropertyType; | ||
default: | ||
throw PtixedException.InvalidExpression(member); | ||
} | ||
} | ||
|
||
public static object Execute(Expression expr) | ||
{ | ||
switch (expr) | ||
{ | ||
case ConstantExpression ce: | ||
return ce.Value; | ||
case MemberExpression me: | ||
var owner = Execute(me.Expression); | ||
return GetValue(me.Member, owner); | ||
default: | ||
throw PtixedException.InvalidExpression(expr); | ||
} | ||
} | ||
} | ||
} |