Ejemplo n.º 1
1
        /// <summary>
        /// 在指定的路径中查找服务提供者
        /// </summary>
        /// <param name="loaderPath">文件夹列表</param>
        /// <returns>查找的结果</returns>
        public static PluginList GetPlugins(params string[] loaderPath)
        {
            PluginList list = new PluginList();
            Action<string> loader = s =>
            {
                PluginInfo[] slist = GetPluginsInAssembly(s);
                if (slist != null) list.AddRange(slist);
            };
            Action<string> folderLoader = s =>
            {
                if (!System.IO.Path.IsPathRooted(s))
                    s = System.IO.Path.Combine(
                        System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), s);

                string[] files = System.IO.Directory.GetFiles(s, "*.exe");
                Array.ForEach(files, loader);

                files = System.IO.Directory.GetFiles(s, "*.dll");
                Array.ForEach(files, loader);
            };

            folderLoader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
            Array.ForEach(loaderPath, folderLoader);

            return list;
        }
Ejemplo n.º 2
1
 public BroadcastModel(Configuration configuration,
     IEnumerable<IExternalYellowPages> externalYellowPagesList,
     PluginList plugins)
 {
     this.configuration = configuration;
     this.externalYellowPagesList = externalYellowPagesList;
     this.plugins = plugins;
     timer.Ticked += timer_Ticked;
 }
Ejemplo n.º 3
0
        public void DistributeEvent(String eventName, MyEventArgBase e)
        {
            if (Broadcast(eventName, e))
            {
                return;
            }

            // Not a broadcast; process event
            PluginList pluginList = new PluginList();

            lock (s_subscriberLock)
            {
                PluginList tmpList;
                if (m_Subscribers.TryGetValue(eventName, out tmpList))
                {
                    // Deep copy
                    pluginList.AddRange(tmpList);
                }
            }

            foreach (IMyPlugin plugin in pluginList)
            {
                if ((plugin.EventPriority <= e.CeilingPriority) || (plugin.EventPriority >= e.FloorPriority))
                {
                    // the source should not be involved.
                    if (!plugin.Equals(e.MyPlugin))
                    {
                        plugin.HandleEvent(eventName, e);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void Prefix(ref List <MyObjectBuilder_Checkpoint.ModItem> mods)
        {
            try
            {
                HashSet <ulong> currentMods = new HashSet <ulong>(mods.Select(x => x.PublishedFileId));
                List <MyObjectBuilder_Checkpoint.ModItem> newMods = new List <MyObjectBuilder_Checkpoint.ModItem>(mods);

                PluginList list = Main.Instance.List;
                foreach (string id in Main.Instance.Config.EnabledPlugins)
                {
                    PluginData data = list[id];
                    if (data is ModPlugin mod && !currentMods.Contains(mod.WorkshopId) && mod.Exists)
                    {
                        LogFile.WriteLine("Loading client mod definitions for " + mod.WorkshopId);
                        newMods.Add(mod.GetModItem());
                    }
                }

                mods = newMods;
            }
            catch (Exception e)
            {
                LogFile.WriteLine("An error occured while loading client mods: " + e);
                throw;
            }
        }
        /// <summary>
        /// Installs the plugin associated with the ID
        /// </summary>
        /// <param name="ID">The identifier.</param>
        /// <returns>Returns true if it is installed successfully, false otherwise</returns>
        public bool InstallPlugin(string ID)
        {
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            var User = HttpContext.Current.Chain(x => x.User).Chain(x => x.Identity).Chain(x => x.Name, "");

            Utilities.IO.Log.Get().LogMessage("Plugin {0} is being installed by {1}", MessageType.Debug, ID, User);
            var TempPlugin = PluginList.Get(ID);

            if (TempPlugin != null)
            {
                UninstallPlugin(ID);
            }
            foreach (IPackageRepository Repo in PackageRepositories)
            {
                var Package = Repo.FindPackage(ID);
                if (Package != null)
                {
                    new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/packages/" + Package.Id + "." + Package.Version.ToString() + "/lib").Create();
                    new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/packages/" + Package.Id + "." + Package.Version.ToString() + "/content").Create();
                    new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/packages/" + Package.Id + "." + Package.Version.ToString() + "/tools").Create();
                    var Manager = new PackageManager(Repo,
                                                     new DefaultPackagePathResolver(Repo.Source),
                                                     new PhysicalFileSystem(new DirectoryInfo(HttpContext.Current != null ?
                                                                                              HttpContext.Current.Server.MapPath("~/App_Data/packages") :
                                                                                              "./App_Data/packages").FullName));
                    Manager.InstallPackage(Package, false, true);
                    PluginList.Add(new Plugin(Package));
                    Package.DependencySets.ForEach(x => x.Dependencies.ForEach(y => InstallPlugin(y.Id)));
                    PluginList.Save();
                    break;
                }
            }
            Utilities.IO.Log.Get().LogMessage("Plugin {0} has been installed by {1}", MessageType.Debug, ID, User);
            return(true);
        }
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 public void Initialize()
 {
     Delete(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/plugins/Loaded/"));
     new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/plugins/Loaded").Create();
     PluginList = PluginList.Load();
     if (PluginList.Plugins == null)
     {
         PluginList.Plugins = new List <Plugin>();
     }
     foreach (Plugin TempPlugin in PluginList.Plugins)
     {
         TempPlugin.Initialize();
     }
     PluginsInstalled = AppDomain.CurrentDomain.GetAssemblies().Objects <IPlugin>();
     foreach (IPlugin TempPlugin in PluginsInstalled)
     {
         Bootstrapper.AddAssembly(TempPlugin.GetType().Assembly);
         foreach (IPackageRepository Repo in PackageRepositories)
         {
             var Package = Repo.FindPackage(TempPlugin.PluginData.PluginID);
             if (Package != null)
             {
                 var TempPluginData = PluginList.Get(Package.Id);
                 TempPluginData.OnlineVersion = Package.Version.ToString();
             }
         }
     }
     PluginList.Save();
 }
Ejemplo n.º 7
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Project.Dispose();
                    tasker.Dispose();
                    relations.Dispose();
                    computers.Dispose();
                    computerIPs.Dispose();
                    files.Dispose();
                    Ips.Dispose();
                    computerDomains.Dispose();
                    lstLimits.Dispose();
                    domains.Dispose();
                    plugins.Dispose();
                }

                Project         = null;
                tasker          = null;
                computerDomains = null;
                lstLimits       = null;
                domains         = null;
                relations       = null;
                computers       = null;
                files           = null;
                Ips             = null;
                plugins         = null;

                disposedValue = true;
            }
        }
Ejemplo n.º 8
0
 private void addMasterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var amfNewMaster = new AddMasterForm())
     {
         if (amfNewMaster.ShowDialog(this) == DialogResult.OK)
         {
             Plugin plugin = GetPluginFromNode(PluginTree.SelectedRecord);
             if (plugin == null)
             {
                 MainView.PostStatusWarning(Resources.NoPluginSelectedCannotContinue);
                 return;
             }
             try
             {
                 if (plugin.AddMaster(amfNewMaster.MasterName))
                 {
                     PluginList.FixMasters();
                     RebuildSelection();
                 }
             }
             catch (ApplicationException ex)
             {
                 MessageBox.Show(this, ex.Message, Resources.Missing_Record, MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns an Object that Lists the Availaible Plugins.
        /// </summary>
        /// <remarks>
        /// The <paramref name="pluginName"/> length must be less or equal to 39, because of a limitation of the appmanifest.
        /// </remarks>
        /// <exception cref="ArgumentException">
        /// the length of <paramref name="pluginName"/> is 40 or greater.
        /// </exception>
        /// <param name="pluginName">The Plugin name defined in the appmanifest.</param>
        /// <returns>The <see cref="AppPlugin.PluginList<,,,>"/></returns>
        public static async Task <PluginList <TIn, TOut, TProgress> > ListAsync(string pluginName)
        {
            var pluginList = new PluginList <TIn, TOut, TProgress>(pluginName);
            await pluginList.InitAsync();

            return(pluginList);
        }
        public void InstallPluginMultipleTimes()
        {
            var Manager = new Core.Plugins.PluginManager(new string[] { "http://localhost:8797/api/v2" }, Utilities.IoC.Manager.Bootstrapper);

            Manager.InstallPlugin("xunit");
            Manager.InstallPlugin("xunit");
            PluginList List = PluginList.Load();

            Assert.Equal(1, List.Plugins.Count);
            Plugin TempPlugin = PluginList.Load().Get("xunit");

            Assert.Equal(6, new DirectoryInfo("~/App_Data/plugins/xunit/").EnumerateFiles().Count());
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.xml").Exists);
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.runner.utility.dll").Exists);
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.runner.tdnet.dll").Exists);
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.runner.msbuild.dll").Exists);
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.dll.tdnet").Exists);
            Assert.True(new FileInfo("~/App_Data/plugins/xunit/xunit.dll").Exists);
            Assert.NotNull(TempPlugin);
            Assert.Equal("JamesNewkirk,BradWilson", TempPlugin.Author.Replace(" ", ""));
            Assert.Equal("xUnit.net is a developer testing framework, built to support Test Driven Development, with a design goal of extreme simplicity and alignment with framework features.", TempPlugin.Description);
            Assert.Equal(6, TempPlugin.Files.Count);
            Assert.Equal("xUnit.net", TempPlugin.Name);
            Assert.Equal("1.9.2", TempPlugin.OnlineVersion);
            Assert.Equal("xunit", TempPlugin.PluginID);
            Assert.Equal(0, TempPlugin.Priority);
            Assert.Equal(null, TempPlugin.Tags);
            Assert.Equal(null, TempPlugin.Type);
            Assert.Equal(false, TempPlugin.UpdateAvailable);
            Assert.Equal("1.9.2", TempPlugin.Version);
        }
Ejemplo n.º 11
0
        public static void Postfix(MyScriptManager __instance)
        {
            try
            {
                HashSet <ulong> currentMods;
                if (MySession.Static.Mods != null)
                {
                    currentMods = new HashSet <ulong>(MySession.Static.Mods.Select(x => x.PublishedFileId));
                }
                else
                {
                    currentMods = new HashSet <ulong>();
                }

                PluginList list = Main.Instance.List;
                foreach (string id in Main.Instance.Config.EnabledPlugins)
                {
                    PluginData data = list[id];
                    if (data is ModPlugin mod && !currentMods.Contains(mod.WorkshopId) && mod.Exists)
                    {
                        LogFile.WriteLine("Loading client mod scripts for " + mod.WorkshopId);
                        loadScripts(__instance, mod.ModLocation, mod.GetModContext());
                    }
                }
            }
            catch (Exception e)
            {
                LogFile.WriteLine("An error occured while loading client mods: " + e);
                throw;
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Refreshes the strings according to current Culture language.
 /// </summary>
 public void RefreshStrings()
 {
     PluginList_SelectionChanged(null, null);
     if (PluginList != null)
     {
         PluginList.RefreshView();
     }
 }
Ejemplo n.º 13
0
        public Parser Create(
            EnvironmentInit environmentInit = null,
            NewFile newFile                     = null,
            PluginInstall pluginInstall         = null,
            PluginUninstall pluginUninstall     = null,
            PluginList pluginList               = null,
            SetUsername setEnvironmentSetting   = null,
            TemplateInstall templateInstall     = null,
            TemplateUninstall templateUninstall = null)
        {
            // if environmentInit hasn't been provided (for testing) then assign the Command Handler
            environmentInit ??= EnvironmentInitHandler.ExecuteAsync;
            newFile ??= NewFileHandler.ExecuteAsync;
            pluginInstall ??= PluginInstallHandler.ExecuteAsync;
            pluginUninstall ??= PluginUninstallHandler.ExecuteAsync;
            pluginList ??= PluginListHandler.ExecuteAsync;
            setEnvironmentSetting ??= SetEnvironmentSettingHandler.ExecuteAsync;
            templateInstall ??= TemplatePackageInstallerHandler.ExecuteAsync;
            templateUninstall ??= TemplatePackageUninstallerHandler.ExecuteAsync;

            // Set up intrinsic commands that will always be available.
            RootCommand rootCommand = Root();

            rootCommand.AddCommand(Environment());
            rootCommand.AddCommand(NewFile());
            rootCommand.AddCommand(Plugins());
            rootCommand.AddCommand(Templates());

            var commandBuilder = new CommandLineBuilder(rootCommand);

            try
            {
                foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths))
                {
                    commandBuilder.AddCommand(command);
                }
            }
            catch (DirectoryNotFoundException)
            {
                // If this is the first run, initialize the environment and default plugins
                Console.WriteLine("Error Detected: vellum environment uninitialized.");
                Parser parser = commandBuilder.UseDefaults().Build();

                int result = parser.Invoke("environment init");

                if (result == ReturnCodes.Ok)
                {
                    // Now the environment has been re-initialized, try to discover the plugins again.
                    foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths))
                    {
                        commandBuilder.AddCommand(command);
                    }
                }
            }

            return(commandBuilder.UseDefaults().Build());
        public void UninstallPlugin()
        {
            var Manager = new Core.Plugins.PluginManager(new string[] { "http://localhost:8797/api/v2" }, Utilities.IoC.Manager.Bootstrapper);

            Manager.InstallPlugin("xunit");
            Manager.UninstallPlugin("xunit");
            Assert.Equal(0, new DirectoryInfo("~/App_Data/plugins/xunit/").EnumerateFiles().Count());
            Assert.Null(PluginList.Load().Get("xunit"));
            Assert.Equal(0, PluginList.Load().Plugins.Count);
        }
Ejemplo n.º 15
0
        private void AttachPlugins(PluginList plugins, Assembly pluginAssembly)
        {
            try
            {
                List <Type> availableTypes = new List <Type>();
                availableTypes.AddRange(pluginAssembly.GetTypes());

                // Get the object that implements the IPluginForm interface
                // and PluginAttribute
                List <Type> pluginForms = availableTypes.FindAll(delegate(Type t)
                {
                    List <Type> interfaceTypes = new List <Type>(t.GetInterfaces());
                    Object[] arr = t.GetCustomAttributes(typeof(MyPluginAttribute), true);

                    return(!(arr == null || arr.Length == 0) && interfaceTypes.Contains(typeof(IMyPlugin)));
                });

                foreach (Type pluginForm in pluginForms)
                {
                    if (typeof(IMyPlugin).IsAssignableFrom(pluginForm))
                    {
                        try
                        {
                            IMyPlugin gsaPlugin = Activator.CreateInstance(pluginForm) as IMyPlugin;
                            if (gsaPlugin != null)
                            {
                                plugins.Add(gsaPlugin);
                            }
                        }
                        catch (MyAppAccessDeniedException ex)
                        {
                            Logger.Instance.WriteLog(ex);
                            // user does not permission to load this
                        }
                        catch (Exception ex)
                        {
                            MyAppAccessDeniedException accessDeniedException = ex.InnerException as MyAppAccessDeniedException;
                            // suppress MyAppAccessDeniedException
                            if (accessDeniedException == null)
                            {
#if DEBUG
                                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
                                Logger.Instance.WriteLog(accessDeniedException);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.WriteLog(ex.Message);
            }
        }
Ejemplo n.º 16
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     Types.Runner runner = PluginList.TypeCreator <Types.Runner>(PluginList.RunnerTypeList[CRunnerList.SelectedIndex]);
     if (runner.Create())
     {
         RunList.Add(runner);
         int a = RunnerList.Items.Count;
         RunnerList.Items.Add(runner.Name);
         RunnerList.Items[a].SubItems.Add(runner.Description);
     }
 }
Ejemplo n.º 17
0
 private static void AddPlugin(Group p)
 {
     if (p.Plugins == null)
     {
         p.Plugins = PluginList.Create();
     }
     if (p.Plugins.Plugin == null)
     {
         p.Plugins.Plugin = new ObservableCollection <Plugin>();
     }
     p.Plugins.Plugin.Add(Plugin.Create());
 }
Ejemplo n.º 18
0
        public void LoadPlugins()
        {
            // Calling it again just to make sure it still exists.
            // It could've been deleted by the user or other applications while the application runs.
            CreatePluginDirectory();
            var catalog   = new DirectoryCatalog(PluginDirectory);
            var container = new CompositionContainer(catalog);

            Plugins = null;
            container.ComposeParts(this);
            WrapPlugins();
        }
Ejemplo n.º 19
0
 private void WrapPlugins()
 {
     Plugins = new PluginList();
     foreach (var rawPlugin in RawPlugins)
     {
         var newPlugin = new Plugin(rawPlugin)
         {
             Settings = FindPluginSettings(rawPlugin)
         };
         Plugins.Add(newPlugin);
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// プラグインを読み込みます。
        /// </summary>
        public static bool Load()
        {
            // プラグイン読み込み準備
            if (!Prepare())
            {
                return(false);
            }

            // プラグインの読み込み
            PluginList = container.GetExportedValues <IPbSupporter>().ToList();
            PluginList.Sort((a, b) => (int)(a.Version - b.Version));
            return(true);
        }
Ejemplo n.º 21
0
        public void AddSubscriber(String eventName, IMyPlugin plugin)
        {
            lock (s_subscriberLock)
            {
                PluginList pluginList;
                if (!m_Subscribers.TryGetValue(eventName, out pluginList))
                {
                    pluginList = new PluginList();
                    m_Subscribers.Add(eventName, pluginList);
                }

                pluginList.Add(plugin);
            }
        }
Ejemplo n.º 22
0
        //プラグインリスト表示のメニューとコマンド
        private static CommandResult CmdPluginList(ICommandTarget target)
        {
            IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target);

            if (window == null)
            {
                return(CommandResult.Ignored);
            }

            PluginList dlg = new PluginList();

            dlg.ShowDialog(window.AsForm());
            return(CommandResult.Succeeded);
        }
Ejemplo n.º 23
0
        private List <IPluginContainer> LoadPlugins()
        {
            var ChangedList = new List <IPluginContainer>();

            string[] pluginNames = null;
            try
            {
                pluginNames = Directory.GetFiles(PluginDir, "*.dll");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
            foreach (string pluginName in pluginNames)
            {
                var pluginAssembly = Assembly.LoadFrom(pluginName);
                try
                {
                    foreach (var type in pluginAssembly.GetTypes())
                    {
                        if (type.GetInterfaces().Contains(typeof(IPluginContainer)))
                        {
                            var  plugin   = Activator.CreateInstance(type) as IPluginContainer;
                            bool isUnique = true;
                            foreach (var item in PluginList)
                            {
                                if (item.ClassName == plugin.ClassName)
                                {
                                    isUnique = false;
                                    break;
                                }
                            }
                            if (isUnique)
                            {
                                PluginList.Add(plugin);
                                ChangedList.Add(plugin);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(null);
                }
            }
            return(ChangedList);
        }
Ejemplo n.º 24
0
 public override void OnNavigatedTo(NavigationContext navigationContext)
 {
     if (navigationContext.Parameters["VisualPlugin"] is IVisualPlugin visualPlugin)
     {
         if (PluginList.Count(x => x.Label == visualPlugin.Name) == 0)
         {
             PluginSelectedIndex.Value = -1;
             OptionSelectedIndex.Value = -1;
             ActiveViewName.Value      = "";
             return;
         }
         RegionManager.RequestNavigate(PluginMainViewRegion.Value, visualPlugin.MainViewName);
         PluginSelectedIndex.Value = PluginList.IndexOf(PluginList.FirstOrDefault(x => x.Label == visualPlugin.Name && x.Icon as string == visualPlugin.Icon && x.Tag as string == visualPlugin.MainViewName));
         ActiveViewName.Value      = visualPlugin.Name;
     }
 }
Ejemplo n.º 25
0
        public Data()
        {
            Project         = new Project();
            files           = new Ficheros();
            Ips             = new IPs();
            domains         = new Domains();
            relations       = new Relations();
            computers       = new Computers();
            computerIPs     = new ComputerIPs();
            computerDomains = new ComputerDomains();
            resolver        = new Resolver();
 #if PLUGINS
            plugins = new PluginList();
#endif
            lstLimits = new ThreadSafeList <Limits>();
        }
Ejemplo n.º 26
0
        private void LoadPlugins()
        {
            PluginList plugins = new PluginList();

            String pluginDirectory = Application.StartupPath;

            // low lookup in plugin directory
            String[] pluginFiles = Directory.GetFiles(pluginDirectory, "*.DLL");

            foreach (String pluginFile in pluginFiles)
            {
                Assembly pluginAssembly = Assembly.LoadFile(pluginFile);

                AttachPlugins(plugins, pluginAssembly);
            }

            AttachPlugins(plugins);
        }
        /// <summary>
        /// Uninstalls the plugin associated with the ID
        /// </summary>
        /// <param name="ID">The identifier.</param>
        /// <returns>Returns true if it is uninstalled successfully, false otherwise</returns>
        public bool UninstallPlugin(string ID)
        {
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            var TempPlugin = PluginList.Get(ID);

            if (TempPlugin == null)
            {
                return(true);
            }
            var User = HttpContext.Current.Chain(x => x.User).Chain(x => x.Identity).Chain(x => x.Name, "");

            Utilities.IO.Log.Get().LogMessage("Plugin {0} is being uninstalled by {1}", MessageType.Debug, ID, User);
            TempPlugin.Delete();
            Utilities.IO.Log.Get().LogMessage("Plugin {0} has been uninstalled by {1}", MessageType.Debug, ID, User);
            PluginList.Remove(TempPlugin);
            PluginList.Save();
            return(true);
        }
Ejemplo n.º 28
0
        private void Button_Click_MoveDown(object sender, RoutedEventArgs e)
        {
            int index = PluginList.SelectedIndex;

            if (index >= 0)
            {
                IList list = PluginList.ItemsSource as IList;
                if (index < (list.Count - 1))
                {
                    object item = list[index];
                    list.RemoveAt(index);
                    index++;
                    list.Insert(index, item);
                    PluginList.SelectedIndex = index;
                    PluginList.ScrollIntoView(item);
                }
            }
        }
Ejemplo n.º 29
0
        private void ReadRemotePluginsFile()
        {
            var           pluginlistPath = PathTools.RelativeAssetPath(this.GetType(), DocDir);
            DirectoryInfo info           = new DirectoryInfo(pluginlistPath);

            remoteplugins = JsonUtility.FromJson <PluginList>(FileTools.ReadAllText(info + "/plugins.json"));
            if (RemotepluginExtends != null)
            {
                foreach (var item in RemotepluginExtends)
                {
                    item.valueChanged.RemoveListener(window.Repaint);
                }
            }
            RemotepluginExtends = new AnimBool[remoteplugins.Plugins.Count];
            for (int i = 0; i < RemotepluginExtends.Length; i++)
            {
                RemotepluginExtends[i] = new AnimBool(false);
                RemotepluginExtends[i].valueChanged.AddListener(window.Repaint);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        public AboutForm()
        {
            InitializeComponent();

            PluginList.SuspendLayout();
            //foreach (Provider provider in ResourceManager.Providers)
            foreach (RegisteredAsset ra in ResourceManager.RegisteredAssets)
            {
                PluginList.Items.Add(ra.Type.Name);
            }
            PluginList.ResumeLayout();


/*
 *
 *                      foreach (IPlugin plugin in PluginManager.Plugins)
 *                              PluginList.Items.Add(plugin.Name + " " + plugin.Version.ToString());
 *
 */
        }
Ejemplo n.º 31
0
        public void GetPlugins()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "plugins", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json       = new JSONObject(result);
                PluginList pluginList = new PluginList();
                pluginList.plugins    = new Plugins();
                foreach (string pluginName in json.keys)
                {
                    pluginList.plugins.Add(pluginName, JsonUtility.FromJson <Plugin>(json.GetField(pluginName).ToString()));
                }
                if (OnGotPlugins != null)
                {
                    OnGotPlugins(pluginList);
                }
            });
        }
Ejemplo n.º 32
0
 public Form1()
 {
     InitializeComponent();
     PluginList.ReadAllPluginsInTypes();
     SaveList.ReadAllSaveFiles();
     if (SaveList.saveList.Count > 0)
     {
         if (SaveList.saveList[0].Items != null)
         {
             itemList = new List <Items.Item>(SaveList.saveList[0].Items);
         }
         else
         {
             itemList = new List <Items.Item>();
         }
     }
     else
     {
         itemList = new List <Items.Item>();
     }
     findStyleBox.SelectedIndex = 0;
     RefreshList();
 }
Ejemplo n.º 33
0
        public PluginList GetPlugins()
        {
            var iPluginName = typeof(IPlugin).FullName;

            var list = new PluginList();
            string[] files;
            try
            {
                files = Directory.GetFiles(PluginDirectoryPath, "*.dll")
                    .Concat(Directory.GetDirectories(PluginDirectoryPath)
                        .SelectMany(x => Directory.GetFiles(x, "*.dll")))
                    .ToArray();
            }
            catch
            {
                return new PluginList();
            }
            foreach (var path in files)
            {
                try
                {
                    var assembly = Assembly.LoadFile(path);
                    list.AddRange(assembly.GetTypes()
                        .Where(x => x.IsClass && !x.IsAbstract && !x.IsNotPublic
                            && x.GetInterface(iPluginName) != null)
                        .Select(x => new ExternalPlugin(
                            GetRelativeFileNameWithoutExtension(path),
                            (IPlugin)Activator.CreateInstance(x))));
                }
                catch
                {
                    continue;
                }
            }
            return list;
        }
 public PluginSettingsViewModel(PluginList plugins)
 {
     Plugins = plugins.Select(x => new PluginColumnViewModel(x)).ToList();
 }
Ejemplo n.º 35
-1
 public PluginsModel(ConfigurationDao dao, PluginList plugins)
 {
     this.dao = dao;
     Plugins = plugins;
     foreach (var plugin in Plugins)
     {
         plugin.IsEnabledChanged += (s, e) =>
         {
             var p = (ExternalPlugin)s;
             if (p.IsEnabled)
                 Initialize(p);
             else
                 Terminate(p);
         };
     }
     InitializeAll();
 }