Beispiel #1
0
        private static void LoadAssembly(Assembly assembly)
        {
            try
            {
                Type[] types = assembly.GetTypes();

                foreach (Type type in types)
                {
                    if (type.IsPublic && !type.IsAbstract)
                    {
                        try
                        {
                            if (type.IsSubclassOf(typeof(BaseScript)))
                            {
                                Log.Write(LogLevel.Info, "Loading script {0} v{1}", type.Name, FileVersionInfo.GetVersionInfo(type.Assembly.Location).ProductVersion);

                                BaseScript script = (BaseScript)Activator.CreateInstance(type);
                                ScriptProcessor.AddScript(script);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Write(LogLevel.Error, "An error occurred during initialization of the script {0}: {1}", type.Name, ex.ToString());
                        }
                    }
                }
            }
            catch (ReflectionTypeLoadException ex)
            {
                Log.Write(LogLevel.Warning, "Assembly {0} could not be loaded because of a loader exception: {1}", assembly.GetName(), ex.LoaderExceptions[0].ToString());
            }
        }
Beispiel #2
0
 private static void LoadAssembly(Assembly assembly)
 {
     try
     {
         foreach (Type type in assembly.GetTypes().OrderBy(type => type.Name))
         {
             if (type.IsPublic)
             {
                 if (!type.IsAbstract)
                 {
                     try
                     {
                         if (type.IsSubclassOf(typeof(BaseScript)))
                         {
                             Utilities.PrintToConsole($"[InfinityScript] Loading script {type.Name} v{assembly.GetName().Version}");
                             ScriptProcessor.AddScript((BaseScript)Activator.CreateInstance(type));
                         }
                     }
                     catch (Exception ex)
                     {
                         Utilities.PrintToConsole($"[InfinityScript] An error occurred during initialization of the script {type.Name}: {ex.Message}");
                     }
                 }
             }
         }
     }
     catch (ReflectionTypeLoadException ex)
     {
         Utilities.PrintToConsole($"[InfinityScript] Assembly {assembly.GetName()} could not be loaded because of a loader exception: {ex.LoaderExceptions[0].Message}");
     }
 }
Beispiel #3
0
        private static void LoadScript(BaseScript script)
        {
            Log.Write(LogLevel.Info, "Loading script {0}", script.GetType().Name);

            ScriptProcessor.AddScript(script);
        }