Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- serviceAssembly = Assembly.LoadFrom(path);
- public static byte[] TransformMessageToBytes(NotificationMessage msg)
- {
- if (msg == null)
- throw new ArgumentNullException(nameof(msg));
- using (MemoryStream stream = new MemoryStream())
- {
- BinaryFormatter binFormatter = new BinaryFormatter();
- binFormatter.Serialize(stream, msg);
- return stream.ToArray();
- }
- }
- public static NotificationMessage TransfromBytesToNotificationMessage(byte[] array, int offset, int count)
- {
- if(array == null)
- throw new ArgumentNullException(nameof(array));
- using (MemoryStream stream = new MemoryStream())
- {
- BinaryFormatter binFormatter = new BinaryFormatter();
- stream.Write(array, offset, count);
- stream.Seek(0, SeekOrigin.Begin);
- return binFormatter.Deserialize(stream) as NotificationMessage;
- }
- }
- serviceDomain.DoCallBack(() =>
- {
- // for example
- // create instance of NotificationMessage by using reflection
- // Invoke convertation methods
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement