/// <summary>Enumerate the types that implement the interface 'TInterface'</summary> public static IEnumerable <PluginFile> Enumerate(Assembly ass) { foreach (var type in ass.GetExportedTypes()) { var attr = type.FindAttribute <PluginAttribute>(false); if (attr == null || attr.Interface != typeof(TInterface)) { continue; } // Return the type that implements the interface var fd = new FileInfo(ass.Location); yield return(new PluginFile(Path_.FileTitle(fd.Name), type, ass, fd, attr.Unique)); } }
/// <summary>Load an instance of each type that implements the interface 'TInterface' in 'ass'</summary> public Plugins <TInterface> Load(Assembly ass, object[]?args = null, Func <Type, object[]?, TInterface>?factory = null) { foreach (var type in ass.GetExportedTypes()) { var attr = type.FindAttribute <PluginAttribute>(false); if (attr == null || attr.Interface != typeof(TInterface)) { continue; } // Return the type that implements the interface Load(Path_.FileTitle(ass.Location), type, args, factory); } return(this); }
/// <summary>Load a pattern set from file</summary> public static PatternSet Load(string filepath) { if (!Path_.FileExists(filepath)) { throw new Exception($"Pattern set file '{filepath}' does not exist"); } var root = XDocument.Load(filepath).Root; if (root == null) { throw new Exception("Pattern set has no root xml node"); } return(new PatternSet(root) { Name = Path_.FileTitle(filepath) }); }
public XmlTree(string filename) : this() { AllowUserToAddRows = false; AllowUserToDeleteRows = false; AllowUserToResizeRows = true; AllowUserToOrderColumns = false; RowHeadersVisible = false; ColumnHeadersVisible = true; GridColor = SystemColors.ControlLight; AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; SelectionMode = DataGridViewSelectionMode.FullRowSelect; ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; RowTemplate.Height = 20; XmlName = Path_.FileTitle(filename); DockControl = new DockControl(this, $"XmlFile-{XmlName}") { TabText = XmlName, TabCMenu = new ContextMenuStrip() }; DockControl.TabCMenu.Items.Add2("Close", null, (s, a) => Dispose()); Root = XDocument.Load(filename).Root; }