Commit 3c15e477 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 FObject.Reflect NodeDispose node.Obj 不是 INotifyPropertyChanged 时,出错

parent 9e6a0e4b
...@@ -224,7 +224,7 @@ namespace FObjBase.Reflect ...@@ -224,7 +224,7 @@ namespace FObjBase.Reflect
{ {
if (!node.IsArray) if (!node.IsArray)
{ {
if (node.Obj != null) if (node.Obj != null && node.Obj is INotifyPropertyChanged)
((INotifyPropertyChanged)(node.Obj)).PropertyChanged -= node.PropertyChanged; ((INotifyPropertyChanged)(node.Obj)).PropertyChanged -= node.PropertyChanged;
} }
......
...@@ -379,6 +379,10 @@ namespace FObjBase.Reflect ...@@ -379,6 +379,10 @@ namespace FObjBase.Reflect
public IFConn from; public IFConn from;
public UInt32 srcid; public UInt32 srcid;
public UInt32 magic; public UInt32 magic;
/// <summary>
/// CALL_MethodInvoke 时使用
/// </summary>
public string methodName; public string methodName;
} }
} }
......
...@@ -227,7 +227,7 @@ namespace FObjBase.Reflect ...@@ -227,7 +227,7 @@ namespace FObjBase.Reflect
name = COMMON.GetNodePath(node), name = COMMON.GetNodePath(node),
data = jObject data = jObject
}; };
reponse_CALL_SetProperty(rData); send_CALL_SetProperty(rData);
} }
...@@ -252,7 +252,7 @@ namespace FObjBase.Reflect ...@@ -252,7 +252,7 @@ namespace FObjBase.Reflect
name = methodName, name = methodName,
data = parameters == null ? null : JObject.FromObject(parameters) data = parameters == null ? null : JObject.FromObject(parameters)
}; };
reponse_CALL_MethodInvoke(rData, asyncDelegate, asyncContext); send_CALL_MethodInvoke(rData, asyncDelegate, asyncContext);
} }
protected void Call(string methodName, object parameters) protected void Call(string methodName, object parameters)
...@@ -265,13 +265,40 @@ namespace FObjBase.Reflect ...@@ -265,13 +265,40 @@ namespace FObjBase.Reflect
Call(methodName, null, null, null); Call(methodName, null, null, null);
} }
void request_CALL_GetAllProperties(Reflect_OBJ_INTERFACE.ReflectData rData)
/// <summary>
/// 处理 从服务器 回复的 CALL_GetAllProperties
/// </summary>
/// <param name="rData"></param>
void receive_CALL_GetAllProperties(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
request_PUSH_PropertyChanged(rData); receive_PUSH_PropertyChanged(rData);
IsSynced = true; IsSynced = true;
DealPushInfoList(); DealPushInfoList();
} }
void request_PUSH_PropertyChanged(Reflect_OBJ_INTERFACE.ReflectData rData)
/// <summary>
/// 处理全部 缓存的推送数据
/// </summary>
void DealPushInfoList()
{
for (int i = 0; i < pushInfoList.Count(); i++)
{
var pushInfoData = pushInfoList[i];
if (pushInfoData.isPushPropertyChanged)
receive_PUSH_PropertyChanged(pushInfoData.rData);
else
receive_PUSH_Event(pushInfoData.rData);
}
pushInfoList.Clear();
}
/// <summary>
/// 处理 从服务器 回复的 PUSH_PropertyChanged
/// </summary>
/// <param name="rData"></param>
void receive_PUSH_PropertyChanged(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
ignoreSet = true; ignoreSet = true;
IsInPushValue = true; IsInPushValue = true;
...@@ -289,7 +316,12 @@ namespace FObjBase.Reflect ...@@ -289,7 +316,12 @@ namespace FObjBase.Reflect
IsInPushValue = false; IsInPushValue = false;
ignoreSet = false; ignoreSet = false;
} }
void request_PUSH_Event(Reflect_OBJ_INTERFACE.ReflectData rData)
/// <summary>
/// 处理 从服务器 回复的 PUSH_Event
/// </summary>
/// <param name="rData"></param>
void receive_PUSH_Event(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
if (InterfaceType == null) if (InterfaceType == null)
return; return;
...@@ -309,7 +341,14 @@ namespace FObjBase.Reflect ...@@ -309,7 +341,14 @@ namespace FObjBase.Reflect
//出错,就提示,肯定是客户端忘记写 "Trigger_XXXX" //出错,就提示,肯定是客户端忘记写 "Trigger_XXXX"
methodInfo.Invoke(this, new object[] { obj }); methodInfo.Invoke(this, new object[] { obj });
} }
void request_CALL_MethodInvoke(Reflect_OBJ_INTERFACE.ReflectData rData, AsyncCBHandler asyncDelegate, object asyncContext)
/// <summary>
/// 处理 从服务器 回复的 CALL_MethodInvoke
/// </summary>
/// <param name="rData"></param>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
void receive_CALL_MethodInvoke(Reflect_OBJ_INTERFACE.ReflectData rData, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
var anyCall = anyCalls.Find(ac => ac.name == rData.name); var anyCall = anyCalls.Find(ac => ac.name == rData.name);
if (anyCall == null) if (anyCall == null)
...@@ -324,7 +363,14 @@ namespace FObjBase.Reflect ...@@ -324,7 +363,14 @@ namespace FObjBase.Reflect
} }
#endregion #endregion
void reponse_CALL_MethodInvoke(Reflect_OBJ_INTERFACE.ReflectData rData, AsyncCBHandler asyncDelegate, object asyncContext)
/// <summary>
/// 发送 CALL_MethodInvoke 请求到服务器
/// </summary>
/// <param name="rData"></param>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
void send_CALL_MethodInvoke(Reflect_OBJ_INTERFACE.ReflectData rData, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
string json = JsonConvert.SerializeObject(rData); string json = JsonConvert.SerializeObject(rData);
...@@ -334,7 +380,11 @@ namespace FObjBase.Reflect ...@@ -334,7 +380,11 @@ namespace FObjBase.Reflect
asyncDelegate, asyncContext); asyncDelegate, asyncContext);
} }
void reponse_CALL_SetProperty(Reflect_OBJ_INTERFACE.ReflectData rData) /// <summary>
/// 发送 CALL_SetProperty 请求到服务器
/// </summary>
/// <param name="rData"></param>
void send_CALL_SetProperty(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
string json = JsonConvert.SerializeObject(rData); string json = JsonConvert.SerializeObject(rData);
...@@ -386,9 +436,9 @@ namespace FObjBase.Reflect ...@@ -386,9 +436,9 @@ namespace FObjBase.Reflect
} }
if(infoid == Reflect_OBJ_INTERFACE.PUSH_PropertyChanged) if(infoid == Reflect_OBJ_INTERFACE.PUSH_PropertyChanged)
request_PUSH_PropertyChanged(rData); receive_PUSH_PropertyChanged(rData);
else else
request_PUSH_Event(rData); receive_PUSH_Event(rData);
} }
break; break;
...@@ -396,22 +446,6 @@ namespace FObjBase.Reflect ...@@ -396,22 +446,6 @@ namespace FObjBase.Reflect
} }
/// <summary>
/// 处理全部 缓存的推送数据
/// </summary>
void DealPushInfoList()
{
for (int i = 0; i < pushInfoList.Count(); i++)
{
var pushInfoData = pushInfoList[i];
if(pushInfoData.isPushPropertyChanged)
request_PUSH_PropertyChanged(pushInfoData.rData);
else
request_PUSH_Event(pushInfoData.rData);
}
pushInfoList.Clear();
}
public override void PushCallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] retdata, AsyncCBHandler asyncDelegate, object asyncContext) public override void PushCallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] retdata, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
...@@ -422,7 +456,7 @@ namespace FObjBase.Reflect ...@@ -422,7 +456,7 @@ namespace FObjBase.Reflect
string json = Misc.Converter.BytesToString(retdata); string json = Misc.Converter.BytesToString(retdata);
var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json); var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json);
request_CALL_GetAllProperties(rData); receive_CALL_GetAllProperties(rData);
} }
break; break;
case Reflect_OBJ_INTERFACE.CALL_MethodInvoke: case Reflect_OBJ_INTERFACE.CALL_MethodInvoke:
...@@ -433,7 +467,7 @@ namespace FObjBase.Reflect ...@@ -433,7 +467,7 @@ namespace FObjBase.Reflect
string json = Misc.Converter.BytesToString(retdata); string json = Misc.Converter.BytesToString(retdata);
var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json); var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json);
request_CALL_MethodInvoke(rData, asyncDelegate, asyncContext); receive_CALL_MethodInvoke(rData, asyncDelegate, asyncContext);
} }
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment