Пример #1
0
        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
            }
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        public static void SerializeConnect(IStreamWriter writer, ConnectCommand connect)
        {
            VersionSerializer.SerializeVersion(writer, connect.ProtocolVersion);
            var realm = connect.Realm;

            writer.WriteString(realm);
        }
Пример #4
0
        /// <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);
            });
        }
Пример #5
0
        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)
            //{

            //}
        }
Пример #6
0
        /// <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);
            }
        }
Пример #7
0
 public static void SerializeLogin(IStreamWriter writer, LoginCommand login)
 {
     writer.WriteString(login.Username);
     writer.WriteString(login.Password);
 }