public void SetItemParam(uint start, ref ItemParamValue ipv, int value) { int TotalSize = sizeof(int) * ItemDefine.MAX_ITEM_PARAM; int size; switch (ipv) { case ItemParamValue.IPV_CHAR: { size = 1; if (start <= ((uint)TotalSize - (uint)size)) { m_Param[start] = (byte)(value); } } break; case ItemParamValue.IPV_SHORT: { size = 2; if (start <= ((uint)TotalSize - (uint)size)) { byte[] b = BitConverter.GetBytes(value); Array.Copy(b, 0, m_Param, start, b.Length); } } break; case ItemParamValue.IPV_INT: { size = 4; if (start <= ((uint)TotalSize - (uint)size)) { byte[] b = BitConverter.GetBytes(value); Array.Copy(b, 0, m_Param, start, b.Length); } } break; default: break; } }
public int GetItemParamValue(uint Start, ref ItemParamValue ipv) { int TotalSize = sizeof(int) * ItemDefine.MAX_ITEM_PARAM; int nSize; switch (ipv) { case ItemParamValue.IPV_CHAR: { nSize = 1; if (Start <= ((uint)TotalSize - (uint)nSize)) { return(m_Param[Start]); } } break; case ItemParamValue.IPV_SHORT: { nSize = 2; if (Start <= ((uint)TotalSize - (uint)nSize)) { return(BitConverter.ToInt16(m_Param, (int)Start)); } } break; case ItemParamValue.IPV_INT: { nSize = 4; if (Start <= ((uint)TotalSize - (uint)nSize)) { return(BitConverter.ToInt32(m_Param, (int)Start)); } } break; default: break; } return(-1); }