Beispiel #1
0
 //This class is responsible for loading all of the plugins and compiling them to a application usable standard!!!
 public void LoadPlugins()
 {
     //Find the directory and if it doesnt exist create it!
     if (pluginDirectory == null || pluginDirectory == "")
     {
         if (Program.DebugMode)
         {
             Console.WriteLine("Plugin directory doesnt exist creating...");
         }
         pluginDirectory = Path.Combine(Directory.GetCurrentDirectory(), "/plugins");
         LoadPlugins();
     }
     else
     {
         //Successfully found a folder
         if (Directory.Exists(pluginDirectory))
         {
             //The Directory exists!
             if (Program.DebugMode)
             {
                 Console.WriteLine("Found plugin directory!!!");
             }
             //Check if the sample exists and if not dont create it if its been deleted
             string metaBoolean = Program.metaFile.getString("awarePluginSampleExists");
             if (metaBoolean == "")
             {
                 //It doesnt exist create it.
                 if (Program.DebugMode)
                 {
                     Console.WriteLine("The Sample program doesnt exist so creating...");
                 }
                 string sampleDirectory = Path.Combine(pluginDirectory, "Sample");
                 if (!Directory.Exists(sampleDirectory))
                 {
                     //Create it
                     Directory.CreateDirectory(sampleDirectory);
                 }
                 //I know i shouldnt but...
                 string sampleMeta = Path.Combine(sampleDirectory, "plugin.meta");
                 if (!File.Exists(sampleMeta))
                 {
                     PluginFileMeta metaFileSample = new PluginFileMeta();
                     metaFileSample.version  = Program.programVersion;
                     metaFileSample.fileName = "Sample";
                     metaFileSample.filePath = sampleDirectory;
                     PluginFileMeta.SaveFile(sampleMeta, metaFileSample);
                 }
                 Program.metaFile.writeString("awarePluginSampleExists", "TRUE", true);
                 if (Program.DebugMode)
                 {
                     Console.WriteLine("Finished creating sample program.. and blocked it off!");
                 }
             }
             if (Directory.GetFiles(pluginDirectory).Length <= 0)
             {
                 return;
             }
             foreach (string m in Directory.EnumerateFiles(pluginDirectory))
             {
                 LoadPlugin(m);
             }
         }
         else
         {
             if (Program.DebugMode)
             {
                 Console.WriteLine("The plugin directory doesnt exist so try again!!!");
             }
             Directory.CreateDirectory(pluginDirectory);
             LoadPlugins();
         }
     }
 }