public static bool Compile(bool debug, bool cache) { List <Assembly> assemblies = new List <Assembly>(); assemblies.Add(Assembly.LoadFrom("Scripts.dll")); assemblies.Add(typeof(ScriptCompiler).Assembly); Assemblies = assemblies.ToArray(); Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Scripts: Verifying..."); Utility.PopColor(); Stopwatch watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Utility.PushColor(ConsoleColor.Green); Console.WriteLine( "Finished ({0} items, {1} mobiles, {2} customs) ({3:F2} seconds)", Core.ScriptItems, Core.ScriptMobiles, Core.ScriptCustoms, watch.Elapsed.TotalSeconds); Utility.PopColor(); return(true); }
public static bool Compile(bool debug, bool cache) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } List <Assembly> assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (Core.VBdotNet) { if (CompileVBScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } } else { Console.WriteLine("Scripts: Skipping VB.NET Scripts...done (use -vb to enable)"); } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles); return(true); }
public static bool Compile(bool debug, bool cache) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } var assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (assemblies.Count == 0) { return(false); } Assemblies = assemblies.ToArray(); Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Scripts: Verifying..."); Utility.PopColor(); var watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Utility.PushColor(ConsoleColor.Green); Console.WriteLine( "Finished ({0} items, {1} mobiles) ({2:F2} seconds)",/*, {2} customs*/ Core.ScriptItems, Core.ScriptMobiles, /*Core.ScriptCustoms,*/ watch.Elapsed.TotalSeconds); Utility.PopColor(); return(true); }
public static void VerifySerialization() { int num1; Core.m_ItemCount = 0; Core.m_MobileCount = 0; Core.VerifySerialization(Assembly.GetCallingAssembly()); for (num1 = 0; (num1 < ScriptCompiler.Assemblies.Length); ++num1) { Core.VerifySerialization(ScriptCompiler.Assemblies[num1]); } }
public static bool Compile(bool debug, bool cache) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } List <Assembly> assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); Console.Write("Scripts: Verifying..."); Stopwatch watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Console.WriteLine("done ({0} items, {1} mobiles) ({2:F2} seconds)", Core.ScriptItems, Core.ScriptMobiles, watch.Elapsed.TotalSeconds); return(true); }
public static bool Compile(bool debug) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } List <Assembly> assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (CompileVBScripts(debug, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles); List <MethodInfo> invoke = new List <MethodInfo>(); for (int a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Configure", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { invoke[i].Invoke(null, null); } invoke.Clear(); Region.Load(); World.Load(); for (int a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { invoke[i].Invoke(null, null); } return(true); }
public static bool Compile(bool debug, bool cache) { EnsureDirectory("Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } var assemblies = new List <Assembly>(); Assembly assembly; if (CompileConfigurationScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("[Failed]"); Utility.PopColor(); return(false); } if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (Core.VBdotNet) { if (CompileVBScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } } else { /* * Utility.PushColor(ConsoleColor.DarkRed); * Console.WriteLine("Scripts: Skipping VB.NET Scripts...done (use -vb to enable)"); * Utility.PopColor(); */ } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); /* * Utility.PushColor(ConsoleColor.Yellow); * Console.WriteLine("Scripts: Verifying..."); * Utility.PopColor(); */ Stopwatch watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Utility.PushColor(ConsoleColor.Green); // Utility.PushColor(ConsoleColor.Green); // Console.Write("[Success]"); // 0 errors, 0 warnings"); // string text = "..................."; string text2 = string.Format("({0} items, {1} mobiles, {2} custom)", Core.ScriptItems, Core.ScriptMobiles, Core.ScriptCustoms); int num = text2.Length - 30; if (num < 0) { num = 0; } num = 18 - num; Utility.PushColor(ConsoleColor.Cyan); Console.SetCursorPosition(24, Console.CursorTop); Console.Write(text2); Console.SetCursorPosition(70, Console.CursorTop); Utility.PushColor(ConsoleColor.Green); Console.WriteLine("[Success]"); Utility.PopColor(); // foreach () // Console.Write(""); Utility.PopColor(); /* * Console.WriteLine( * "Finished ({0} items, {1} mobiles, {3} customs) ({2:F2} seconds)", * Core.ScriptItems, * Core.ScriptMobiles, * watch.Elapsed.TotalSeconds, * Core.ScriptCustoms); */ Utility.PopColor(); return(true); }
public static bool Compile(bool debug, bool cache, bool publish) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } List <Assembly> assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { if (publish) { string path = assembly.Location; string hashpath = path.Substring(0, path.Length - 3) + "hash"; string pdbpath = path.Substring(0, path.Length - 3) + "pdb"; if (File.Exists(@"Scripts\Output\NextPublish.Scripts.CS.dll")) { File.Delete(@"Scripts\Output\NextPublish.Scripts.CS.dll"); } if (File.Exists(@"Scripts\Output\NextPublish.Scripts.CS.hash")) { File.Delete(@"Scripts\Output\NextPublish.Scripts.CS.hash"); } if (Core.Debug && File.Exists(@"Scripts\Output\NextPublish.Scripts.CS.pdb")) { File.Delete(@"Scripts\Output\NextPublish.Scripts.CS.pdb"); } File.Move(path, @"Scripts\Output\NextPublish.Scripts.CS.dll"); File.Move(hashpath, @"Scripts\Output\NextPublish.Scripts.CS.hash"); if (Core.Debug) { File.Move(path.Substring(0, path.Length - 3) + "pdb", @"Scripts\Output\NextPublish.Scripts.CS.pdb"); } Core.Kill(); } assemblies.Add(assembly); } } else { return(false); } if (Core.VBdotNet) { if (CompileVBScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } } else { Console.WriteLine("Scripts: Skipping VB.NET Scripts...done (use -vb to enable)"); } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); Console.Write("Scripts: Verifying..."); Stopwatch watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Console.WriteLine("done ({0} items, {1} mobiles) ({2:F2} seconds)", Core.ScriptItems, Core.ScriptMobiles, watch.Elapsed.TotalSeconds); return(true); }
public static bool Compile(bool debug, bool cache) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } List <Assembly> assemblies = new List <Assembly>(); Assembly assembly; if (CompileCSScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } if (Core.VBdotNet) { if (CompileVBScripts(debug, cache, out assembly)) { if (assembly != null) { assemblies.Add(assembly); } } else { return(false); } } else { Utility.PushColor(ConsoleColor.DarkRed); Console.WriteLine("Scripts: Skipping VB.NET Scripts...done (use -vb to enable)"); Utility.PopColor(); } if (assemblies.Count == 0) { return(false); } m_Assemblies = assemblies.ToArray(); Utility.PushColor(ConsoleColor.Yellow); Console.Write("Scripts: Verifying..."); Utility.PopColor(); Stopwatch watch = Stopwatch.StartNew(); Core.VerifySerialization(); watch.Stop(); Utility.PushColor(ConsoleColor.Green); Console.WriteLine( "done ({0} items, {1} mobiles) ({2:F2} seconds)", Core.ScriptItems, Core.ScriptMobiles, watch.Elapsed.TotalSeconds); Utility.PopColor(); return(true); }
public static bool Compile(bool debug) { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); //m_Assemblies = new Assembly[] // { Assembly.LoadFile( Path.Combine( Core.BaseDirectory, "Scripts/Output/Scripts.CS.dll" ) ) }; DeleteFiles("Scripts.CS*.dll"); DeleteFiles("Scripts.VB*.dll"); DeleteFiles("Scripts*.dll"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } CompilerResults csResults = null, vbResults = null; csResults = CompileCSScripts(debug); if (csResults == null || !csResults.Errors.HasErrors) { vbResults = CompileVBScripts(debug); } if ((csResults == null || !csResults.Errors.HasErrors) && (vbResults == null || !vbResults.Errors.HasErrors) && (vbResults != null || csResults != null)) { int a = 0; if (csResults == null || vbResults == null) { m_Assemblies = new Assembly[1]; } else { m_Assemblies = new Assembly[2]; } if (csResults != null) { m_Assemblies[a++] = csResults.CompiledAssembly; } if (vbResults != null) { m_Assemblies[a++] = vbResults.CompiledAssembly; } Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles); ArrayList invoke = new ArrayList(); for (a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Configure", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } //m.Invoke( null, null ); } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { ((MethodInfo)invoke[i]).Invoke(null, null); } invoke.Clear(); World.Load(); for (a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } //m.Invoke( null, null ); } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { ((MethodInfo)invoke[i]).Invoke(null, null); } return(true); } else { return(false); } }
public static bool Compile(bool debug) { /* Pix: Here I'm letting release builds always compile the scripts as per the 'default' way * RunUO works. In debug mode, I check for the existence of a pre-compiled 'Scripts.dll', and * if that exists, then load that, else compile normal scripts. */ #if !DEBUG return(CompileRawScripts(debug)); #else string path = Path.Combine(Core.BaseDirectory, "Scripts.dll"); if (!File.Exists(path)) { Console.WriteLine("Pre-Compiled Scripts.dll not found."); return(CompileRawScripts(debug)); } Assembly scripts = null; try { scripts = Assembly.LoadFile(path); } catch (Exception err) { Console.WriteLine("Impossible to load Scripts.dll. Error: {0}", err.ToString()); return(false); } m_Assemblies = new Assembly[] { scripts }; Console.WriteLine("Scripts.dll loaded"); Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles, and {2} Serializable objects)", Core.ScriptItems, Core.ScriptMobiles, Core.ScriptSerializableObjects); ArrayList invoke = new ArrayList(); Type[] types = scripts.GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Configure", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { ((MethodInfo)invoke[i]).Invoke(null, null); } invoke.Clear(); World.Load(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { ((MethodInfo)invoke[i]).Invoke(null, null); } return(true); #endif }
public static bool LoadPrecompiledAssembly() { EnsureDirectory("Scripts/"); EnsureDirectory("Scripts/Output/"); if (m_AdditionalReferences.Count > 0) { m_AdditionalReferences.Clear(); } Assembly assembly = Assembly.LoadFrom("Scripts/Output/Scripts.CS.dll"); if (assembly == null) { return(false); } m_Assemblies = new List <Assembly> { assembly }.ToArray(); Console.WriteLine("Scripts: Loaded without compiling..."); Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles); List <MethodInfo> invoke = new List <MethodInfo>(); for (int a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Configure", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { invoke[i].Invoke(null, null); } invoke.Clear(); Region.Load(); World.Load(); for (int a = 0; a < m_Assemblies.Length; ++a) { Type[] types = m_Assemblies[a].GetTypes(); for (int i = 0; i < types.Length; ++i) { MethodInfo m = types[i].GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public); if (m != null) { invoke.Add(m); } } } invoke.Sort(new CallPriorityComparer()); for (int i = 0; i < invoke.Count; ++i) { invoke[i].Invoke(null, null); } return(true); }
public static bool Compile(bool debug) { int num1; ArrayList list1; Type[] typeArray1; int num2; MethodInfo info1; int num3; Type[] typeArray2; int num4; MethodInfo info2; int num5; ScriptCompiler.EnsureDirectory("Scripts/"); ScriptCompiler.EnsureDirectory("Scripts/Output/"); ScriptCompiler.DeleteFiles("Scripts.CS*.dll"); ScriptCompiler.DeleteFiles("Scripts.VB*.dll"); ScriptCompiler.DeleteFiles("Scripts*.dll"); if (ScriptCompiler.m_AdditionalReferences.Count > 0) { ScriptCompiler.m_AdditionalReferences.Clear(); } CompilerResults results1 = null; CompilerResults results2 = null; results1 = ScriptCompiler.CompileCSScripts(debug); if ((results1 == null) || !results1.Errors.HasErrors) { results2 = ScriptCompiler.CompileVBScripts(debug); } if ((((results1 == null) || !results1.Errors.HasErrors) && ((results2 == null) || !results2.Errors.HasErrors)) && ((results2 != null) || (results1 != null))) { num1 = 0; if ((results1 == null) || (results2 == null)) { ScriptCompiler.m_Assemblies = new Assembly[1]; } else { ScriptCompiler.m_Assemblies = new Assembly[2]; } if (results1 != null) { ScriptCompiler.m_Assemblies[num1++] = results1.CompiledAssembly; } if (results2 != null) { ScriptCompiler.m_Assemblies[num1++] = results2.CompiledAssembly; } Console.Write("Scripts: Verifying..."); Core.VerifySerialization(); Console.WriteLine("done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles); list1 = new ArrayList(); num1 = 0; while ((num1 < ScriptCompiler.m_Assemblies.Length)) { typeArray1 = ScriptCompiler.m_Assemblies[num1].GetTypes(); for (num2 = 0; (num2 < typeArray1.Length); ++num2) { info1 = typeArray1[num2].GetMethod("Configure", (BindingFlags.Public | BindingFlags.Static)); if (info1 != null) { list1.Add(info1); } } ++num1; } list1.Sort(new CallPriorityComparer()); for (num3 = 0; (num3 < list1.Count); ++num3) { ((MethodInfo)list1[num3]).Invoke(null, null); } list1.Clear(); World.Load(); for (num1 = 0; (num1 < ScriptCompiler.m_Assemblies.Length); ++num1) { typeArray2 = ScriptCompiler.m_Assemblies[num1].GetTypes(); for (num4 = 0; (num4 < typeArray2.Length); ++num4) { info2 = typeArray2[num4].GetMethod("Initialize", (BindingFlags.Public | BindingFlags.Static)); if (info2 != null) { list1.Add(info2); } } } list1.Sort(new CallPriorityComparer()); for (num5 = 0; (num5 < list1.Count); ++num5) { ((MethodInfo)list1[num5]).Invoke(null, null); } return(true); } return(false); }