internal void HandleClientToGamePhaseTransition(ILeagueSession session, LeagueSessionPhaseChangedArgs e)
        {
            logger.Info("Handling Client to Game Phase Transition!");

             var modifications = modificationLoader.EnumerateModifications();
             int compilationsRemaining = modifications.Count;
             foreach (var modification in modifications) {
            var resolutionChain = resolutionChainsByModificationName.GetOrAdd(
               modification.RepositoryName,
               add => new CompletionChain(cancellationToken => leagueBuildUtilities.ResolveModification(modification, cancellationToken))
            );
            var compilationChain = compilationChainsByModificationName.GetOrAdd(
               modification.RepositoryName,
               add => new CompletionChain(cancellationToken => leagueBuildUtilities.CompileModification(modification, cancellationToken))
            );
            var resolutionLink = resolutionChain.CreateLink("resolution_" + DateTime.Now.ToFileTimeUtc());
            var compilationLink = compilationChain.CreateLink("compilation_" + DateTime.Now.ToFileTimeUtc());
            resolutionLink.Tail(compilationLink.StartAndWaitForChain);
            compilationLink.Tail(() => {
               logger.Info("Compilation counter at " + compilationsRemaining);
               if (Interlocked.Decrement(ref compilationsRemaining) == 0) {
                  var gameModifications = leagueBuildUtilities.LinkGameModifications(modifications);
                  trinketSpawner.SpawnTrinket(
                     session.GetProcessOrNull(LeagueProcessType.GameClient),
                     leagueTrinketSpawnConfigurationFactory.GetGameConfiguration(gameModifications)
                  );
               }
            });
            resolutionChain.StartNext(resolutionLink);
             }
        }
        internal void HandleUninitializedToPreclientPhaseTransition(ILeagueSession session, LeagueSessionPhaseChangedArgs e)
        {
            logger.Info("Handling Uninitialized to Preclient Phase Transition!");
             var modifications = modificationLoader.EnumerateModifications();
             foreach (var modification in modifications) {
            var resolutionChain = resolutionChainsByModificationName.GetOrAdd(
               modification.RepositoryName,
               add => new CompletionChain(cancellationToken => leagueBuildUtilities.ResolveModification(modification, cancellationToken))
            );
            var compilationChain = compilationChainsByModificationName.GetOrAdd(
               modification.RepositoryName,
               add => new CompletionChain(cancellationToken => leagueBuildUtilities.CompileModification(modification, cancellationToken))
            );

            var resolutionLink = resolutionChain.CreateLink("resolution_" + DateTime.Now.ToFileTimeUtc());
            var compilationLink = compilationChain.CreateLink("compilation_" + DateTime.Now.ToFileTimeUtc());
            resolutionLink.Tail(compilationLink.StartAndWaitForChain);
            resolutionChain.StartNext(resolutionLink);
             }
             radsService.Suspend();
        }
 private void HandlePhaseContextPhaseChanged(ILeagueSession session, LeagueSessionPhaseChangedArgs e)
 {
     OnPhaseChanged(this, e);
 }
 internal void HandleSessionPhaseChanged(ILeagueSession session, LeagueSessionPhaseChangedArgs e)
 {
     logger.Info("Phase Change from " + e.Previous + " to " + e.Current);
      PhaseChangeHandler handler;
      if (phaseChangeHandlers.TryGetValue(new PhaseChange(e.Previous, e.Current), out handler)) {
     handler(session, e);
      }
 }
 protected virtual void OnPhaseChanged(ILeagueSession session, LeagueSessionPhaseChangedArgs e)
 {
     LeagueSessionPhaseChangedHandler handler = PhaseChanged;
      if (handler != null) handler(session, e);
 }