public static CmdItem toCmdItem(object o) { try { if (!mapCmdId.ContainsKey(o.GetType())) { Log.e("CmdItemHelper", "can not find object in mapCmdId, o.GetType() = " + o.GetType()); //DebugEx.debugBreak(); return(null); } SyncCmdID did = mapCmdId[o.GetType()]; SKBuiltinBuffer_t _t = Util.toSKBuffer(o.GetType().InvokeMember("ToByteArray", BindingFlags.InvokeMethod, null, o, null) as byte[]); return(CmdItem.CreateBuilder().SetCmdId((int)did).SetCmdBuf(_t).Build()); } catch (Exception exception) { Log.d("CmdItemHelper", "CmdItemHelper ToByteArray error" + exception); } return(null); }
public static CmdList getCmdItemList() { List <OpLog> list = _opList; CmdList.Builder builder = new CmdList.Builder(); if ((list == null) || (list.Count <= 0)) { // Log.e("OpLogMgr", "************ getCmdItemList************"); return(builder.SetCount(0).Build()); } foreach (OpLog log in list) { SKBuiltinBuffer_t _t = Util.toSKBuffer(log.bytesCmdBuf); CmdItem item = CmdItem.CreateBuilder().SetCmdId(log.nCmdId).SetCmdBuf(_t).Build(); if (item != null) { builder.ListList.Add(item); } } return(builder.SetCount((uint)builder.ListList.Count).Build()); }