示例#1
0
        public void KnownApplicationNameTest(string appName, string fqdn)
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            var logger = new Mock <ILoggerFactory>().Object;

            FactoryApplicationContext.SetLoggerFactory(logger);

            FactoryApplicationContext.ClearRegisteredItems();
            FactoryApplicationContext.RegisterApplication(asm, appName, fqdn);

            var items = new Dictionary <string, PluginEntry>();

            for (int i = 1; i <= 5; i++)
            {
                string key   = string.Format("{0}_{1}", appName, i);
                var    entry = new PluginEntry(asm, key, fqdn);

                items.Add(key, entry);
            }

            FactoryApplicationContext.RegisterApplications(items);

            IApplication opt = FactoryApplicationContext.CreateApplicationObject(appName);

            Assert.IsNotNull(opt, "Object must not be null!!!");
        }
示例#2
0
 public frmPluginManager()
 {
     InitializeComponent();
     SetupPlugins();
     ipsel = null;
     UpdateButtons();
 }
示例#3
0
        public static IBusinessOperation CreateBusinessOperationObject(string profile, string name)
        {
            if (!classMaps.ContainsKey(name))
            {
                throw new ArgumentNullException(String.Format("Operation not found [{0}]", name));
            }

            PluginEntry entry = classMaps[name];

            Assembly           asm = Assembly.Load(entry.Asm.GetName());
            IBusinessOperation obj = (IBusinessOperation)asm.CreateInstance(entry.Fqdn);

            ContextGroup grp = GetContextGroup(profile);

            obj.SetNoSqlContext(grp.NoSqlContext);
            obj.SetStorageContext(grp.StorageContext);
            obj.SetSmtpContext(grp.SmtpContext);
            obj.SetDatabaseContext(grp.DatabaseContext);

            if (loggerFactory != null)
            {
                Type    t      = obj.GetType();
                ILogger logger = loggerFactory.CreateLogger(t);
                obj.SetLogger(logger);
            }

            return(obj);
        }
示例#4
0
 private static async Task UpdateTabContent(PluginEntry pluginEntry, ClosableTab tab, SessionEntry?entry = null)
 {
     pluginEntry.Plugin.ProgressReportStart    += tab.CreateProgressBar;
     pluginEntry.Plugin.ProgressReportUpdate   += tab.UpdateProgressBar;
     pluginEntry.Plugin.ProgressReportComplete += tab.ClearProgressBarEventHandler;
     pluginEntry.Plugin.ReadFromFileRequest    += ReadFromFileRequestHandler;
     pluginEntry.Plugin.WriteToFileRequest     += WriteToFileRequestHandler;
     try
     {
         await pluginEntry.Plugin.RestoreAsync();
     }
     catch (System.Security.SecurityException)
     {
         string message = "Password has been changed. " + pluginEntry.Name + " plugin state cannot be loaded.";
         string caption = "Plugin state load error";
         var    result  = MessageBox.Show(Application.Current.MainWindow, message, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
     tab.Content = pluginEntry.Plugin;
     tab.Title   = pluginEntry.Name;
     if (entry != null)
     {
         if (((SessionEntry)entry).isSelected)
         {
             OnUpdateSelectedTab(new UpdateSelectedTabEventArgs(((SessionEntry)entry).Positon));
         }
     }
 }
示例#5
0
 static bool CheckTrial(PluginEntry pe)
 {
     /*
      * string strPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TMCR";
      * if (!Directory.Exists(strPath))
      * {
      *  Utility.CreateDirectory(strPath);
      * }
      *
      * strPath += "\\CRTMSet.dbg";
      *
      *
      * TrialMaker t = new TrialMaker("CT5", Application.StartupPath + "\\RegFile.reg",
      *  //Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\TMSetp.dbf",
      *  strPath,
      *  "",
      *  30, 1000, "887");
      * //Environment.SpecialFolder.ApplicationData
      * byte[] MyOwnKey = { 97, 250, 1, 5, 84, 21, 7, 63,
      * 4, 54, 87, 56, 123, 10, 3, 62,
      * 7, 9, 20, 36, 37, 21, 101, 57};
      * t.TripleDESKey = MyOwnKey;
      *
      * TrialMaker.RunTypes RT = t.ShowDialog();
      * //bool is_trial;
      *
      * if (RT != TrialMaker.RunTypes.Expired)
      * {
      *
      *  return true;
      *  //Application.Run(new Form1(is_trial));
      * }
      */
     return(false);
 }
        private void txtUndo_MouseUp(object sender, MouseButtonEventArgs e)
        {
            PluginEntry entry = (PluginEntry)((TextBlock)sender).DataContext;

            if (entry.UninstallOnClose)
            {
                foreach (var other in CurrentPlugins)
                {
                    if (entry.PluginAssembly == other.PluginAssembly)
                    {
                        other.UninstallOnClose = false;
                    }
                }
            }
            else if (entry.InstallOnClose)
            {
                entry.IsSelected = true;
                btnPluginRemove_Click(sender, null);
            }
            else if (entry.DisableOnClose)
            {
                entry.DisableOnClose = false;
            }
            else if (entry.EnableOnClose)
            {
                entry.EnableOnClose = false;
            }
        }
示例#7
0
        static bool CheckTrial(PluginEntry pe)
        {
            TrialMaker t = new TrialMaker("TT6", Application.StartupPath + "\\RegFile.reg",
                //Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\TMSetp.dbf",
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TMSetp.dbf",
                "",
                60, 1000, "745");
            //Environment.SpecialFolder.ApplicationData
            byte[] MyOwnKey = { 97, 250, 1, 5, 84, 21, 7, 63,
            4, 54, 87, 56, 123, 10, 3, 62,
            7, 9, 20, 36, 37, 21, 101, 57};
            t.TripleDESKey = MyOwnKey;

            TrialMaker.RunTypes RT = t.ShowDialog();
            //bool is_trial;
            if (RT != TrialMaker.RunTypes.Expired)
            {
                /*
                if (RT == TrialMaker.RunTypes.Full)
                    is_trial = false;
                else
                    is_trial = true;
                 * */
                return true;
                //Application.Run(new Form1(is_trial));
            }
            return false;
            //return true;
        }
 private void CreatePluginEntry(PluginAssembly pa, bool fAddedByUser)
 {
     if (!pa.PluginInfosExist || CurrentPlugins.Any(pe => pe.Path == pa.Path))
     {
         return;
     }
     foreach (PluginInformation pi in pa.PluginInformations)
     {
         if (null != pi && null != pi.Path)
         {
             // Check the file exists by qwop ?
             if (!File.Exists(pi.Path))
             {
                 continue;
             }
             // Check the file exists by qwop ?
             PluginEntry entry = new PluginEntry(this, pi, pa)
             {
                 InstallOnClose = fAddedByUser
             };
             int i = 0;
             while (i < CurrentPlugins.Count && string.Compare(CurrentPlugins[i].Title, entry.Title, true) <= 0)
             {
                 ++i;
             }
             CurrentPlugins.Insert(i, entry);
         }
     }
 }
 public static void RegisterItems(Dictionary <string, PluginEntry> dests, Dictionary <string, PluginEntry> items)
 {
     foreach (KeyValuePair <string, PluginEntry> item in items)
     {
         PluginEntry entry = item.Value;
         RegisterItem(dests, entry.Asm, entry.Key, entry.Fqdn);
     }
 }
示例#10
0
 private void lvplugins_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvplugins.SelectedIndices.Count > 0)
     {
         int idx = lvplugins.SelectedIndices[0];
         ipsel = UVDLPApp.Instance().m_plugins[idx];
         UpdateButtons();
     }
 }
示例#11
0
        /// <summary>
        /// Loading 'lite' plugins from zip file .plg files
        /// </summary>
        public void ScanForPluginsLite()
        {
            // load the list of plugin states
            string picn = m_apppath + m_pathsep + "pluginconfig.cfg"; // plugin configuration name

            m_pluginstates.Load(picn);

            // get a list of dll's in this current directory
            // try to register them as a plug-in
            string[] filePaths = Directory.GetFiles(m_apppath, "*.plg");
            foreach (String pluginname in filePaths)
            {
                try
                {
                    // create an instance of the plugin
                    PluginLite pll = new PluginLite();
                    pll.m_filename = pluginname;
                    pll.LoadManifest();
                    IPlugin plug = (IPlugin)pll;
                    string  args = Path.GetFileNameWithoutExtension(pluginname);

                    // create an entry for the plugin
                    PluginEntry pe = new PluginEntry(plug, args);
                    //add the entry to the list of plugins
                    m_plugins.Add(pe);
                    //mark the plugin as enabled by default
                    pe.m_enabled = true;
                    if (m_pluginstates.InList(args))
                    {
                        // this plugin is listed in the disabled list.
                        DebugLogger.Instance().LogInfo("Plugin " + args + " marked disabled");
                        pe.m_enabled = false;
                    }
                    //get the vendor id of the newly loaded plugin
                    int vid = plug.GetInt("VendorID");
                    //look for the license key for this plugin
                    LicenseKey lk = KeyRing.Instance().Find(vid);
                    // if we found it, mark it as licensed
                    if (lk != null)
                    {
                        //initialize the plugin by setting the host.
                        if (pe.m_enabled)
                        {
                            plug.Host = this; // this will initialize the plugin - the plugin's init function will be called
                            DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args);
                        }
                    }
                    DebugLogger.Instance().LogInfo("Loaded plugin " + args);
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex.Message);
                }
            }
        }
 public void ScanForPlugins()
 {
     // get a list of dll's in this current directory
     // try to register them as a plug-in
     //string[] filePaths = Directory.GetFiles(m_apppath + m_pathsep + "Plugins", "*.dll");
     string[] filePaths = Directory.GetFiles(m_apppath, "*.dll");
     foreach (String pluginname in filePaths)
     {
         string args = Path.GetFileNameWithoutExtension(pluginname);
         if (args.ToLower().StartsWith("pl"))
         {
             // located a dll that is a potential plugin
             Type ObjType = null;
             try
             {
                 // load it
                 Assembly ass = null;
                 //string args = Path.GetFileNameWithoutExtension(pluginname);
                 ass = Assembly.Load(args);
                 if (ass != null)
                 {
                     ObjType = ass.GetType(args + ".PlugIn"); // look for the plugin interface
                     // OK Lets create the object as we have the Report Type
                     if (ObjType != null)
                     {
                         // create an instance of the plugin
                         IPlugin plug = (IPlugin)Activator.CreateInstance(ObjType);
                         // create an entry for the plugin
                         PluginEntry pe = new PluginEntry(plug);
                         //add the entry to the list of plugins
                         m_plugins.Add(pe);
                         //get the vendor id of the newly loaded plugin
                         int vid = plug.GetInt("VendorID");
                         //look for the license key for this plugin
                         LicenseKey lk = KeyRing.Instance().Find(vid);
                         // if we found it, mark it as licensed
                         if (lk != null)
                         {
                             pe.m_licensed = true;
                             //initialize the plugin by setting the host.
                             plug.Host = this; // this will initialize the plugin - the plugin's init function will be called
                             DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args);
                         }
                         DebugLogger.Instance().LogInfo("Loaded plugin " + args);
                     }
                 }
             }
             catch (Exception ex)
             {
                 DebugLogger.Instance().LogError(ex.Message);
             }
         }
     }
 }
示例#13
0
    void OnEnable()
    {
        var camera = GetComponent <Camera>();

        if (sendTexture == null && camera != null)
        {
            _sender = PluginEntry.CreateSender(name, camera.pixelWidth, camera.pixelHeight);
            return;
        }
        _sender = PluginEntry.CreateSender(name, sendTexture.width, sendTexture.height);
    }
        private string[] GetSpoutList()
        {
            var count = PluginEntry.CountSharedObjects();
            var names = new string[count];

            for (var i = 0; i < count; i++)
            {
                names[i] = PluginEntry.GetSharedObjectNameString(i);
            }
            return(names);
        }
示例#15
0
 private void lvplugins_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int idx = lvplugins.SelectedIndices[0];
         m_ip = UVDLPApp.Instance().m_plugins[idx];
         ListContents();
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
示例#16
0
        private List <string> GetSpoutList()
        {
            var count = PluginEntry.CountSharedObjects();
            var names = new List <string>();

            for (var i = 0; i < count; i++)
            {
                names.Add(PluginEntry.GetSharedObjectNameString(i));
            }
            if (count == 0)
            {
                names.Add("NONE");
            }
            return(names);
        }
示例#17
0
        public static async void GetPluginUI(PluginEntry sourcePlugin)
        {
            ClosableTab requestedPlugin = isOpened(sourcePlugin.Name);

            if (requestedPlugin == null)
            {
                await UpdateTabContent(sourcePlugin, GetSelectedTab());
            }
            else
            {
                await CloseTabAsync(GetSelectedTab());

                OnUpdateSelectedTab(new UpdateSelectedTabEventArgs(MainWindowViewModel.tabs.IndexOf(requestedPlugin)));
            }
        }
        public static ICacheContext GetCacheObject(string profile, string name)
        {
            if (!classMaps.ContainsKey(name))
            {
                throw new ArgumentNullException(String.Format("Cache name not found [{0}]", name));
            }

            PluginEntry entry = classMaps[name];

            Dictionary <string, ICacheContext> cacheMaps = null;

            if (!cacheProfileMaps.ContainsKey(profile))
            {
                cacheMaps = new Dictionary <string, ICacheContext>();
                cacheProfileMaps.Add(profile, cacheMaps);
            }
            else
            {
                cacheMaps = cacheProfileMaps[profile];
            }

            ICacheContext cacheObj = null;

            if (!cacheMaps.ContainsKey(name))
            {
                //Create just only one time and reuse it later
                //Using lazy approach

                Assembly asm = Assembly.Load(entry.Asm.GetName());

                cacheObj = (ICacheContext)asm.CreateInstance(entry.Fqdn);
                cacheMaps.Add(name, cacheObj);

                if (loggerFactory != null)
                {
                    Type    t      = cacheObj.GetType();
                    ILogger logger = loggerFactory.CreateLogger(t);
                    cacheObj.SetLogger(logger);
                }
            }
            else
            {
                cacheObj = cacheMaps[name];
            }

            return(cacheObj);
        }
示例#19
0
        private List <string> GetSpoutSyphonList()
        {
            var namesString = new List <string>();

#if UNITY_STANDALONE_OSX
            var list  = Plugin_CreateServerList();
            var count = Plugin_GetServerListCount(list);
            var names = new Tuple <string, string> [count];
            for (var i = 0; i < count; i++)
            {
                var pName    = Plugin_GetNameFromServerList(list, i);
                var pAppName = Plugin_GetAppNameFromServerList(list, i);

                var name    = (pName != IntPtr.Zero) ? Marshal.PtrToStringAnsi(pName) : "(no name)";
                var appName = (pAppName != IntPtr.Zero) ? Marshal.PtrToStringAnsi(pAppName) : "(no app name)";
                names[i] = Tuple.Create(appName, name);
            }


            for (var i = 0; i < names.Count(); i++)
            {
                namesString.Add($"{names[i].Item1}/{names[i].Item2}");
            }

            if (count == 0)
            {
                namesString.Add("NONE");
            }
#endif

#if UNITY_STANDALONE_WIN
            var count = PluginEntry.CountSharedObjects();
            var names = new List <string>();
            for (var i = 0; i < count; i++)
            {
                namesString.Add(PluginEntry.GetSharedObjectNameString(i));
            }
            if (count == 0)
            {
                namesString.Add("NONE");
            }
#endif

            return(namesString);
        }
示例#20
0
        public static BaseDbContext CreateDbContextObject(string name, DbCredential credential)
        {
            if (!classMaps.ContainsKey(name))
            {
                throw new ArgumentNullException(String.Format("DbContext not found [{0}]", name));
            }

            PluginEntry entry = classMaps[name];

            Assembly asm = Assembly.Load(entry.Asm.GetName());
            Type     t   = asm.GetType(entry.Fqdn);

            BaseDbContext obj = (BaseDbContext)Activator.CreateInstance(t, credential);

            obj.SetLoggerFactory(loggerFactory);

            return(obj);
        }
        private void OnPluginLoaded(Plugin plugin)
        {
            var entry = GetPluginEntry(plugin);

            if (entry != null)
            {
                return;
            }

            // Special case for editor plugins (merge with game plugin if has linked)
            if (plugin is EditorPlugin editorPlugin && GetPluginEntry(editorPlugin.GamePluginType) != null)
            {
                return;
            }

            var desc     = plugin.Description;
            var category = _categories.Find(x => string.Equals(x.Text, desc.Category, StringComparison.OrdinalIgnoreCase));

            if (category == null)
            {
                category = new CategoryEntry(desc.Category)
                {
                    AnchorPreset = AnchorPresets.StretchAll,
                    Offsets      = Margin.Zero,
                    Parent       = _tabs
                };
                _categories.Add(category);
                category.UnlockChildrenRecursive();
            }

            entry = new PluginEntry(plugin, category, ref desc)
            {
                Parent = category.Panel,
            };
            _entries.Add(plugin, entry);
            entry.UnlockChildrenRecursive();

            if (_tabs.SelectedTab == null)
            {
                _tabs.SelectedTab = category;
            }
        }
示例#22
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        // Lazy initialization for the shared texture.
        if (_sharedTexture == null)
        {
            var ptr = PluginEntry.GetTexturePointer(_sender);
            if (ptr != System.IntPtr.Zero)
            {
                _sharedTexture = Texture2D.CreateExternalTexture(
                    PluginEntry.GetTextureWidth(_sender),
                    PluginEntry.GetTextureHeight(_sender),
                    TextureFormat.ARGB32, false, false, ptr
                    );
            }
        }

        // Update the shared texture.
        if (_sharedTexture != null)
        {
            // Lazy initialization for the fix-up shader.
            if (_fixupMaterial == null)
            {
                _fixupMaterial = new Material(Shader.Find("Hidden/Spout/Fixup"));
            }

            // Parameters for the fix-up shader.
            _fixupMaterial.SetFloat("_ClearAlpha", _clearAlpha ? 1 : 0);

            // Apply the fix-up shader.
            var tempRT = RenderTexture.GetTemporary(_sharedTexture.width, _sharedTexture.height);
            Graphics.Blit(source, tempRT, _fixupMaterial, 0);

            // Copy the result to the shared texture.
            Graphics.CopyTexture(tempRT, _sharedTexture);

            // Release temporaries.
            RenderTexture.ReleaseTemporary(tempRT);
        }

        // Just transfer the source to the destination.
        Graphics.Blit(source, destination);
    }
        private void btnPluginEnableDisable_Click(object sender, RoutedEventArgs e)
        {
            PluginEntry entry = (PluginEntry)((Button)sender).DataContext;

            if (entry.DisableOnClose)
            {
                entry.DisableOnClose = false;
            }
            else if (entry.EnableOnClose)
            {
                entry.EnableOnClose = false;
            }
            else if (entry.Enabled)
            {
                entry.DisableOnClose = true;
            }
            else
            {
                entry.EnableOnClose = true;
            }
        }
示例#24
0
    void OnDisable()
    {
        if (_sender != System.IntPtr.Zero)
        {
            PluginEntry.DestroySharedObject(_sender);
            _sender = System.IntPtr.Zero;
        }

        if (_sharedTexture != null)
        {
            if (Application.isPlaying)
            {
                Destroy(_sharedTexture);
            }
            else
            {
                DestroyImmediate(_sharedTexture);
            }
            _sharedTexture = null;
        }
    }
        public static IApplication CreateApplicationObject(string name)
        {
            if (!classMaps.ContainsKey(name))
            {
                throw new ArgumentNullException(String.Format("Application not found [{0}]", name));
            }


            PluginEntry entry = classMaps[name];

            Assembly     asm = Assembly.Load(entry.Asm.GetName());
            IApplication obj = (IApplication)asm.CreateInstance(entry.Fqdn);

            if (loggerFactory != null)
            {
                Type    t      = obj.GetType();
                ILogger logger = loggerFactory.CreateLogger(t);
                obj.SetLogger(logger);
            }

            return(obj);
        }
        private void btnPluginRemove_Click(object sender, RoutedEventArgs e)
        {
            PluginEntry    entry          = (PluginEntry)((Button)sender).DataContext;
            PluginAssembly pluginAssembly = entry.PluginAssembly;

            if (pluginAssembly.PluginInformations.Count > 1)
            {
                string plugins = pluginAssembly.PluginInformations.Select(info => info.Name).StringJoin(", ");
                if (MessageBox.Show(
                        QTUtility.TextResourcesDic["Options_Page12_Plugins"][8] +
                        Environment.NewLine + Environment.NewLine + plugins + Environment.NewLine + Environment.NewLine +
                        QTUtility.TextResourcesDic["Options_Page12_Plugins"][9],
                        QTUtility.TextResourcesDic["OptionsDialog"][3],
                        MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                {
                    return;
                }
            }
            for (int i = 0; i < CurrentPlugins.Count; i++)
            {
                PluginEntry otherEntry = CurrentPlugins[i];
                if (otherEntry.PluginAssembly == entry.PluginAssembly)
                {
                    if (otherEntry.InstallOnClose)
                    {
                        CurrentPlugins.RemoveAt(i);
                        --i;
                    }
                    else
                    {
                        otherEntry.UninstallOnClose = true;
                    }
                }
            }
            if (entry.InstallOnClose)
            {
                entry.PluginAssembly.Dispose();
            }
        }
        private void btnPluginOptions_Click(object sender, RoutedEventArgs e)
        {
            PluginEntry entry = (PluginEntry)((Button)sender).DataContext;
            string      pid   = entry.PluginID;

            // Unfortunately, we can't call Plugin.OnOption on plugins that are
            // loaded in a non-static context.
            InstanceManager.InvokeMain(tabbar => {
                Plugin p;
                if (!tabbar.pluginServer.TryGetPlugin(pid, out p) || p.Instance == null)
                {
                    return;
                }
                try {
                    p.Instance.OnOption();
                }
                catch (Exception ex) {
                    PluginManager.HandlePluginException(ex, new WindowInteropHelper(Window.GetWindow(this)).Handle,
                                                        entry.Name, "Open plugin option.");
                }
            });
        }
示例#28
0
        private void OnPluginRemove(PluginEntry entry)
        {
            var category = entry.Category;

            _entries.Remove(entry.Plugin);
            entry.Dispose();

            // If category is not used anymore
            if (_entries.Values.Count(x => x.Category == category) == 0)
            {
                if (_tabs.SelectedTab == category)
                {
                    _tabs.SelectedTab = null;
                }

                category.Dispose();
                _categories.Remove(category);

                if (_tabs.SelectedTab == null && _categories.Count > 0)
                {
                    _tabs.SelectedTab = _categories[0];
                }
            }
        }
示例#29
0
 public void RemoveAddon(PluginEntry plugin) {
     throw new NotImplementedException();
 }
 private void CreatePluginEntry(PluginAssembly pa, bool fAddedByUser) {
     if(!pa.PluginInfosExist || CurrentPlugins.Any(pe => pe.Path == pa.Path)) {
         return;
     }
     foreach(PluginInformation pi in pa.PluginInformations) {
         PluginEntry entry = new PluginEntry(this, pi, pa) { InstallOnClose = fAddedByUser };
         int i = 0;
         while(i < CurrentPlugins.Count && string.Compare(CurrentPlugins[i].Title, entry.Title, true) <= 0) ++i;
         CurrentPlugins.Insert(i, entry);
     }
 }
示例#31
0
 internal void OnPluginEnabled(PluginEntry plugin, bool value) {
     (value ? PluginEnabled : PluginDisabled)?.Invoke(this, new AppAddonEventHandlerArgs { PluginId = plugin.Id });
 }
示例#32
0
 void Start()
 {
     PluginEntry.SetPrintDelegate(Print);
     Debug.Log(PluginEntry.GetID());
 }
示例#33
0
        public async Task InstallPlugin(PluginEntry plugin, IProgress<double?> progress = null, CancellationToken cancellation = default(CancellationToken)) {
            var destination = GetPluginDirectory(plugin.Id);

            try {
                plugin.IsInstalling = true;
                
                var data = await CmApiProvider.GetDataAsync($"plugins/get/{plugin.Id}", progress, cancellation);
                if (data == null || cancellation.IsCancellationRequested) return;

                await Task.Run(() => {
                    if (Directory.Exists(destination)) {
                        FileUtils.Recycle(destination);
                    }

                    using (var stream = new MemoryStream(data, false))
                    using (var archive = new ZipArchive(stream)) {
                        archive.ExtractToDirectory(destination);
                    }
                }, cancellation);
                if (cancellation.IsCancellationRequested) return;

                plugin.InstalledVersion = plugin.Version;
                File.WriteAllText(Path.Combine(destination, ManifestName), JsonConvert.SerializeObject(plugin));

                if (plugin.IsEnabled) {
                    PluginEnabled?.Invoke(this, new AppAddonEventHandlerArgs { PluginId = plugin.Id });
                }
            } catch (Exception e) {
                NonfatalError.Notify(ToolsStrings.Plugins_CannotInstall, e);
            } finally {
                plugin.IsInstalling = false;
            }
        }
示例#34
0
        protected void AddClassConfig(Assembly asm, string apiName, string fqdn)
        {
            PluginEntry entry = new PluginEntry(asm, apiName, fqdn);

            classMaps.Add(apiName, entry);
        }