public void Encode(IWritableBuffer bw) { this.mask.Encode(bw); if (mask.CheckFlag(__FLAG_INFO)) { bw.Write(_info); } if (mask.CheckFlag(__FLAG_PROP)) { bw.Write(_prop); } }
public static void WriteUnknow(this IWritableBuffer bw, DataObject obj) { if (obj != null) { using (var tempBw = ByteBuffer.Pool.Get()) { var typeCode = Protocol.Instance.GetTypeCode(obj.GetType().FullName); tempBw.WriteUnsignedShort(typeCode); if (typeCode == 0) { Logger.Error("GetTypeCode failed! -> {0}", obj.GetType()); } else { obj.Encode(tempBw); } bw.WriteUnsignedVarint(tempBw.Length); bw.Write(tempBw); } } else { bw.WriteUnsignedVarint(0); } }
public void Encode(IWritableBuffer bw) { this.mask.Encode(bw); if (mask.CheckFlag(__FLAG_DATA)) { bw.Write(_data); } }
public static void WriteArray <T>(this IWritableBuffer bw, T[] arr) where T : DataObject, new() { int len = arr == null ? 0 : arr.Length; bw.WriteUnsignedVarint(len); for (int i = 0; i < len; i++) { bw.Write(arr[i]); } }
public static void WriteByteArray(this IWritableBuffer bw, byte[] dat) { var len = dat == null ? 0 : dat.Length; bw.WriteUnsignedVarint(len); if (len > 0) { bw.Write(dat); } }
public static void Write(this IWritableBuffer bw, ByteBuffer other) { if (other == null || other.Length == 0) { return; } if (other == bw) { throw new ArgumentException(); } bw.Write(other.data, 0, other.Length); }
public static void WriteUTF8(this IWritableBuffer bw, string str) { if (str != null) { using (var temp = ByteBuffer.Pool.Get()) { CodingUtil.DecodeUTF8(str, temp); bw.WriteUnsignedShort(temp.Length); bw.Write(temp.data, 0, temp.Length); } } else { bw.WriteShort(0); } }
public static void Write <T>(this IWritableBuffer bw, T obj) where T : DataObject, new() { if (obj != null) { using (var tempBw = ByteBuffer.Pool.Get()) { obj.Encode(tempBw); bw.WriteUnsignedVarint(tempBw.Length); bw.Write(tempBw); } } else { bw.WriteUnsignedVarint(0); } }
internal static void WritNode(this IWritableBuffer bw, DDNode obj, DDFieldTmpl fieldTmpl) { if (obj != null) { using (var tempBw = ByteBuffer.Pool.Get()) { if (fieldTmpl.isUnknowType) { var typeCode = Protocol.Instance.GetTypeCode(obj.Tmpl.fullName); tempBw.WriteUnsignedShort(typeCode); if (typeCode == 0) { Logger.Error("GetTypeCode failed! -> {0}", obj.GetType()); } else { obj.Encode(tempBw); } } else { if (fieldTmpl.objTmpl != obj.Tmpl.fullName) { Logger.Error("write failed! can't match tmpl {0} -> {1} ", fieldTmpl.objTmpl, obj.Tmpl.fullName); } else { obj.Encode(tempBw); } } bw.WriteUnsignedVarint(tempBw.Length); bw.Write(tempBw); } } else { bw.WriteShort(0); } }
public static void Write(this IWritableBuffer bw, byte[] bytes) { bw.Write(bytes, 0, bytes.Length); }