private void ProcessCommandCreate( bool verbose, string dir, bool overwrite, string name, SemanticVersion version) { try { if (verbose) { Logger.EnableVerbose(); } string file = GetFileName(dir, false); if (File.Exists(file)) { if (!overwrite) { Logger.Error($"File already exists: {file}. Use option '-o' to overwrite."); return; } } else if (string.IsNullOrWhiteSpace(file)) { Logger.Error($"Configuration file name is invalid: '{file}'."); return; } var configuration = new PlugInConfiguration(name, version, new HashSet <ConfigurationOption>()); using var stream = File.Create(file); PlugInConfigurationSerializer.WriteToStream(configuration, stream, new BridgeLogger()); stream.Flush(true); Logger.Information($"New configuration logged to {file}."); } catch (Exception e) { _parsingException = e; } }
/// <summary> /// 注册菜单插件 /// </summary> public void RegisterMenuPlugins(Account currentAccount) { m_PrivilegeMenu = new Collection <PlugInConfiguration>(); for (int i = 0; i < this.pluginMenu.Count; i++) { PlugInConfiguration pluginconfig = this.pluginMenu[i]; if (!pluginconfig.Visible) { continue; } if (currentAccount.IsAdministrator() || (currentAccount.HasPermission(pluginconfig.AssemblyName, pluginconfig.AssemblyStartupClass))) { if (menuregister != null) { //menuregister.Register(pluginconfig); m_PrivilegeMenu.Add(pluginconfig); } } } }
/// <summary> /// 运行插件(菜单信息) /// </summary> /// <param name="menuInfo"></param> /// <returns></returns> public IPlugIn LoadPlugIn(PlugInConfiguration menuInfo) { return(LoadPlugIn(menuInfo.AssemblyName, menuInfo.AssemblyStartupClass, false)); }
private static PlugInConfigurationDto BuildConfigurationDto(Type plugInType, GameConfiguration gameConfiguration, PlugInConfiguration plugInConfiguration) { var plugInAttribute = plugInType.GetCustomAttribute <PlugInAttribute>(); var plugInPoint = plugInType.GetInterfaces().FirstOrDefault(i => i.GetCustomAttribute <PlugInPointAttribute>() != null)?.GetCustomAttribute <PlugInPointAttribute>(); var customPlugInContainer = plugInType.GetInterfaces().FirstOrDefault(i => i.GetCustomAttribute <CustomPlugInContainerAttribute>() != null)?.GetCustomAttribute <CustomPlugInContainerAttribute>(); var dto = new PlugInConfigurationDto { Id = plugInConfiguration.GetId(), GameConfigurationId = gameConfiguration.GetId(), CustomPlugInSource = plugInConfiguration.CustomPlugInSource, ExternalAssemblyName = plugInConfiguration.ExternalAssemblyName, IsActive = plugInConfiguration.IsActive, TypeId = plugInConfiguration.TypeId, TypeName = plugInType.FullName, PlugInName = plugInAttribute?.Name, PlugInDescription = plugInAttribute?.Description, }; if (plugInPoint != null) { dto.PlugInPointName = plugInPoint.Name; dto.PlugInPointDescription = plugInPoint.Description; } else if (customPlugInContainer != null) { var customPlugInInterface = plugInType.GetInterfaces().FirstOrDefault(intf => intf.GetInterfaces().Any(i => i.GetCustomAttribute <CustomPlugInContainerAttribute>() != null)); dto.PlugInPointName = customPlugInInterface == null ? customPlugInContainer.Name : $"{customPlugInContainer.Name} - {customPlugInInterface.Name}"; dto.PlugInPointDescription = customPlugInContainer.Description; } else { dto.PlugInPointName = "N/A"; dto.PlugInPointDescription = "N/A"; } return(dto); }
public MouldEventArgs(PlugInConfiguration info) { m_PlugInfo = info; }
/// <summary> /// 加载界面图片 /// </summary> private void InitGroup() { try { if (m_ListCaption == null) { m_ListCaption = new List <string>(); } if (m_ListCaption.Count == 0) { m_ListCaption.Add(""); m_ListCaption.Add(""); m_ListCaption.Add(""); } if (m_ListCaption.Count == 1) { m_ListCaption.Add(""); m_ListCaption.Add(""); } if (m_ListCaption.Count == 2) { m_ListCaption.Add(""); } var listModuleTemp0 = from info in m_App.PrivilegeMenu where info.MenuParentCaption.Equals(m_ListCaption[0]) select info; var listModuleTemp1 = from info in m_App.PrivilegeMenu where info.MenuParentCaption.Equals(m_ListCaption[1]) select info; var listModuleTemp2 = from info in m_App.PrivilegeMenu where info.MenuParentCaption.Equals(m_ListCaption[2]) select info; List <PlugInConfiguration> list0 = listModuleTemp0.ToList(); List <PlugInConfiguration> list1 = listModuleTemp1.ToList(); List <PlugInConfiguration> list2 = listModuleTemp2.ToList(); GroupBox GroupBox0 = new GroupBox(); GroupBox GroupBox1 = new GroupBox(); GroupBox GroupBox2 = new GroupBox(); GroupBox0.BackColor = Color.Transparent; GroupBox1.BackColor = Color.Transparent; GroupBox2.BackColor = Color.Transparent; //group.AutoScroll = true; if (list0 != null && list0.Count > 0) { #region 设置GroupBox0 GroupBox0.Text = m_ListCaption[0]; GroupBox0.Font = myFont; for (int i = 0; i < list0.Count; i++) { PlugInConfiguration plugInfo = list0[i]; if (!String.IsNullOrEmpty(plugInfo.IconName)) { plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal); } UCMould moule = new UCMould(plugInfo); moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick; moule.MouldFunClick += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick); GroupBox0.Controls.Add(moule); } SetGroupBox(GroupBox0); #endregion } if (list1 != null && list1.Count > 0) { #region 设置GroupBox1 GroupBox1.Text = m_ListCaption[1]; GroupBox1.Font = myFont; for (int i = 0; i < list1.Count; i++) { PlugInConfiguration plugInfo = list1[i]; if (!String.IsNullOrEmpty(plugInfo.IconName)) { plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal); } UCMould moule = new UCMould(plugInfo); moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick; moule.MouldFunClick += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick); GroupBox1.Controls.Add(moule); } SetGroupBox(GroupBox1); #endregion } if (list2 != null && list2.Count > 0) { #region 设置GroupBox2 GroupBox2.Text = m_ListCaption[2]; GroupBox2.Font = myFont; for (int i = 0; i < list2.Count; i++) { PlugInConfiguration plugInfo = list2[i]; if (!String.IsNullOrEmpty(plugInfo.IconName)) { plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal); } UCMould moule = new UCMould(plugInfo); moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick; moule.MouldFunClick += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick); GroupBox2.Controls.Add(moule); } SetGroupBox(GroupBox2); #endregion } ProcessGroupBox(); } catch (Exception) { throw; } }
/// <summary> /// Initializes a new instance of the <see cref="PlugInConfigurationViewItem"/> class. /// </summary> /// <param name="plugInConfiguration">The plug in configuration.</param> public PlugInConfigurationViewItem(PlugInConfiguration plugInConfiguration) { this.Configuration = plugInConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="PlugInConfigurationChangedEventArgs"/> class. /// </summary> /// <param name="plugInType">Type of the plug in.</param> /// <param name="configuration">The changed configuration.</param> public PlugInConfigurationChangedEventArgs(Type plugInType, PlugInConfiguration configuration) : base(plugInType) { this.Configuration = configuration; }
/// <inheritdoc /> public void PlugInConfigured(Guid plugInId, PlugInConfiguration updatedConfiguration) { this.plugInManager.ConfigurePlugIn(plugInId, updatedConfiguration); }