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
833f02d3
Commit
833f02d3
authored
Oct 09, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev6.0' of
http://private.flyautomation.net:82/panruising/thick_public
into dev6.0
parents
7ebc388c
dbb0dbb9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
8 deletions
+53
-8
Reflect_Proxy.cs
Project.FLY.FObjSys/FObjBaseReflect/Reflect_Proxy.cs
+53
-8
No files found.
Project.FLY.FObjSys/FObjBaseReflect/Reflect_Proxy.cs
View file @
833f02d3
...
@@ -183,8 +183,8 @@ namespace FObjBase.Reflect
...
@@ -183,8 +183,8 @@ namespace FObjBase.Reflect
private
void
Obj_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
private
void
Obj_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
{
if
(
ignoreSet
)
//从服务器接收的数据,不用再推送给服务器
//
if (ignoreSet)//从服务器接收的数据,不用再推送给服务器
return
;
//
return;
if
(
interfaceType
==
null
)
if
(
interfaceType
==
null
)
return
;
return
;
...
@@ -207,8 +207,8 @@ namespace FObjBase.Reflect
...
@@ -207,8 +207,8 @@ namespace FObjBase.Reflect
private
void
Sub_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
private
void
Sub_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
{
if
(
ignoreSet
)
//从服务器接收的数据,不用再推送给服务器
//
if (ignoreSet)//从服务器接收的数据,不用再推送给服务器
return
;
//
return;
if
(!
subProperties
.
ContainsKey
(
sender
))
if
(!
subProperties
.
ContainsKey
(
sender
))
return
;
//异常, 不是子property
return
;
//异常, 不是子property
...
@@ -276,9 +276,9 @@ namespace FObjBase.Reflect
...
@@ -276,9 +276,9 @@ namespace FObjBase.Reflect
case
Reflect_OBJ_INTERFACE
.
CALL_SetProperty
:
case
Reflect_OBJ_INTERFACE
.
CALL_SetProperty
:
{
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
ignoreSet
=
true
;
//
ignoreSet = true;
JsonConvert
.
PopulateObject
(
json
,
obj
);
JsonConvert
.
PopulateObject
(
json
,
obj
);
ignoreSet
=
false
;
//
ignoreSet = false;
}
}
break
;
break
;
...
@@ -287,14 +287,21 @@ namespace FObjBase.Reflect
...
@@ -287,14 +287,21 @@ namespace FObjBase.Reflect
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
rData
=
JsonConvert
.
DeserializeObject
<
Reflect_OBJ_INTERFACE
.
ReflectData
>(
json
);
var
rData
=
JsonConvert
.
DeserializeObject
<
Reflect_OBJ_INTERFACE
.
ReflectData
>(
json
);
var
type
=
obj
.
GetType
();
var
type
=
obj
.
GetType
();
var
methodInfo
=
type
.
GetMethod
(
rData
.
name
);
var
paramNames_req
=
rData
.
data
.
Children
().
OfType
<
JProperty
>().
Select
(
p
=>
p
.
Name
);
MethodInfo
methodInfo
=
GetMethodInfo
(
type
,
rData
.
name
,
paramNames_req
);
if
(
methodInfo
==
null
)
{
//不能找到,
throw
new
Exception
(
$"程序写错了, 不能找到 rData.name=
{
rData
.
name
}
或者 参数名称不对,没法完全匹配"
);
}
var
parameterInfos
=
methodInfo
.
GetParameters
();
var
parameterInfos
=
methodInfo
.
GetParameters
();
object
[]
parameters
=
new
object
[
parameterInfos
.
Count
()];
object
[]
parameters
=
new
object
[
parameterInfos
.
Count
()];
for
(
int
i
=
0
;
i
<
parameters
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
parameters
.
Count
();
i
++)
{
{
var
ptype
=
parameterInfos
[
i
].
ParameterType
;
var
ptype
=
parameterInfos
[
i
].
ParameterType
;
var
pname
=
parameterInfos
[
i
].
Name
;
var
pname
=
parameterInfos
[
i
].
Name
;
if
(
string
.
Compare
(
pname
,
"asyncDelegate"
,
true
)==
0
)
if
(
string
.
Compare
(
pname
,
"asyncDelegate"
,
true
)
==
0
)
{
{
parameters
[
i
]
=
new
AsyncCBHandler
(
asyncDelegate
);
parameters
[
i
]
=
new
AsyncCBHandler
(
asyncDelegate
);
}
}
...
@@ -308,10 +315,48 @@ namespace FObjBase.Reflect
...
@@ -308,10 +315,48 @@ namespace FObjBase.Reflect
}
}
}
}
methodInfo
.
Invoke
(
obj
,
parameters
);
methodInfo
.
Invoke
(
obj
,
parameters
);
}
}
break
;
break
;
}
}
}
}
MethodInfo
GetMethodInfo
(
Type
type
,
string
name
,
IEnumerable
<
string
>
parameterNames
)
{
var
methodInfos
=
from
mi
in
type
.
GetMethods
()
where
mi
.
Name
==
name
select
mi
;
if
(
methodInfos
.
Count
()==
0
)
return
null
;
if
(
methodInfos
.
Count
()
==
1
)
return
methodInfos
.
First
();
//必须完全匹配
foreach
(
var
methodInfo
in
methodInfos
)
{
var
parameterInfos
=
methodInfo
.
GetParameters
();
var
names
=
parameterInfos
.
Select
(
pi
=>
pi
.
Name
);
var
names_req
=
parameterNames
;
//比较 names 与 names_data
var
exps_req
=
names_req
.
Except
(
names
);
if
(
exps_req
.
Count
()
!=
0
)
{
//请求的参数,这个method 不是全部都有
continue
;
}
var
exps
=
names
.
Except
(
names_req
);
if
(
exps
.
Count
()
==
2
&&
exps
.
Contains
(
"asyncDelegate"
)
&&
exps
.
Contains
(
"asyncContext"
))
{
//请求的参数 就只有 "asyncDelegate" 与 "asyncContext" 没有而已
//这个就是需要调用的 method
return
methodInfo
;
}
else
{
continue
;
}
}
return
null
;
}
void
asyncDelegate
(
object
asyncContext
,
object
retData
)
void
asyncDelegate
(
object
asyncContext
,
object
retData
)
{
{
var
cc
=
(
CC
)
asyncContext
;
var
cc
=
(
CC
)
asyncContext
;
...
...
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