Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT: I've updated the answer with some more detailed information.</strong></p> <p>Here is an example how you might accomplish what you want to do.<br> Start by defining a enum for your different types of plugin types.</p> <pre><code>public enum AssemblyPluginType { Skins, Browser } </code></pre> <p>Add two attributes that will be used to describe the plugins (assembly plugin type and potential conflicts).</p> <pre><code>[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class AssemblyPluginAttribute : Attribute { private readonly AssemblyPluginType _type; public AssemblyPluginType PluginType { get { return _type; } } public AssemblyPluginAttribute(AssemblyPluginType type) { _type = type; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class AssemblyPluginConflictAttribute : Attribute { private readonly AssemblyPluginType[] _conflicts; public AssemblyPluginType[] Conflicts { get { return _conflicts; } } public AssemblyPluginConflictAttribute(params AssemblyPluginType[] conflicts) { _conflicts = conflicts; } } </code></pre> <p>Now you can add these attributes to your assembly.</p> <p>The following two lines can be added anywhere in the assembly as long as they're outside a namespace. I usually put assembly attributes in the <code>AssemblyInfo.cs</code> file that can be found in the <code>Properties</code> folder.</p> <pre><code>[assembly: AssemblyPluginAttribute(AssemblyPluginType.Browser)] [assembly: AssemblyPluginConflictAttribute(AssemblyPluginType.Skins, AssemblyPluginType.Browser)] </code></pre> <p>Now you can use the following code to examine an assembly for specific attributes:</p> <pre><code>using System; using System.Reflection; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { // Get the assembly we're going to check for attributes. // You will want to load the assemblies you want to check at runtime. Assembly assembly = typeof(Program).Assembly; // Get all assembly plugin attributes that the assembly contains. object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyPluginAttribute), false); if (attributes.Length == 1) { // Cast the attribute and get the assembly plugin type from it. var attribute = attributes[0] as AssemblyPluginAttribute; AssemblyPluginType pluginType = attribute.PluginType; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload