public static void MarkPluginAsEnabled(string systemName, bool enable) { if (String.IsNullOrEmpty(systemName)) { throw new ArgumentNullException("systemName"); } var filePath = HostingEnvironment.MapPath(InstalledPluginsFilePath); if (!File.Exists(filePath)) { using (File.Create(filePath)) { //we use 'using' to close the file after it's created } } var pluginInstalled = PluginFileParser.ParseInstalledPluginsFile(GetInstalledPluginsFilePath()); var pluginFound = pluginInstalled.Plugins .FirstOrDefault(x => x.SystemName.Equals(systemName, StringComparison.InvariantCultureIgnoreCase)); if (pluginFound != null) { pluginFound.Enabled = enable; } // remove var plugin = ReferencedPlugins.Where(x => x.SystemName.Equals(systemName, StringComparison.InvariantCulture)).FirstOrDefault(); plugin.Enabled = enable; PluginFileParser.SaveInstalledPluginsFile(pluginInstalled, filePath); }
public static bool IsPluginLimitedToTenants(string systemName) { if (IsPluginInstalled(systemName)) { return(ReferencedPlugins.First(x => x.SystemName == systemName).LimitedToTenants.Any()); } return(false); }
/// <summary> /// Find a plugin descriptor by some type which is located into the same assembly as plugin /// </summary> /// <param name="typeInAssembly">Type</param> /// <returns>Plugin descriptor if exists; otherwise null</returns> public static PluginDescriptor FindPlugin(Type typeInAssembly) { if (typeInAssembly == null) { throw new ArgumentNullException(nameof(typeInAssembly)); } return(ReferencedPlugins?.FirstOrDefault(plugin => plugin.ReferencedAssembly != null && plugin.ReferencedAssembly.FullName.Equals(typeInAssembly.Assembly.FullName, StringComparison.InvariantCultureIgnoreCase))); }
/// <summary> /// 查找某一类型对应的插件描述信息 /// </summary> /// <param name="typeInAssembly"></param> /// <returns></returns> public static PluginDescriptor FindPlugin(Type typeInAssembly) { Check.NotNull(typeInAssembly, nameof(typeInAssembly)); if (ReferencedPlugins == null) { return(null); } return(ReferencedPlugins.FirstOrDefault(plugin => plugin.ReferencedAssembly != null && plugin.ReferencedAssembly.FullName.Equals(typeInAssembly.Assembly.FullName, StringComparison.InvariantCultureIgnoreCase))); }
/// <summary> /// Find a plugin descriptor by some type which is located into the same assembly as plugin /// </summary> /// <param name="typeInAssembly">Type</param> /// <returns>Plugin descriptor if exists; otherwise null</returns> public static PluginDescriptor FindPlugin(Type typeInAssembly) { if (typeInAssembly == null) { throw new ArgumentNullException("typeInAssembly"); } if (ReferencedPlugins == null) { return(null); } return(ReferencedPlugins.FirstOrDefault(plugin => plugin.ReferencedAssembly != null && plugin.ReferencedAssembly.FullName.Equals(typeInAssembly.GetTypeInfo().Assembly.FullName, StringComparison.OrdinalIgnoreCase))); }
public static bool IsPluginInstalled(string systemName) { if (installedPlugins == null) { installedPlugins = new Dictionary <string, bool>(); } if (!installedPlugins.ContainsKey(systemName)) { bool isInstalled = ReferencedPlugins.Any(x => x.SystemName == systemName && x.Installed); installedPlugins.Add(systemName, isInstalled); } return(installedPlugins[systemName]); }