Пример #1
0
 private byte[] ConvertToBytes(ChoScalarObject obj)
 {
     if (_messageType == ChoUDPMessageType.Xml)
         return _encoding.GetBytes(ChoObject.XmlSerialize(new ChoScalarObject(obj)));
     else
         return ChoObject.Serialize(new ChoScalarObject(obj));
 }
Пример #2
0
        public void WriteData(T target)
        {
            ChoGuard.ArgumentNotNullOrEmpty(target, "Target");
            ChoGuard.NotDisposed(this);

            //using (Mutex mutex = new Mutex(false, ChoMutexHelper.GetName(_name)))
            //{
            //    mutex.WaitOne();
            using (MemoryMappedViewStream stream = mf.CreateViewStream())
            {
                if (_msgFormatter == ChoMsgFormatter.Binary)
                {
                    ChoObject.Serialize(stream, target);
                }
                else
                {
                    ChoObject.XmlSerialize(stream, target);
                }
            }
            _event.Set();
            //}
        }