Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
06ad9957
Commit
06ad9957
authored
Jun 05, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 Reflect_SeviceClient 的 event 有默认 触发函数名称 Trigger_XXXXX
parent
d5138f41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
CallAttribute.cs
Project.FLY.FObjSys/FObjBaseReflect/CallAttribute.cs
+6
-5
Reflect_SeviceClient.cs
Project.FLY.FObjSys/FObjBaseReflect/Reflect_SeviceClient.cs
+10
-2
No files found.
Project.FLY.FObjSys/FObjBaseReflect/CallAttribute.cs
View file @
06ad9957
...
...
@@ -7,16 +7,17 @@ using System.Threading.Tasks;
namespace
FObjBase.Reflect
{
/// <summary>
/// 注册 event 返回类型
/// 注册 event 返回类型;
/// 客户端,默认使用 Trigger_xxxx(xxxx为event名称),作为触发事件的函数,该函数的参数类型就是EventArgsType;
/// </summary>
public
class
PushAttribute
:
Attribute
{
public
Type
EventArgsType
;
public
string
TriggerName
;
//
public PushAttribute(Type eventArgsType)
//
{
//
EventArgsType = eventArgsType;
//
}
public
PushAttribute
(
Type
eventArgsType
)
{
EventArgsType
=
eventArgsType
;
}
public
PushAttribute
(
Type
eventArgsType
,
string
triggerName
)
{
EventArgsType
=
eventArgsType
;
...
...
Project.FLY.FObjSys/FObjBaseReflect/Reflect_SeviceClient.cs
View file @
06ad9957
...
...
@@ -153,11 +153,18 @@ namespace FObjBase.Reflect
if
(
anyEvents
.
Any
(
ae
=>
ae
.
name
==
eventInfo
.
Name
))
continue
;
//已经添加了
string
triggerName
;
if
(
string
.
IsNullOrEmpty
(
pushAttribute
.
TriggerName
))
{
triggerName
=
"Trigger_"
+
eventInfo
.
Name
;
}
else
{
triggerName
=
pushAttribute
.
TriggerName
;
}
var
anyEvent
=
new
AnyEvent
()
{
name
=
eventInfo
.
Name
,
triggerName
=
pushAttribute
.
T
riggerName
,
triggerName
=
t
riggerName
,
retType
=
pushAttribute
.
EventArgsType
};
anyEvents
.
Add
(
anyEvent
);
...
...
@@ -324,6 +331,7 @@ namespace FObjBase.Reflect
//触发事件!!!
var
methodInfo
=
GetType
().
GetMethod
(
anyEvent
.
triggerName
);
var
obj
=
rData
.
data
.
ToObject
(
anyEvent
.
retType
);
//出错,就提示,肯定是客户端忘记写 "Trigger_XXXX"
methodInfo
.
Invoke
(
this
,
new
object
[]
{
obj
});
}
break
;
...
...
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