Exemplo n.º 1
0
 public bool TrySetNewAssembly(params string[] code)
 {
     try
     {
         if (playerAppDomain != null)
         {
             AppDomain.Unload(playerAppDomain);
             playerAppDomain = null;
             GC.Collect();
         }
         var parsed   = CodeCompiler.Parse(PlayerData.PlayerId, code.Select(CodeHelper.GetCodeWithDLL));
         var compiled = CodeCompiler.Compile(parsed);
         if (!compiled)
         {
             return(false);
         }
         var appDomain = CodeRunner.GetExecutor(PlayerData.PlayerId);
         if (appDomain != null)
         {
             playerCode      = code;
             playerAppDomain = appDomain;
         }
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception while compiling:");
         Console.WriteLine(e.ToString());
     }
     return(false);
 }