public static void WriteTypeMetaInfo(IStreamWriter writer, ITypeStructure typeItem, bool writeTypeMetaPrefix = true) { if (writeTypeMetaPrefix) { writer.WriteUInt8(ValueItem.TypeMetaInfo); } writer.WriteUInt8(SingleTypeDescr); Type type = typeItem.RuntimeType; writer.WriteString(type.Assembly.GetName().Name); writer.WriteString(type.FullName); short itemCount = (short)typeItem.Items.Count; writer.WriteInt16(itemCount); for (int i = 0; i < itemCount; i++) { var memberItem = typeItem.Items[i]; writer.WriteInt16((short)memberItem.Type); // ItemType Enum writer.WriteUInt32(memberItem.TypeId); // TypeId (Type Hash) writer.WriteString(memberItem.Name); // Property Name writer.WriteBool(memberItem.IsNullable); // Nullable Flag } }
/// <summary> /// Write enum type meta infos /// </summary> /// <param name="writer"></param> /// <param name="type"></param> public static void WriteTypeMetaInfo(IStreamWriter writer, Type type) { writer.WriteUInt8(ValueItem.TypeMetaInfo); writer.WriteUInt8(SingleTypeDescr); writer.WriteString(type.Assembly.GetName().Name); writer.WriteString(type.FullName); // Write 0 items (only type specification in case of enum) writer.WriteInt16(0); }
public static void SerializeConnect(IStreamWriter writer, ConnectCommand connect) { VersionSerializer.SerializeVersion(writer, connect.ProtocolVersion); var realm = connect.Realm; writer.WriteString(realm); }
/// <summary> /// Writes the value. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { string stringValue = (string)value; writer.WriteString(stringValue); }); }
public static void WriteTypeMetaInfo(IStreamWriter writer, CollectionItems collection) { writer.WriteUInt8(ValueItem.TypeMetaInfo); writer.WriteUInt8(CollectionTypeDescr); Type type = collection.RuntimeType; writer.WriteString(type.Assembly.GetName().Name); writer.WriteString(type.FullName); //writer.WriteBool(collection.IsArray); //if (collection.IsArray) //{ //} }
/// <summary> /// Writes the value. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { if (value == null) { writer.WriteUInt8(ValueItem.NullValueIdent); } else { string stringValue = (string)value; uint stringHashCode; if (context.Serializer.IsWriteHashStringRequired(stringValue, out stringHashCode)) { writer.WriteUInt8(ValueItem.HashCodeString); writer.WriteString(stringValue); } else { writer.WriteUInt8(ValueItem.SingleValueIdent); } writer.WriteUInt32(stringHashCode); } }
public static void SerializeLogin(IStreamWriter writer, LoginCommand login) { writer.WriteString(login.Username); writer.WriteString(login.Password); }