/[RomCheater]/trunk/RomCheater.PluginFramework/Core/PluginLoader.cs
ViewVC logotype

Diff of /trunk/RomCheater.PluginFramework/Core/PluginLoader.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.PluginFramework/Core/PluginLoader.cs	2012/05/27 23:33:54	148
+++ trunk/RomCheater.PluginFramework/Core/PluginLoader.cs	2012/06/22 08:21:18	414
@@ -1,4 +1,17 @@
-´╗┐using System;
+´╗┐#region Logging Defines
+// include this any class or method that required logging, and comment-out what is not needed
+#define LOGGING_ENABLED
+#region Enabled logging levels
+#define LOGGING_ENABLE_INFO
+#define LOGGING_ENABLE_WARN
+#define LOGGING_ENABLE_DEBUG
+#define LOGGING_ENABLE_VERBOSEDEBUG
+#define LOGGING_ENABLE_ERROR
+#define LOGGING_ENABLE_VERBOSEERROR
+#define LOGGING_ENABLE_PROFILER
+#endregion
+#endregion
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -18,31 +31,38 @@
             LoadedWindowPlugins = new List<IWindowPlugin>();
         }
         #region IPluginLoader Members
-
-        public void LoadPlugins()
+        public void LoadPlugins() { LoadPlugins(false); }
+        public void LoadPlugins(bool silent)
         {
             try
             {
-                logger.Info.WriteLine("Loading Plugins...");
+                if (!silent)
+                    logger.Info.WriteLine("Loading Plugins...");
 
                 string PluginPath = string.Format(@"{0}\Plugins", typeof(PluginLoader).Assembly.Location.Replace(@"\RomCheater.PluginFramework.dll", ""));
-                logger.Debug.WriteLine("Plugins Path: {0}", PluginPath);
+                if (!silent)
+                    logger.Debug.WriteLine("Plugins Path: {0}", PluginPath);
                 List<string> dlls = new List<string>(Directory.GetFiles(PluginPath, "*.dll"));
-                logger.Debug.WriteLine("  Found: {0} plugin dlls", dlls.Count);
+                if (!silent)
+                    logger.Debug.WriteLine("  Found: {0} plugin dlls", dlls.Count);
                 foreach (string dll in dlls)
                 {
                     FileInfo fi = new FileInfo(dll);
-                    logger.Debug.WriteLine("    plugin[{0}]: {1}", dlls.IndexOf(dll), fi.Name);
+                    if (!silent)
+                        logger.Debug.WriteLine("    plugin[{0}]: {1}", dlls.IndexOf(dll), fi.Name);
                     GetConfigPluginsFromDll(fi);
                     GetInputPluginsFromDll(fi);
                     GetWindowPluginsFromDll(fi);
                 }
 
-                logger.Info.WriteLine("  Loaded {0} config plugins", LoadedConfigPlugins.Count);
-                logger.Info.WriteLine("  Loaded {0} input plugins", LoadedInputPlugins.Count);
-                logger.Info.WriteLine("  Loaded {0} window plugins", LoadedWindowPlugins.Count);
-
-                logger.Info.WriteLine("Plugins Loaded.");
+                if (!silent)
+                    logger.Info.WriteLine("  Loaded {0} config plugins", LoadedConfigPlugins.Count);
+                if (!silent)
+                    logger.Info.WriteLine("  Loaded {0} input plugins", LoadedInputPlugins.Count);
+                if (!silent)
+                    logger.Info.WriteLine("  Loaded {0} window plugins", LoadedWindowPlugins.Count);
+                if (!silent)
+                    logger.Info.WriteLine("Plugins Loaded.");
             }
             catch (ReflectionTypeLoadException ex)
             {
@@ -54,11 +74,13 @@
                         builder.AppendLine(c.ToString());
                     }
                 }
-                logger.Error.WriteLine("Failed to load one or more plugins{0}Possible Reason:{0}{1}", System.Environment.NewLine, builder.ToString());
+                if (!silent)
+                    logger.Error.WriteLine("Failed to load one or more plugins{0}Possible Reason:{0}{1}", System.Environment.NewLine, builder.ToString());
             }
             catch (Exception ex)
             {
-                logger.Error.WriteLine("Failed to load one or more plugins{0}Possible Reason:{0}{1}", System.Environment.NewLine, ex.ToString());
+                if (!silent)
+                    logger.Error.WriteLine("Failed to load one or more plugins{0}Possible Reason:{0}{1}", System.Environment.NewLine, ex.ToString());
             }
         }
         public List<IConfigPlugin> LoadedConfigPlugins { get; private set; }
@@ -107,7 +129,7 @@
                 if (type.BaseType == typeof(ConfigPlugin))
                 {
                     ConstructorInfo ci = null;
-                    ci = type.GetConstructor(new Type[] {});
+                    ci = type.GetConstructor(new Type[] { });
                     if (ci == null)
                     {
                         throw new NullReferenceException(string.Format("Unable to bind to constructor for type: {0}", type.Name));

 

  ViewVC Help
Powered by ViewVC 1.1.22