Esempio n. 1
0
 private void method_3()
 {
     foreach (string path in this.SourceFilePaths)
     {
         string[] array = File.ReadAllLines(path);
         for (int i = 0; i < array.Length; i++)
         {
             string text = array[i].Trim();
             if (text.StartsWith("//!CompilerOption|"))
             {
                 string[] array2 = text.Split(new char[]
                 {
                     '|'
                 }, StringSplitOptions.RemoveEmptyEntries);
                 string a = array2[1];
                 if (!(a == "AddRef"))
                 {
                     if (!(a == "Optimize"))
                     {
                         if (a == "Define" && array2.Length == 3 && !string.IsNullOrEmpty(array2[2]))
                         {
                             CompilerParameters options = this.Options;
                             options.CompilerOptions = options.CompilerOptions + " /d:" + array2[2] + ";";
                         }
                     }
                     else if (array2.Length == 3 && !string.IsNullOrEmpty(array2[2]) && array2[2] == "On" && !this.Options.CompilerOptions.Contains("/optimize;"))
                     {
                         this.Options.IncludeDebugInformation = false;
                         CompilerParameters options2 = this.Options;
                         options2.CompilerOptions += " /optimize";
                     }
                 }
                 else if (array2.Length == 3 && !string.IsNullOrEmpty(array2[2]) && array2[2].EndsWith(".dll") && !CodeCompiler.smethod_2(array2[2]) && !array2[2].ToLowerInvariant().Contains("hearthbuddy.exe"))
                 {
                     this.AddReference(array2[2]);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public void Reload(string reason)
 {
     //this.ilog_0.Debug(string.Format("Reloading AssemblyLoader<{0}> - {1}", typeof(T), reason));
     Instances = new List <T>();
     if (!Directory.Exists(string_0))
     {
         //this.ilog_0.Error(string.Format("Could not Reload assemblies because the path \"{0}\" does not exist.", this.string_0));
         return;
     }
     //this.ilog_0.Info("Reload cs files from " + this.string_0);
     foreach (string path in Directory.GetDirectories(string_0))
     {
         try
         {
             CodeCompiler    codeCompiler    = new CodeCompiler(path);
             CompilerResults compilerResults = codeCompiler.Compile();
             if (compilerResults != null)
             {
                 if (compilerResults.Errors.HasErrors)
                 {
                     foreach (object arg in compilerResults.Errors)
                     {
                         //this.ilog_0.Error(string.Format("Compiler Error: {0}", arg));
                         Console.WriteLine($"Compiler Error: {arg}");
                     }
                 }
                 Instances.AddRange(new TypeLoader <T>(codeCompiler.CompiledAssembly));
             }
         }
         catch (Exception ex)
         {
             if (ex is ReflectionTypeLoadException)
             {
                 foreach (Exception exception in (ex as ReflectionTypeLoadException).LoaderExceptions)
                 {
                     //this.ilog_0.Error("[Reload] An exception occurred.", exception);
                     Console.WriteLine($"Compiler Error: {exception}");
                 }
             }
             else
             {
                 //this.ilog_0.Error("[Reload] An exception occurred.", ex);
                 Console.WriteLine($"Compiler Error: {ex}");
             }
         }
     }
     using (List <T> .Enumerator enumerator2 = new TypeLoader <T>().GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             Class229 @class = new Class229();
             @class.gparam_0 = enumerator2.Current;
             if (!Instances.Any(@class.method_0))
             {
                 Instances.Add(@class.gparam_0);
             }
         }
     }
     if (eventHandler_0 != null)
     {
         eventHandler_0(this, null);
     }
 }