/// <summary> /// 将上下文应用到特性 /// </summary> /// <param name="inputAttribute"></param> /// <param name="inputContext"></param> /// <param name="useBeforeTag"></param> public static void UseAttribute(List <VoidDoAttribute> inputAttribute, MethodCallContext inputContext, int useBeforeTag) { if (null == inputAttribute || null == inputContext) { return; } if (1 == useBeforeTag) { foreach (var oneAttribute in inputAttribute) { if (null == oneAttribute) { continue; } oneAttribute.DoBeforeMethod(inputContext); } } else { for (int tempIndx = inputAttribute.Count - 1; tempIndx >= 0; tempIndx--) { if (null == inputAttribute[tempIndx]) { continue; } inputAttribute[tempIndx].DoAfterMethod(inputContext); } } }
/// <summary> /// 获得使用特性 /// </summary> /// <param name="inputContext"></param> /// <returns></returns> public static List <VoidDoAttribute> GetUseAttribute(MethodCallContext inputContext) { List <VoidDoAttribute> returnValue = new List <VoidDoAttribute>(); try { GetVoidAttribute(inputContext.ThisMethod as MethodInfo, ref returnValue); } catch (Exception) { ; } return(returnValue); }
/// <summary> /// 执行后方法 /// </summary> /// <param name="inputContext"></param> public virtual void DoAfterMethod(MethodCallContext inputContext) { ; }
/// <summary> /// 执行前方法 /// </summary> /// <param name="inputContext"></param> public virtual void DoBeforeMethod(MethodCallContext inputContext) { ; }