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

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

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

--- trunk/RomCheater.PluginFramework/Core/PluginCollectionTypes.cs	2013/06/18 10:25:55	713
+++ trunk/RomCheater.PluginFramework/Core/PluginCollectionTypes.cs	2013/06/18 10:51:47	715
@@ -426,11 +426,44 @@
             #endregion
         }
         #endregion
+        #region UnkownPlugin Support
+        internal static class UnknownPlugins
+        {
+            private const PluginType PluginType = Core.PluginType.Unknown;
+            #region UnknownPlugin
+            internal class UnknownPlugin
+            {
+                private const PluginNames PluginName = Core.PluginNames.Unknown;
+                private static List<IBasePluginDefinition> bpds = new List<IBasePluginDefinition>();
+                static UnknownPlugin()
+                {
+                    bpds = new List<IBasePluginDefinition>();
+                    PluginLoader loader = new PluginLoader();
+                    loader.LoadPlugins(true);
+                    var config_plugins = loader.LoadedConfigPlugins;
+                    var input_plugins = loader.LoadedInputPlugins;
+                    var window_plugins = loader.LoadedWindowPlugins;
+                    var user_plugins = loader.LoadedUserControlPlugins;
 
+                    config_plugins.ForEach(s => bpds.Add(new BasePluginDefinition(s.Name, s.Description, s.ID)));
+                    input_plugins.ForEach(s => bpds.Add(new BasePluginDefinition(s.Name, s.Description, s.ID)));
+                    window_plugins.ForEach(s => bpds.Add(new BasePluginDefinition(s.Name, s.Description, s.ID)));
+                    user_plugins.ForEach(s => bpds.Add(new BasePluginDefinition(s.Name, s.Description, s.ID)));
+
+                }
+                public static List<IBasePluginDefinition> Plugin { get { return (bpds as List<IBasePluginDefinition>); } }
+            }
+            #endregion
+        }
+        #endregion
 
         #region Name/Guid Collection
         public static IBasePluginDefinition GetPluginByName(PluginNames plugin_name)
         {
+            return GetPluginsByName(plugin_name).FirstOrDefault();
+        }
+        public static List<IBasePluginDefinition> GetPluginsByName(PluginNames plugin_name)
+        {
             Type t = typeof(PluginCollection);
             List<Type> types = new List<Type>(t.GetNestedTypes(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public));
 
@@ -469,7 +502,14 @@
                     bpd = (prop_value as IBasePluginDefinition);
                     if (bpd != null)
                     {
-                        return bpd;
+                        return new List<IBasePluginDefinition>() { bpd };
+                    }
+                    else
+                    {
+                        List<IBasePluginDefinition> bpds = new List<IBasePluginDefinition>();
+                        bpds = (prop_value as List<IBasePluginDefinition>);
+                        bpds.TrimExcess();
+                        return bpds;
                     }
                 }
             }
@@ -499,10 +539,17 @@
                 {
                     var sub_field = sub_type.GetField("PluginName", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                     PluginNames o = (PluginNames)sub_field.GetValue(null);
-                    var bpd = GetPluginByName(o);
-                    if (bpd != null)
+                    var bpds = GetPluginsByName(o);
+                    if (bpds != null)
                     {
-                        plugins.Add(bpd);
+                        if (bpds.Count == 0)
+                        {
+                            throw new ArgumentOutOfRangeException(string.Format("Found pluginby name: '{0}' but no plugin data was returned", o.ToString()));
+                        }
+                        foreach (var bpd in bpds)
+                        {
+                            plugins.Add(bpd);
+                        }
                     }
                     else
                     {

 

  ViewVC Help
Powered by ViewVC 1.1.22