diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-06-04 01:22:32 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-06-04 01:22:32 +0300 |
| commit | acf120606f7495bd132c0250fccb1b975e9660da (patch) | |
| tree | 7ee25d9229317cf5042f20dd3966c7ea21be95c1 /Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs | |
| parent | a56f07ca4373ae1dd6127f7a047a2bf0689ac6ad (diff) | |
| download | Tango-acf120606f7495bd132c0250fccb1b975e9660da.tar.gz Tango-acf120606f7495bd132c0250fccb1b975e9660da.zip | |
Added PMR_VS solution.
Refactored discovery to be more generic.
Diffstat (limited to 'Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs index 096ed2bf4..3f01d07c8 100644 --- a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs +++ b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs @@ -1,4 +1,5 @@ -using Google.Protobuf.Reflection; +using Google.Protobuf; +using Google.Protobuf.Reflection; using System; using System.Collections.Generic; using System.ComponentModel; @@ -8,12 +9,10 @@ using System.Text; using System.Threading.Tasks; using Tango.PMR.Common; -namespace Tango.PMR -{ /// <summary> /// Contains PMR extension methods. /// </summary> - public static class ExtensionMethods + public static class ExtensionMethods { /// <summary> /// Gets the protobuf <see cref="OriginalNameAttribute"/> attribute value from the message type. @@ -32,5 +31,15 @@ namespace Tango.PMR else return value.ToString(); } + + /// <summary> + /// Gets the message parser. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> + public static MessageParser GetParser(this IMessage message) + { + MessageParser parser = message.GetType().GetProperty("Parser").GetValue(message) as MessageParser; + return parser; + } } -} |
