/// <summary> /// 元数据转换成第三方数据 /// </summary> /// <param name="metadataObject">元数据集合</param> /// <param name="id">属性对应key</param> /// <param name="data">属性对应byte数组</param> /// <param name="offsetStart">属性在数组中的偏移值</param> /// <param name="length">属性在byte数组中的长度</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public void DataProcessor(MetadataContainer metadataObject, byte id, byte[] data, int offsetStart, uint length) { if (metadataObject == null) { throw new ArgumentNullException("metadataObject"); } uint arrayLength = BitConverter.ToUInt32(data, offsetStart); ResourceBlock[] resourceBlocks = new ResourceBlock[arrayLength]; offsetStart += 4; for (int j = 0; j < arrayLength; j++) { uint resouceBlockLength = BitConverter.ToUInt32(data, offsetStart); if (resouceBlockLength == 0) { resourceBlocks[j] = null; offsetStart += 4; } else { resourceBlocks[j] = MetadataObjectEngine.GetObject(data, (uint)offsetStart, resouceBlockLength); offsetStart += (int)resouceBlockLength; } } metadataObject.SetAttribute(id, new ResourceBlockArrayStored(resourceBlocks)); }
/// <summary> /// 解析元数据 /// </summary> /// <param name="data">总BUFF长度</param> /// <param name="offset">可用偏移量</param> /// <param name="count">可用长度</param> /// <returns> /// 返回能否解析的一个标示 /// </returns> public override List <T> Parse <T>(byte[] data, int offset, int count) { int totalLength; List <T> messages = new List <T>(); try { while (count > 0) { totalLength = BitConverter.ToInt32(data, offset); if (totalLength > data.Length) { _tracing.Error("#Parse message failed, illegal total length. #length: " + totalLength); return(messages); } int markRangeCount = BitConverter.ToUInt16(data, offset + 4); int markRangeLength = markRangeCount * 5 + offset; int protocolId = data[markRangeLength + 6]; int serviceId = data[markRangeLength + 7]; int detailsId = data[markRangeLength + 8]; MetadataContainer message; try { message = MetadataObjectEngine.GetObject(data, (uint)offset, (uint)totalLength); if (message == null) { _tracing.Error( "#Parse message failed, parse result = null. #protocol id={0}, service id={1}, detalis id={2}: ", protocolId, serviceId, detailsId); return(messages); } } catch (System.Exception ex) { _tracing.Error(ex, "#Parse message failed."); continue; } finally { offset += totalLength; count -= totalLength; } messages.Add((T)(object)message); if (data.Length - offset < 4) { break; } } return(messages); } catch (System.Exception ex) { _tracing.Error(ex, "#Parse message failed."); return(messages); } }
/// <summary> /// 第三方数据转换成元数据 /// </summary> /// <param name="proxy">内存段实例</param> /// <param name="baseValueMessage">存储属性的实例对象</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public void ValueProcessor(IMemorySegmentProxy proxy, BaseValueStored baseValueMessage) { if (proxy == null) { throw new ArgumentNullException("proxy"); } if (baseValueMessage == null) { throw new ArgumentNullException("baseValueMessage"); } ResourceBlock[] value = baseValueMessage.GetValue <ResourceBlock[]>(); proxy.WriteUInt32((uint)value.Length); for (int i = 0; i < value.Length; i++) { if (value[i] == null) { proxy.WriteUInt32(0); continue; } MetadataObjectEngine.ToBytes(value[i], proxy); } }
private void InnerHightSpeedSendTest(int destinationInstanceCount, int destinationMsgCount, int port) { int msgRecvCount = 0, sendMsgCount = 0; int previousMsgRecvCount = 0, previousSendMsgCount = 0; AutoResetEvent msgEvent = new AutoResetEvent(false); Console.Write("#Begining prepare Host channel resource..."); TcpHostTransportChannel hostChannel = new TcpHostTransportChannel(port); Assert.IsTrue(hostChannel.Regist()); hostChannel.ChannelCreated += delegate(object sender, LightSingleArgEventArgs <ITransportChannel> args) { MessageTransportChannel <MetadataContainer> msgChannel = new MessageTransportChannel <MetadataContainer>((IRawTransportChannel)args.Target, new MetadataProtocolStack()); msgChannel.ReceivedMessage += delegate(object s, LightSingleArgEventArgs <List <MetadataContainer> > a) { Interlocked.Add(ref msgRecvCount, a.Target.Count); }; }; Console.WriteLine("Done"); Console.Write("#Begining prepare {0} numbers of TCP channel...", destinationInstanceCount); IList <TcpTransportChannel> clients = new List <TcpTransportChannel>(); for (int i = 0; i < destinationInstanceCount; i++) { TcpTransportChannel transportChannel = new TcpTransportChannel("127.0.0.1", port); Assert.IsTrue(transportChannel.CommunicationState == CommunicationStates.Unknown); transportChannel.Connect(); Assert.IsTrue(transportChannel.IsConnected); Assert.IsTrue(transportChannel.CommunicationState == CommunicationStates.Opened); clients.Add(transportChannel); } Console.WriteLine("Done"); MetadataContainer container = new MetadataContainer(); container.SetAttribute(0x00, new StringValueStored("Test-Name")); container.SetAttribute(0x01, new StringValueStored("Test-Value")); byte[] data = MetadataObjectEngine.ToBytes(container); Assert.IsNotNull(data); Console.WriteLine("#Sending message on those of transport channels..."); ThreadPool.QueueUserWorkItem(delegate { while (true) { previousMsgRecvCount = msgRecvCount; previousSendMsgCount = sendMsgCount; Thread.Sleep(1000); if (destinationMsgCount != previousSendMsgCount || destinationMsgCount != previousMsgRecvCount) { Console.WriteLine(); Console.WriteLine("Send Count: {0} <---{1} messages/per-second.", sendMsgCount, sendMsgCount - previousSendMsgCount); Console.WriteLine("Recv Count: {0} <---{1} messages/per-second.", msgRecvCount, msgRecvCount - previousMsgRecvCount); Console.WriteLine(); } } }); ThreadPool.QueueUserWorkItem(delegate { while (sendMsgCount != destinationMsgCount) { for (int i = 0; i < clients.Count; i++) { clients[i].Send(data); Interlocked.Increment(ref sendMsgCount); if (sendMsgCount == destinationMsgCount) { break; } } //Thread.Sleep(100); } msgEvent.Set(); }); msgEvent.WaitOne(); Thread.Sleep(2000); Assert.IsTrue(sendMsgCount == destinationMsgCount); Assert.IsTrue(sendMsgCount == msgRecvCount); foreach (TcpTransportChannel clientChannel in clients) { clientChannel.Disconnect(); } Thread.Sleep(2000); }
public void SendMessageTest() { ITransportChannel connectedChannel = null; AutoResetEvent resetEvent = new AutoResetEvent(false); AutoResetEvent msgEvent = new AutoResetEvent(false); AutoResetEvent channelEvent = new AutoResetEvent(false); TcpHostTransportChannel hostChannel = new TcpHostTransportChannel(20005); Assert.IsTrue(hostChannel.Regist()); hostChannel.ChannelCreated += delegate(object sender, LightSingleArgEventArgs <ITransportChannel> args) { connectedChannel = args.Target; channelEvent.Set(); }; TcpTransportChannel transportChannel = new TcpTransportChannel("127.0.0.1", 20005); Assert.IsTrue(transportChannel.CommunicationState == CommunicationStates.Unknown); transportChannel.Connect(); if (!channelEvent.WaitOne(2000)) { throw new System.Exception("#Cannot passed channel be connect test."); } Assert.IsNotNull(connectedChannel); Assert.IsTrue(connectedChannel.IsConnected); Assert.IsTrue(transportChannel.IsConnected); Assert.IsTrue(transportChannel.CommunicationState == CommunicationStates.Opened); MetadataContainer msg = null; IMessageTransportChannel <MetadataContainer> msgChannel = new MessageTransportChannel <MetadataContainer>((IRawTransportChannel)connectedChannel, new MetadataProtocolStack()); msgChannel.ReceivedMessage += delegate(object sender, LightSingleArgEventArgs <List <MetadataContainer> > args) { msg = args.Target[0]; msgEvent.Set(); }; MetadataContainer container = new MetadataContainer(); container.SetAttribute(0x00, new StringValueStored("Test-Name")); container.SetAttribute(0x01, new StringValueStored("Test-Value")); byte[] data = MetadataObjectEngine.ToBytes(container); Assert.IsNotNull(data); int sendCount = transportChannel.Send(data); Assert.IsTrue(sendCount == data.Length || sendCount == 1); if (!msgEvent.WaitOne(2000)) { throw new System.Exception("#Cannot passed message channel receive test."); } Assert.IsNotNull(msg); Console.WriteLine(msg); msgChannel.Disconnected += delegate { resetEvent.Set(); }; transportChannel.Disconnect(); if (!resetEvent.WaitOne(10000)) { throw new System.Exception("#Cannot passed transport channel disconnect test."); } Assert.IsTrue(transportChannel.CommunicationState == CommunicationStates.Closed); Thread.Sleep(2000); Assert.IsTrue(!connectedChannel.IsConnected); Assert.IsTrue(hostChannel.UnRegist()); }
/// <summary> /// 初始化普通类型第三方数据转元数据的处理器 /// </summary> /// <exception cref="ArgumentNullException">参数不能为空</exception> private static void InitializeValueProcessorDictionary() { ValueActions.Add((byte)PropertyTypes.Boolean, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <bool>() == DefaultValue.Boolean) { return; } proxy.WriteBoolean(valueStored.GetValue <bool>()); }); ValueActions.Add((byte)PropertyTypes.Byte, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <byte>() == DefaultValue.Byte) { return; } proxy.WriteByte(valueStored.GetValue <byte>()); }); ValueActions.Add((byte)PropertyTypes.SByte, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <sbyte>() == DefaultValue.SByte) { return; } proxy.WriteSByte(valueStored.GetValue <sbyte>()); }); ValueActions.Add((byte)PropertyTypes.Char, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <char>() == DefaultValue.Char) { return; } proxy.WriteChar(valueStored.GetValue <char>()); }); ValueActions.Add((byte)PropertyTypes.Int16, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <short>() == DefaultValue.Int16) { return; } proxy.WriteInt16(valueStored.GetValue <short>()); }); ValueActions.Add((byte)PropertyTypes.UInt16, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <ushort>() == DefaultValue.UInt16) { return; } proxy.WriteUInt16(valueStored.GetValue <ushort>()); }); ValueActions.Add((byte)PropertyTypes.Int32, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <int>() == DefaultValue.Int32) { return; } proxy.WriteInt32(valueStored.GetValue <int>()); }); ValueActions.Add((byte)PropertyTypes.UInt32, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <uint>() == DefaultValue.UInt32) { return; } proxy.WriteUInt32(valueStored.GetValue <uint>()); }); ValueActions.Add((byte)PropertyTypes.Int64, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <long>() == DefaultValue.Int64) { return; } proxy.WriteInt64(valueStored.GetValue <long>()); }); ValueActions.Add((byte)PropertyTypes.UInt64, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <ulong>() == DefaultValue.UInt64) { return; } proxy.WriteUInt64(valueStored.GetValue <ulong>()); }); ValueActions.Add((byte)PropertyTypes.Float, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <float>() == DefaultValue.Float) { return; } proxy.WriteFloat(valueStored.GetValue <float>()); }); ValueActions.Add((byte)PropertyTypes.Double, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <double>() == DefaultValue.Double) { return; } proxy.WriteDouble(valueStored.GetValue <double>()); }); ValueActions.Add((byte)PropertyTypes.Decimal, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <decimal>() == DefaultValue.Decimal) { return; } proxy.WriteDecimal(valueStored.GetValue <decimal>()); }); ValueActions.Add((byte)PropertyTypes.String, (proxy, valueStored) => proxy.WriteString(valueStored.GetValue <string>())); ValueActions.Add((byte)PropertyTypes.DateTime, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <DateTime>() == DefaultValue.DateTime) { return; } proxy.WriteDateTime(valueStored.GetValue <DateTime>()); }); ValueActions.Add((byte)PropertyTypes.Guid, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <Guid>() == DefaultValue.Guid) { return; } proxy.WriteGuid(valueStored.GetValue <Guid>()); }); ValueActions.Add((byte)PropertyTypes.IPEndPoint, (proxy, valueStored) => proxy.WriteIPEndPoint(valueStored.GetValue <IPEndPoint>())); ValueActions.Add((byte)PropertyTypes.IntPtr, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <IntPtr>() == DefaultValue.IntPtr) { return; } proxy.WriteIntPtr(valueStored.GetValue <IntPtr>()); }); ValueActions.Add((byte)PropertyTypes.ResourceBlock, (proxy, valueStored) => MetadataObjectEngine.ToBytes(valueStored.GetValue <ResourceBlock>(), proxy)); ValueActions.Add((byte)PropertyTypes.TimeSpan, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (valueStored.GetValue <TimeSpan>() == DefaultValue.TimeSpan) { return; } proxy.WriteTimeSpan(valueStored.GetValue <TimeSpan>()); }); ValueActions.Add((byte)PropertyTypes.BitFlag, (proxy, valueStored) => proxy.WriteBitFlag(valueStored.GetValue <BitFlag>())); ValueActions.Add((byte)PropertyTypes.Blob, delegate(IMemorySegmentProxy proxy, BaseValueStored valueStored) { if (proxy == null) { throw new ArgumentNullException("proxy"); } if (valueStored == null) { throw new ArgumentNullException("valueStored"); } byte[] data = valueStored.GetValue <Blob>().Compress(); proxy.WriteMemory(data, 0U, (uint)data.Length); }); ValueActions.Add((byte)PropertyTypes.Null, delegate { }); }
/// <summary> /// 初始化普通类型元数据转第三方数据的处理器 /// </summary> /// <exception cref="ArgumentNullException">参数不能为空</exception> private static unsafe void InitializeDataProcessorDictionary() { DataActions.Add((byte)PropertyTypes.Boolean, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new BooleanValueStored(DefaultValue.Boolean)); } else { metadataObject.SetAttribute(id, new BooleanValueStored(BitConverter.ToBoolean(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Byte, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new ByteValueStored(DefaultValue.Byte)); } else { metadataObject.SetAttribute(id, new ByteValueStored(byteData[offsetStart])); } }); DataActions.Add((byte)PropertyTypes.SByte, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new SByteValueStored(DefaultValue.SByte)); } else { fixed(byte *pByte = (&byteData[offsetStart])) metadataObject.SetAttribute(id, new SByteValueStored(*(sbyte *)pByte)); } }); DataActions.Add((byte)PropertyTypes.Char, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new CharValueStored(DefaultValue.Char)); } else { metadataObject.SetAttribute(id, new CharValueStored(BitConverter.ToChar(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Int16, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new Int16ValueStored(DefaultValue.Int16)); } else { metadataObject.SetAttribute(id, new Int16ValueStored(BitConverter.ToInt16(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.UInt16, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new UInt16ValueStored(DefaultValue.UInt16)); } else { metadataObject.SetAttribute(id, new UInt16ValueStored(BitConverter.ToUInt16(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Int32, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new Int32ValueStored(DefaultValue.Int32)); } else { metadataObject.SetAttribute(id, new Int32ValueStored(BitConverter.ToInt32(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.UInt32, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new UInt32ValueStored(DefaultValue.UInt32)); } else { metadataObject.SetAttribute(id, new UInt32ValueStored(BitConverter.ToUInt32(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Int64, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new Int64ValueStored(DefaultValue.Int64)); } else { metadataObject.SetAttribute(id, new Int64ValueStored(BitConverter.ToInt64(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.UInt64, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new UInt64ValueStored(DefaultValue.UInt64)); } else { metadataObject.SetAttribute(id, new UInt64ValueStored(BitConverter.ToUInt64(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Float, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new FloatValueStored(DefaultValue.Float)); } else { metadataObject.SetAttribute(id, new FloatValueStored(BitConverter.ToSingle(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Double, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new DoubleValueStored(DefaultValue.Double)); } else { metadataObject.SetAttribute(id, new DoubleValueStored(BitConverter.ToDouble(byteData, offsetStart))); } }); DataActions.Add((byte)PropertyTypes.Decimal, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new DecimalValueStored(DefaultValue.Decimal)); } else { fixed(byte *pByte = (&byteData[offsetStart])) metadataObject.SetAttribute(id, new DecimalValueStored(*(decimal *)pByte)); } }); DataActions.Add((byte)PropertyTypes.String, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new StringValueStored(null)); } else { metadataObject.SetAttribute(id, new StringValueStored(Encoding.UTF8.GetString(byteData, offsetStart, (int)offsetLength))); } }); DataActions.Add((byte)PropertyTypes.DateTime, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new DateTimeValueStored(DefaultValue.DateTime)); } else { metadataObject.SetAttribute(id, new DateTimeValueStored(new DateTime(BitConverter.ToInt64(byteData, offsetStart)))); } }); DataActions.Add((byte)PropertyTypes.Guid, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new GuidValueStored(DefaultValue.Guid)); } else { fixed(byte *pByte = (&byteData[offsetStart])) metadataObject.SetAttribute(id, new GuidValueStored(*(Guid *)pByte)); } }); DataActions.Add((byte)PropertyTypes.IPEndPoint, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { fixed(byte *pData = (&byteData[offsetStart])) { IPEndPoint iep = new IPEndPoint(new IPAddress(BitConverter.GetBytes(*(int *)pData)), *(int *)(pData + 4)); metadataObject.SetAttribute(id, new IPEndPointValueStored(iep)); } }); DataActions.Add((byte)PropertyTypes.IntPtr, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new IntPtrValueStored(DefaultValue.IntPtr)); } else { metadataObject.SetAttribute(id, new IntPtrValueStored(new IntPtr(BitConverter.ToInt32(byteData, offsetStart)))); } }); DataActions.Add((byte)PropertyTypes.ResourceBlock, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { metadataObject.SetAttribute(id, new ResourceBlockStored(MetadataObjectEngine.GetObject(byteData, (uint)offsetStart, offsetLength))); }); DataActions.Add((byte)PropertyTypes.TimeSpan, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { if (offsetLength == 0) { metadataObject.SetAttribute(id, new TimeSpanValueStored(DefaultValue.TimeSpan)); } else { fixed(byte *pData = (&byteData[offsetStart])) metadataObject.SetAttribute(id, new TimeSpanValueStored(new TimeSpan(*(long *)pData))); } }); DataActions.Add((byte)PropertyTypes.BitFlag, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { metadataObject.SetAttribute(id, new BitFlagValueStored(new BitFlag(byteData[offsetStart]))); }); DataActions.Add((byte)PropertyTypes.Blob, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { metadataObject.SetAttribute(id, new BlobValueStored(new Blob(byteData, offsetStart, (int)offsetLength))); }); DataActions.Add((byte)PropertyTypes.Null, delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength) { metadataObject.SetAttribute(id, new NullValueStored()); }); }
/// <summary> /// 内部指定类型序列化方法 /// </summary> /// <param name="proxy">内存代理器</param> public override void ToBytes(IMemorySegmentProxy proxy) { MetadataObjectEngine.ToBytes(_value, proxy); }
/// <summary> /// 将一个消息转换为2进制形式 /// </summary> /// <param name="message">需要转换的消息</param> /// <returns> /// 返回转换后的2进制 /// </returns> public override byte[] ConvertToBytes(object message) { return(MetadataObjectEngine.ToBytes((MetadataContainer)message)); }