110,536
社区成员
发帖
与我相关
我的任务
分享
private void showHexstr(string hexstr)
{
MainBody mainBody = Parser.Protocol2Entity(YM.Common.alg.HexToByte(hexstr));
ShowObj(mainBody.Area);
this.HexTextBox.AppendText(hexstr);
this.HexTextBox.AppendText("\r");
HexTextBox.ScrollToEnd();
}
public void ShowObj(object obj)
{
if (obj == null) return ;
System.Reflection.PropertyInfo[] ps = obj.GetType().GetProperties();
var displayNames = obj.GetType().GetCustomAttributes(typeof(DisplayNameAttribute), true);
string displayName;
if (displayNames.Length > 0)
displayName = (displayNames.GetValue(0) as DisplayNameAttribute).DisplayName;
else displayName = obj.GetType().Name;
this.ObjTextBox.AppendText(displayName);
this.ObjTextBox.AppendText("\r");
foreach (System.Reflection.PropertyInfo p in ps)
{
string value = "";
var o = p.GetValue(obj, null);
if (o != null)
{
string tmp = o.ToString();
displayNames = p.GetCustomAttributes(typeof(DisplayNameAttribute),true);
if (displayNames.Length > 0)
displayName = (displayNames.GetValue(0) as DisplayNameAttribute).DisplayName;
else displayName = p.Name;
value = displayName + ":" + value + tmp + " ";
}
this.ObjTextBox.AppendText(value);
this.ObjTextBox.AppendText("\r");
}
this.ObjTextBox.AppendText("\r");
this.ObjTextBox.AppendText("\r");
}