summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-03-14 17:16:58 +0000
committersr55 <[email protected]>2015-03-14 17:16:58 +0000
commit0b14b5646566aa90026466dd7c4b3430dec7c093 (patch)
tree52de74050a00326f0442dac74af6b7f77b18031d /win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs
parent600687b0c1be4c35c6b18a37a8fddc1e72f020fc (diff)
WinGui: Remove the Caliburn Micro / Castle dependency in The services library, and make the low-level json api public.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6986 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs b/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs
new file mode 100644
index 000000000..53db9e23f
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HandBrake.ApplicationServices.Utilities
+{
+ using System.Linq.Expressions;
+ using System.Reflection;
+
+ public static class ExtensionMethods
+ {
+ /// <summary>
+ /// Converts an expression into a <see cref="MemberInfo"/>.
+ /// </summary>
+ /// <param name="expression">The expression to convert.</param>
+ /// <returns>The member info.</returns>
+ public static MemberInfo GetMemberInfo(this Expression expression)
+ {
+ var lambda = (LambdaExpression)expression;
+
+ MemberExpression memberExpression;
+ if (lambda.Body is UnaryExpression)
+ {
+ var unaryExpression = (UnaryExpression)lambda.Body;
+ memberExpression = (MemberExpression)unaryExpression.Operand;
+ }
+ else
+ memberExpression = (MemberExpression)lambda.Body;
+
+ return memberExpression.Member;
+ }
+
+ }
+}