public virtual int Size() { int nSize = 0; try { nSize += CounterType_Serializer.Size(counter_type); nSize += sizeof(int); nSize += sizeof(ulong); } catch (System.Exception) { return(-1); } return(nSize); }
public virtual bool Store(MemoryStream _buf_) { try { if (false == CounterType_Serializer.Store(_buf_, counter_type)) { return(false); } _buf_.Write(BitConverter.GetBytes(counter_value), 0, sizeof(int)); _buf_.Write(BitConverter.GetBytes(update_date), 0, sizeof(ulong)); } catch (System.Exception) { return(false); } return(true); }
public virtual bool Load(MemoryStream _buf_) { try { if (false == CounterType_Serializer.Load(ref counter_type, _buf_)) { return(false); } if (sizeof(int) > _buf_.Length - _buf_.Position) { return(false); } counter_value = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position); _buf_.Position += sizeof(int); if (sizeof(ulong) > _buf_.Length - _buf_.Position) { return(false); } update_date = BitConverter.ToUInt64(_buf_.GetBuffer(), (int)_buf_.Position); _buf_.Position += sizeof(ulong); } catch (System.Exception) { return(false); } return(true); }