public static void Write <T>(TLBinaryWriter to, object value) { if (value == null) { to.WriteUInt32(0x56730BCC); return; } var type = typeof(T); if (type == typeof(UInt32)) { to.WriteUInt32((uint)value); } else if (type == typeof(Int32)) { to.WriteInt32((int)value); } else if (type == typeof(UInt64)) { to.WriteUInt64((ulong)value); } else if (type == typeof(Int64)) { to.WriteInt64((long)value); } else if (type == typeof(Double)) { to.WriteDouble((double)value); } else if (type == typeof(Boolean)) { to.WriteBoolean((bool)value); } else if (type == typeof(String)) { to.WriteString((string)value); } else if (type == typeof(Byte[])) { to.WriteByteArray((byte[])value); } else { to.WriteObject((TLObject)value); } }