private byte[] ConvertToBytes(ChoScalarObject obj) { if (_messageType == ChoUDPMessageType.Xml) return _encoding.GetBytes(ChoObject.XmlSerialize(new ChoScalarObject(obj))); else return ChoObject.Serialize(new ChoScalarObject(obj)); }
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(); //} }