diff --git a/src/NReco.LambdaParser/Linq/IInvokeMethod.cs b/src/NReco.LambdaParser/Linq/IInvokeMethod.cs
index c9aed31..cdafaa4 100644
--- a/src/NReco.LambdaParser/Linq/IInvokeMethod.cs
+++ b/src/NReco.LambdaParser/Linq/IInvokeMethod.cs
@@ -2,24 +2,22 @@
using System.Collections.Generic;
using System.Text;
-namespace NReco.Linq
-{
+namespace NReco.Linq {
- ///
- /// Exposes a method that allows the invoke of a method within an object
- ///
- ///
- /// Interface to allow different implimentations of invoke method with different capabilities.
- /// ensures backwards compatibility and behavour.
- ///
- public interface IInvokeMethod
- {
+ ///
+ /// Exposes a method that allows the invoke of a method within an object
+ ///
+ ///
+ /// Interface to allow different implimentations of invoke method with different capabilities.
+ /// ensures backwards compatibility and behavour.
+ ///
+ public interface IInvokeMethod {
- ///
- /// Invokes a method within an object (targetobject), given a set of arguments / parameters passed to method
- ///
- /// An object reference to the return value of the method
- object Invoke(object TargetObject, string MethodName, object[] args);
+ ///
+ /// Invokes a method within an object (targetobject), given a set of arguments / parameters passed to method
+ ///
+ /// An object reference to the return value of the method
+ object Invoke(object targetObject, string methodName, object[] args);
- }
+ }
}
diff --git a/src/NReco.LambdaParser/Linq/ILambdaValue.cs b/src/NReco.LambdaParser/Linq/ILambdaValue.cs
index 0a0daca..f768b99 100644
--- a/src/NReco.LambdaParser/Linq/ILambdaValue.cs
+++ b/src/NReco.LambdaParser/Linq/ILambdaValue.cs
@@ -18,13 +18,13 @@
using System.Text;
using System.Threading.Tasks;
-namespace NReco.Linq
-{
+namespace NReco.Linq {
+
///
/// Represents a value in expressions produced by .
///
public interface ILambdaValue {
object Value { get; }
- }
+ }
}
diff --git a/src/NReco.LambdaParser/Linq/IValueComparer.cs b/src/NReco.LambdaParser/Linq/IValueComparer.cs
index fcfcb98..934245d 100644
--- a/src/NReco.LambdaParser/Linq/IValueComparer.cs
+++ b/src/NReco.LambdaParser/Linq/IValueComparer.cs
@@ -18,8 +18,8 @@
using System.Text;
using System.Threading.Tasks;
-namespace NReco.Linq
-{
+namespace NReco.Linq {
+
///
/// Exposes a method that compares two objects.
///
@@ -34,6 +34,6 @@ public interface IValueComparer {
///
/// A signed integer that indicates the relative values of x and y or null if values cannot be compared.
int? Compare(object x, object y);
- }
+ }
}
diff --git a/src/NReco.LambdaParser/Linq/LambdaParameterWrapper.cs b/src/NReco.LambdaParser/Linq/LambdaParameterWrapper.cs
index 471e791..71703fc 100644
--- a/src/NReco.LambdaParser/Linq/LambdaParameterWrapper.cs
+++ b/src/NReco.LambdaParser/Linq/LambdaParameterWrapper.cs
@@ -108,9 +108,9 @@ internal sealed class LambdaParameterWrapper : IComparable, ILambdaValue {
var delegParams =
#if NET40
- deleg.Method.GetParameters();
+ deleg.Method.GetParameters();
#else
- deleg.GetMethodInfo().GetParameters();
+ deleg.GetMethodInfo().GetParameters();
#endif
if (delegParams.Length != args.Length)
throw new TargetParameterCountException(
@@ -120,7 +120,7 @@ internal sealed class LambdaParameterWrapper : IComparable, ILambdaValue {
for (int i = 0; i < resolvedArgs.Length; i++) {
var argObj = args[i] is LambdaParameterWrapper ? ((LambdaParameterWrapper)args[i]).Value : args[i];
//Static method call below, what should we do with this? Perhaps we should move it somewhere else
- if (!NReco.OptionsParamsInvokeMethod.IsInstanceOfType(delegParams[i].ParameterType, argObj))
+ if (!NReco.InvokeMethod.IsInstanceOfType(delegParams[i].ParameterType, argObj))
argObj = Convert.ChangeType(argObj, delegParams[i].ParameterType, CultureInfo.InvariantCulture);
resolvedArgs[i] = argObj;
}
@@ -134,33 +134,33 @@ internal sealed class LambdaParameterWrapper : IComparable, ILambdaValue {
obj = ((LambdaParameterWrapper)obj).Value;
//Additional check since obj appears to still be null in some use cases
- if (obj == null)
- throw new NullReferenceException(String.Format("Property or field {0} target is null", propertyName));
+ if (obj == null)
+ throw new NullReferenceException(String.Format("Property or field {0} target is null", propertyName));
- PropertyInfo prop;
- try
- {
+ PropertyInfo prop;
+ try
+ {
#if NET40
prop = obj.GetType().GetProperty(propertyName);
#else
prop = obj.GetType().GetRuntimeProperty(propertyName);
#endif
- }
+ }
//Below covers an issue caused by properties declared in base classes with different signitures
//in these cases an AmbiguousMatchException is thrown
//if this happens then we look for the first match by propertyName since this
//seems to be the one from the decendant class.
catch (System.Reflection.AmbiguousMatchException)
- {
+ {
#if NET40
prop = obj.GetType().GetProperties().FirstOrDefault(rp=>rp.Name == propertyName);
#else
prop = obj.GetType().GetRuntimeProperties().FirstOrDefault(rp=>rp.Name == propertyName);
#endif
- }
+ }
- if (prop != null) {
+ if (prop != null) {
var propVal = prop.GetValue(obj, null);
return new LambdaParameterWrapper(propVal, Cmp, Inv);
}
diff --git a/src/NReco.LambdaParser/Linq/LambdaParser.cs b/src/NReco.LambdaParser/Linq/LambdaParser.cs
index 2959926..8045878 100644
--- a/src/NReco.LambdaParser/Linq/LambdaParser.cs
+++ b/src/NReco.LambdaParser/Linq/LambdaParser.cs
@@ -21,7 +21,6 @@
using System.ComponentModel;
using System.Globalization;
-
namespace NReco.Linq {
///
diff --git a/src/NReco.LambdaParser/OptionsParamsInvokeMethod.cs b/src/NReco.LambdaParser/OptionsParamsInvokeMethod.cs
index 6e8d1cd..b23faff 100644
--- a/src/NReco.LambdaParser/OptionsParamsInvokeMethod.cs
+++ b/src/NReco.LambdaParser/OptionsParamsInvokeMethod.cs
@@ -18,20 +18,15 @@
using System.Text;
using System.Reflection;
-namespace NReco {
+namespace NReco.Linq {
///
/// Invoke object's method that is most compatible with provided arguments
///
- public class OptionsParamsInvokeMethod : Linq.IInvokeMethod {
+ public class OptionsParamsInvokeMethod : IInvokeMethod {
internal readonly static OptionsParamsInvokeMethod _Instance = new OptionsParamsInvokeMethod();
- public static Linq.IInvokeMethod Instance
- {
- get {
- return _Instance;
- }
- }
+ public static IInvokeMethod Instance => _Instance;
protected MethodInfo FindMethod(object TargetObject, string MethodName, Type[] argTypes) {
if (TargetObject is Type) {
@@ -74,18 +69,18 @@ public static Linq.IInvokeMethod Instance
}
- public object Invoke(object TargetObject, string MethodName, object[] args) {
+ public object Invoke(object targetObject, string methodName, object[] args) {
Type[] argTypes = new Type[args.Length];
for (int i = 0; i < argTypes.Length; i++)
argTypes[i] = args[i] != null ? args[i].GetType() : typeof(object);
// strict matching first
- MethodInfo targetMethodInfo = FindMethod(TargetObject, MethodName, argTypes);
+ MethodInfo targetMethodInfo = FindMethod(targetObject, methodName, argTypes);
// fuzzy matching
if (targetMethodInfo==null) {
- var methods = GetAllMethods(TargetObject);
+ var methods = GetAllMethods(targetObject);
foreach (var m in methods) {
- if (m.Name == MethodName) {
+ if (m.Name == methodName) {
var para = m.GetParameters();
var paracnt = para.Length;
var optcnt = OptionalParameterCount(para);
@@ -104,12 +99,12 @@ public static Linq.IInvokeMethod Instance
argTypeNames[i] = argTypes[i].Name;
string argTypeNamesStr = String.Join(",",argTypeNames);
throw new MissingMemberException(
- (TargetObject is Type ? (Type)TargetObject : TargetObject.GetType()).FullName+"."+MethodName);
+ (targetObject is Type ? (Type)targetObject : targetObject.GetType()).FullName+"."+methodName);
}
- object[] argValues = PrepareActualValues(MethodName,targetMethodInfo.GetParameters(),args);
+ object[] argValues = PrepareActualValues(methodName,targetMethodInfo.GetParameters(),args);
object res = null;
try {
- res = targetMethodInfo.Invoke( TargetObject is Type ? null : TargetObject, argValues);
+ res = targetMethodInfo.Invoke( targetObject is Type ? null : targetObject, argValues);
} catch (TargetInvocationException tiEx) {
if (tiEx.InnerException!=null)
throw new Exception(tiEx.InnerException.Message, tiEx.InnerException);
@@ -170,7 +165,7 @@ private bool CheckParamValueCompatibility(Type paramType, object val)
else {
if (!CheckParamValueCompatibility(paramType, values[i])) return false;
}
- }
+ }
else {
if (!paramsInfo[i].IsOptional) return false;
}