コード例 #1
0
ファイル: InvokeBody.cs プロジェクト: wra222/testgit
 public static void ExecuteOne(InvokeBody ivkBdy)
 {
     try
     {
         if (ivkBdy._dependencyIvkbdy == null || (ivkBdy._dependencyIvkbdy != null && ivkBdy._dependencyIvkbdy.IsExpected))
         {
             if (ivkBdy._isAction)
             {
                 ivkBdy._action();
             }
             else
             {
                 ivkBdy._retVal = ivkBdy._method.Invoke(ivkBdy._repository, ivkBdy._args);
             }
         }
     }
     catch(Exception ex)
     {
         throw ex.InnerException;
     }
 }
コード例 #2
0
ファイル: InvokeBody.cs プロジェクト: wra222/testgit
        public static InvokeBody AddOneInvokeBody(object repository, IUnitOfWork uow, Action actionMethod)
        {
            if (actionMethod != null && 
                uow!=null)
            {
                InvokeBody ivkBdy = new InvokeBody(repository, actionMethod);
                uow.RegisterDeferMethods(ivkBdy);
                return ivkBdy;
            }

            return null;
        }
コード例 #3
0
ファイル: InvokeBody.cs プロジェクト: wra222/testgit
 public static InvokeBody AddOneInvokeGenericBody(object repository, IUnitOfWork uow, MethodBase method, Type[] genericTypes, params object[] args)
 {
     if (uow != null)
     {
         string methodName = method.Name;
         string postFix = "Defered";
         MethodInfo mi = null;
         MethodInfo genericMethod = repository.GetType().GetMethod(methodName.Substring(0, methodName.Length - postFix.Length));
         mi = genericMethod.MakeGenericMethod(genericTypes);
         InvokeBody ivkBdy = new InvokeBody(repository, mi, args);
         uow.RegisterDeferMethods(ivkBdy);
         return ivkBdy;
     }
     return null;
 }
コード例 #4
0
ファイル: InvokeBody.cs プロジェクト: wra222/testgit
        private static InvokeBody AddOneInvokeBody_Inner(object repository, IUnitOfWork uow, MethodBase method, int iBeginParam, params object[] args)
        {
            if (uow != null)
            {
                string methodName = method.Name;

                string postFix = "Defered";
                MethodInfo mi = null;
                ParameterInfo[] parameters = method.GetParameters();
                if (parameters != null && parameters.Length > 0)
                {
                    List<Type> paramTypes = new List<Type>();
                    for (int i = iBeginParam; i < parameters.Length; i++)
                    {
                        paramTypes.Add(parameters[i].ParameterType);
                    }
                    mi = repository.GetType().GetMethod(methodName.Substring(0, methodName.Length - postFix.Length), paramTypes.ToArray());
                }
                else
                {
                    mi = repository.GetType().GetMethod(methodName.Substring(0, methodName.Length - postFix.Length));
                }
                InvokeBody ivkBdy = new InvokeBody(repository, mi, args);
                uow.RegisterDeferMethods(ivkBdy);
                return ivkBdy;
            }
            return null;
        }
コード例 #5
0
ファイル: UnitOfWork.cs プロジェクト: wra222/testgit
 /// <summary>
 /// 注册延迟改库方法
 /// </summary>
 /// <param name="ivkBdy"></param>
 public void RegisterDeferMethods(InvokeBody ivkBdy)
 {
     if (ivkBdy != null && !_invokeBodies.Contains(ivkBdy))
     {
         logger.DebugFormat(MsgRegisterDeferMethods, ivkBdy.ToString());
         _invokeBodies.Add(ivkBdy);
         _execSeq.Add(ivkBdy);
     }
 }