Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9c05c353
Commit
9c05c353
authored
Mar 27, 2018
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments
parent
7b19d208
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
ReflectionUtil.cs
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
+13
-6
No files found.
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
View file @
9c05c353
...
...
@@ -56,32 +56,40 @@ namespace Google.Protobuf.Reflection
internal
static
readonly
Type
[]
EmptyTypes
=
new
Type
[
0
];
/// <summary>
/// Creates a delegate which will cast the argument to the
appropriate method target type
,
/// Creates a delegate which will cast the argument to the
type that declares the method
,
/// call the method on it, then convert the result to object.
/// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal
static
Func
<
IMessage
,
object
>
CreateFuncIMessageObject
(
MethodInfo
method
)
=>
GetReflectionHelper
(
method
.
DeclaringType
,
method
.
ReturnType
).
CreateFuncIMessageObject
(
method
);
/// <summary>
/// Creates a delegate which will cast the argument to the
appropriate method target type
,
/// Creates a delegate which will cast the argument to the
type that declares the method
,
/// call the method on it, then convert the result to the specified type. The method is expected
/// to actually return an enum (because of where we're calling it - for oneof cases). Sometimes that
/// means we need some extra work to perform conversions.
/// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal
static
Func
<
IMessage
,
int
>
CreateFuncIMessageInt32
(
MethodInfo
method
)
=>
GetReflectionHelper
(
method
.
DeclaringType
,
method
.
ReturnType
).
CreateFuncIMessageInt32
(
method
);
/// <summary>
/// Creates a delegate which will execute the given method after casting the first argument to
/// the t
arget type of
the method, and the second argument to the first parameter type of the method.
/// the t
ype that declares
the method, and the second argument to the first parameter type of the method.
/// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal
static
Action
<
IMessage
,
object
>
CreateActionIMessageObject
(
MethodInfo
method
)
=>
GetReflectionHelper
(
method
.
DeclaringType
,
method
.
GetParameters
()[
0
].
ParameterType
).
CreateActionIMessageObject
(
method
);
/// <summary>
/// Creates a delegate which will execute the given method after casting the first argument to
/// t
he target type of
the method.
/// t
ype that declares
the method.
/// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal
static
Action
<
IMessage
>
CreateActionIMessage
(
MethodInfo
method
)
=>
GetReflectionHelper
(
method
.
DeclaringType
,
typeof
(
object
)).
CreateActionIMessage
(
method
);
...
...
@@ -174,4 +182,4 @@ namespace Google.Protobuf.Reflection
// Public to make the reflection simpler.
public
static
SampleEnum
SampleEnumMethod
()
=>
SampleEnum
.
X
;
}
}
\ No newline at end of file
}
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