示例#1
0
 internal void TerminateAspects(Func <bool> onError)
 {
     using (_monitor.OpenInfo("Terminating Aspects."))
     {
         for (int i = _runContext.Aspects.Count - 1; i >= 0; --i)
         {
             IStObjEngineAspect a = _runContext.Aspects[i];
             using (_monitor.OpenInfo($"Aspect: {a.GetType().FullName}."))
             {
                 try
                 {
                     if (!a.Terminate(_monitor, this))
                     {
                         onError();
                     }
                 }
                 catch (Exception ex)
                 {
                     _monitor.Error(ex);
                     onError();
                 }
             }
         }
         _trampoline.Execute(_monitor, onError);
     }
 }
 internal void RunAspects(Func <bool> onError, bool postCode)
 {
     using (_monitor.OpenInfo($"Running Aspects ({(postCode ? "Post" : "Pre" )} Code Generation)."))
     {
         foreach (var a in _startContext.Aspects)
         {
             using (_monitor.OpenInfo($"Aspect: {a.GetType()}."))
             {
                 try
                 {
                     bool success = postCode ? a.RunPostCode(_monitor, this) : a.RunPreCode(_monitor, this);
                     if (!success)
                     {
                         onError();
                     }
                 }
                 catch (Exception ex)
                 {
                     _monitor.Error(ex);
                     onError();
                 }
             }
         }
         if (postCode)
         {
             _trampolinePostCode.Execute(_monitor, onError);
         }
         else
         {
             _trampoline.Execute(_monitor, onError);
         }
     }
 }