/// <summary> /// 序列化 /// </summary> /// <param name="_serializer_">对象序列化器</param> public unsafe void Serialize(fastCSharp.emit.dataSerializer _serializer_) { if (_serializer_.CheckPoint(this)) { { fastCSharp.unmanagedStream _stream_ = _serializer_.Stream; _stream_.PrepLength(sizeof(int) + 4 + 168); byte *_write_ = _stream_.CurrentData; *(int *)_write_ = 1073741855; _write_ += sizeof(int); byte *_nullMap_ = _write_; fastCSharp.unsafer.memory.Clear32(_write_, 4); _write_ += 4; if (!GuidNull.HasValue) { _nullMap_[2 >> 3] |= (byte)(1 << (2 & 7)); } else { *(System.Guid *)_write_ = (System.Guid)GuidNull; _write_ += sizeof(System.Guid); } if (!DecimalNull.HasValue) { _nullMap_[3 >> 3] |= (byte)(1 << (3 & 7)); } else { *(decimal *)_write_ = (decimal)DecimalNull; _write_ += sizeof(decimal); } { *(System.Guid *)_write_ = (System.Guid)Guid; _write_ += sizeof(System.Guid); } { *(decimal *)_write_ = (decimal)Decimal; _write_ += sizeof(decimal); } if (!LongNull.HasValue) { _nullMap_[4 >> 3] |= (byte)(1 << (4 & 7)); } else { *(long *)_write_ = (long)LongNull; _write_ += sizeof(long); } { *(long *)_write_ = (long)Long; _write_ += sizeof(long); } if (!DoubleNull.HasValue) { _nullMap_[5 >> 3] |= (byte)(1 << (5 & 7)); } else { *(double *)_write_ = (double)DoubleNull; _write_ += sizeof(double); } { *(double *)_write_ = (double)Double; _write_ += sizeof(double); } if (!DateTimeNull.HasValue) { _nullMap_[6 >> 3] |= (byte)(1 << (6 & 7)); } else { *(System.DateTime *)_write_ = (System.DateTime)DateTimeNull; _write_ += sizeof(System.DateTime); } if (!ULongNull.HasValue) { _nullMap_[7 >> 3] |= (byte)(1 << (7 & 7)); } else { *(ulong *)_write_ = (ulong)ULongNull; _write_ += sizeof(ulong); } { *(ulong *)_write_ = (ulong)ULong; _write_ += sizeof(ulong); } { *(System.DateTime *)_write_ = (System.DateTime)DateTime; _write_ += sizeof(System.DateTime); } if (!IntNull.HasValue) { _nullMap_[8 >> 3] |= (byte)(1 << (8 & 7)); } else { *(int *)_write_ = (int)IntNull; _write_ += sizeof(int); } { *(int *)_write_ = (int)Int; _write_ += sizeof(int); } if (!UIntNull.HasValue) { _nullMap_[9 >> 3] |= (byte)(1 << (9 & 7)); } else { *(uint *)_write_ = (uint)UIntNull; _write_ += sizeof(uint); } if (!FloatNull.HasValue) { _nullMap_[10 >> 3] |= (byte)(1 << (10 & 7)); } else { *(float *)_write_ = (float)FloatNull; _write_ += sizeof(float); } { *(float *)_write_ = (float)Float; _write_ += sizeof(float); } { *(uint *)_write_ = (uint)UInt; _write_ += sizeof(uint); } { *(ushort *)_write_ = (ushort)UShort; _write_ += sizeof(ushort); } if (!ShortNull.HasValue) { _nullMap_[11 >> 3] |= (byte)(1 << (11 & 7)); } else { *(short *)_write_ = (short)ShortNull; _write_ += sizeof(short); } { *(short *)_write_ = (short)Short; _write_ += sizeof(short); } if (!CharNull.HasValue) { _nullMap_[12 >> 3] |= (byte)(1 << (12 & 7)); } else { *(char *)_write_ = (char)CharNull; _write_ += sizeof(char); } if (!UShortNull.HasValue) { _nullMap_[13 >> 3] |= (byte)(1 << (13 & 7)); } else { *(ushort *)_write_ = (ushort)UShortNull; _write_ += sizeof(ushort); } { *(char *)_write_ = (char)Char; _write_ += sizeof(char); } if (!ByteNull.HasValue) { _nullMap_[14 >> 3] |= (byte)(1 << (14 & 7)); } else { *(byte *)_write_ = (byte)ByteNull; _write_ += sizeof(byte); } if (BoolNull.HasValue) { if ((bool)BoolNull) { _nullMap_[0 >> 3] |= (byte)(3 << (0 & 7)); } else { _nullMap_[0 >> 3] |= (byte)(1 << (0 & 7)); } } { *(byte *)_write_ = (byte)Byte; _write_ += sizeof(byte); } if (!SByteNull.HasValue) { _nullMap_[15 >> 3] |= (byte)(1 << (15 & 7)); } else { *(sbyte *)_write_ = (sbyte)SByteNull; _write_ += sizeof(sbyte); } { *(sbyte *)_write_ = (sbyte)SByte; _write_ += sizeof(sbyte); } if (Bool) { _nullMap_[16 >> 3] |= (byte)(1 << (16 & 7)); } if (String == null) { _nullMap_[17 >> 3] |= (byte)(1 << (17 & 7)); } _stream_.UnsafeAddSerializeLength((int)(_write_ - _stream_.CurrentData)); _stream_.PrepLength(); if (String != null) { _serializer_.MemberClassSerialize(String); } } } }
/// <summary> /// 序列化 /// </summary> /// <param name="_serializer_">对象序列化器</param> public unsafe void Serialize(fastCSharp.emit.dataSerializer _serializer_) { #region IF type.IsNull if (_serializer_.CheckPoint(this)) #endregion IF type.IsNull { #region IF Attribute.IsMemberMap if (_serializer_.SerializeMemberMap <@type.FullName>() == null) #endregion IF Attribute.IsMemberMap { #region IF NullMapFixedSize fastCSharp.unmanagedStream _stream_ = _serializer_.Stream; _stream_.PrepLength(sizeof(int) + @NullMapSize + @FixedSize); byte *_write_ = _stream_.CurrentData; *(int *)_write_ = @MemberCountVerify; _write_ += sizeof(int); #region IF NullMapSize byte *_nullMap_ = _write_; fastCSharp.unsafer.memory.Clear32(_write_, @NullMapSize); _write_ += @NullMapSize; #endregion IF NullMapSize #region LOOP Members #region NAME FixedSerialize #region IF MemberType.IsBool #region IF MemberType.IsNull if (/*NOTE*/ ((bool?)(object)/*NOTE*/ @MemberName /*NOTE*/) /*NOTE*/.HasValue) { if ((bool)/*NOTE*/ (object)/*NOTE*/ @MemberName) { _nullMap_[@SerializeNullMapIndex >> 3] |= (byte)(3 << (@SerializeNullMapIndex & 7)); } else { _nullMap_[@SerializeNullMapIndex >> 3] |= (byte)(1 << (@SerializeNullMapIndex & 7)); } } #endregion IF MemberType.IsNull #region NOT MemberType.IsNull if (/*NOTE*/ (bool)(object)/*NOTE*/ @MemberName) { _nullMap_[@SerializeNullMapIndex >> 3] |= (byte)(1 << (@SerializeNullMapIndex & 7)); } #endregion NOT MemberType.IsNull #endregion IF MemberType.IsBool #region NOT MemberType.IsBool #region IF MemberType.IsNull #region IF MemberType.NullType if (!/*NOTE*/ ((int?)(object)/*NOTE*/ @MemberName /*NOTE*/) /*NOTE*/.HasValue) { _nullMap_[@SerializeNullMapIndex >> 3] |= (byte)(1 << (@SerializeNullMapIndex & 7)); } #endregion IF MemberType.NullType #region NOT MemberType.NullType if (@MemberName == null) { _nullMap_[@SerializeNullMapIndex >> 3] |= (byte)(1 << (@SerializeNullMapIndex & 7)); } #endregion NOT MemberType.NullType #region IF SerializeFixedSize else #endregion IF SerializeFixedSize #endregion IF MemberType.IsNull #region IF SerializeFixedSize { *(@MemberType.StructNotNullType *)_write_ = (@MemberType.StructNotNullType) /*NOTE*/ (object) /*NOTE*//*IF:MemberType.Type.IsEnum*/ (@MemberType.EnumUnderlyingType.FullName) /*IF:MemberType.Type.IsEnum*/ @MemberName; _write_ += sizeof(@MemberType.StructNotNullType); } #endregion IF SerializeFixedSize #endregion NOT MemberType.IsBool #endregion NAME FixedSerialize #endregion LOOP Members _stream_.UnsafeAddSerializeLength((int)(_write_ - _stream_.CurrentData)); _stream_.PrepLength(); #endregion IF NullMapFixedSize #region NOT NullMapFixedSize _serializer_.Stream.Write(@MemberCountVerify); #endregion NOT NullMapFixedSize #region LOOP Members #region NAME NotFixedSerialize #region NOT SerializeFixedSize #region IF MemberType.IsNull #region IF MemberType.NullType if (/*NOTE*/ ((int?)(object)/*NOTE*/ @MemberName /*NOTE*/) /*NOTE*/.HasValue) #endregion IF MemberType.NullType #region NOT MemberType.NullType { if (@MemberName != null) #endregion NOT MemberType.NullType #endregion IF MemberType.IsNull #region IF MemberType.Type.IsValueType #region IF MemberType.NullType { _serializer_.MemberNullableSerialize(/*NOTE*/ (int?)(object)/*NOTE*/ @MemberName); } } #endregion IF MemberType.NullType #region NOT MemberType.NullType _serializer_.MemberStructSerialize(/*NOTE*/ (int)(object)/*NOTE*/ @MemberName); #endregion NOT MemberType.NullType #endregion IF MemberType.Type.IsValueType #region NOT MemberType.Type.IsValueType _serializer_.MemberClassSerialize(@MemberName); #endregion NOT MemberType.Type.IsValueType #endregion NOT SerializeFixedSize #endregion NAME NotFixedSerialize #endregion LOOP Members } #region IF Attribute.IsMemberMap else { #region IF NullMapFixedSize fastCSharp.unmanagedStream _stream_ = _serializer_.Stream; _stream_.PrepLength(@NullMapSize + @FixedSize); byte *_nullMap_ = _stream_.CurrentData /*IF:FixedSize*/, _write_ = _nullMap_ /*IF:FixedSize*/; #region IF NullMapSize fastCSharp.unsafer.memory.Clear32(_nullMap_, @NullMapSize); #region IF FixedSize _write_ += @NullMapSize; #endregion IF FixedSize #endregion IF NullMapSize #region LOOP Members if (_serializer_.IsMemberMap(@MemberIndex)) { #region FROMNAME FixedSerialize #endregion FROMNAME FixedSerialize } #endregion LOOP Members #region IF FixedSize _stream_.UnsafeAddLength(((int)(_write_ - _nullMap_) + 3) & (int.MaxValue - 3)); #endregion IF FixedSize #region NOT FixedSize _stream_.UnsafeAddLength(@NullMapSize); #endregion NOT FixedSize _stream_.PrepLength(); #endregion IF NullMapFixedSize #region LOOP Members if (_serializer_.IsMemberMap(@MemberIndex)) { #region FROMNAME NotFixedSerialize #endregion FROMNAME NotFixedSerialize } #endregion LOOP Members } #endregion IF Attribute.IsMemberMap } }