/// <summary> /// 构造函数 /// </summary> /// <param name="oldInvoker"></param> /// <param name="functionDescription"></param> /// <param name="inteType"></param> /// <param name="ignoreType"></param> public ExtOperationInvoker(IOperationInvoker oldInvoker, string functionDescription, EnumInterception inteType, EnumIgnoreInterception ignoreType) { var mInfo = (MethodInfo)oldInvoker.GetType().GetProperty("Method").GetValue(oldInvoker, null); m_OldInvoker = oldInvoker; m_InteType = inteType; m_FunctionName = mInfo.Name; m_FunctionDescription = functionDescription; m_IgnoreType = ignoreType; }
private TransResponse CreateResponse(out object[] outputParams) { List <object> outParams = new List <object>(); PropertyInfo prop = invoker.GetType().GetProperty("Method"); if (prop != null) { MethodInfo operationMethod = prop.GetValue(invoker) as MethodInfo; if (operationMethod != null) { ParameterInfo[] ps = operationMethod.GetParameters(); foreach (var pi in ps) { if (pi.IsOut) { var piType = pi.ParameterType.GetElementType(); if (piType.IsValueType) { if (piType == typeof(bool)) { outParams.Add(false); } else if (piType == typeof(DateTime)) { outParams.Add(DateTime.MinValue); } else { outParams.Add(0); } } else { outParams.Add(null); } } } Type trType = typeof(TransResponse <>); trType = trType.MakeGenericType(operationMethod.ReturnType.GenericTypeArguments); TransResponse response = Activator.CreateInstance(trType) as TransResponse; outputParams = outParams.ToArray(); return(response); } } outputParams = outParams.ToArray(); return(null); }
/// <summary> /// Retrieves the method name for the check. /// </summary> /// <returns></returns> private string GetInvokerMethod() { PropertyInfo pi = _invoker.GetType().GetProperty("MethodName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { var val = pi.GetValue(_invoker, null); return(val.ToString()); } return(string.Empty); }