diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-25 16:58:42 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-25 16:58:42 +0200 |
| commit | d530d39d7ed9b05e3e233adc62dceba2fd17e1fe (patch) | |
| tree | 2e042288fdeedd12e3ca0ee331743ebc115eb4b2 /Software/Visual_Studio/Tango.PMR/ExtensionMethods | |
| parent | adaddad79352c156303e9178a6f172a18af50cd2 (diff) | |
| download | Tango-d530d39d7ed9b05e3e233adc62dceba2fd17e1fe.tar.gz Tango-d530d39d7ed9b05e3e233adc62dceba2fd17e1fe.zip | |
Improved extension methods support on procedures.
Drastically reduces procedure designer loading time.
DataStore proto support fully working and tested.
Diffstat (limited to 'Software/Visual_Studio/Tango.PMR/ExtensionMethods')
| -rw-r--r-- | Software/Visual_Studio/Tango.PMR/ExtensionMethods/IMessageExtensions.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.PMR/ExtensionMethods/IMessageExtensions.cs b/Software/Visual_Studio/Tango.PMR/ExtensionMethods/IMessageExtensions.cs new file mode 100644 index 000000000..84acb51d2 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/ExtensionMethods/IMessageExtensions.cs @@ -0,0 +1,27 @@ +using Google.Protobuf; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public static class IMessageExtensions +{ + /// <summary> + /// Serializes this PMR message to byte array. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="message">The message.</param> + /// <returns></returns> + public static byte[] ToBytes<T>(this T message) where T : IMessage<T> + { + using (MemoryStream ms = new MemoryStream()) + { + message.WriteTo(ms); + return ms.ToArray(); + } + } +} + |
