bool ProcessRPC(CRPC cSignal, params object[] parametrs) { Type type = cSignal.GetType(); FieldInfo[] properties = cSignal.GetType().GetFields(); //Console.WriteLine("cmp len {0} {1}", parametrs.Length, properties.Length); if (parametrs.Length != properties.Length + 1) { return(false); } object param = null; int i = 1; foreach (FieldInfo property in properties) { if (i <= parametrs.Length + 1) { param = parametrs[i]; i++; } else { param = null; } //Console.WriteLine("param {0}", param); if (param != null) { //Console.WriteLine("cmp {0} {1}", property.FieldType, param.GetType()); if (property.FieldType == param.GetType()) { property.SetValue(cSignal, param); } else { cSignal = null; return(false); } } } MethodInfo onDone = cSignal.GetType().GetMethod("OnDone"); if (onDone != null) { if (!(bool)onDone.Invoke(cSignal, null)) { cSignal = null; return(false); } } return(true); }
public bool ProcessRPC(CRPC cSignal, params object[] parametrs) { Type type = cSignal.GetType(); FieldInfo[] properties = cSignal.GetType().GetFields(); if (parametrs.Length != properties.Length) { return(false); } object param = null; int i = 0; foreach (FieldInfo property in properties) { if (i <= parametrs.Length) { param = parametrs[i]; i++; } else { param = null; } if (param != null) { if (property.FieldType == param.GetType()) { property.SetValue(cSignal, param); } else { cSignal = null; return(false); } } } MethodInfo onDone = cSignal.GetType().GetMethod("OnDone"); if (onDone != null) { if (!(bool)onDone.Invoke(cSignal, null)) { cSignal = null; return(false); } } return(true); }