Summary
The downloadable solution contains three projects: AuthenticationPlugin.Common, AuthenticationPlugin.Plugins.MyTest, and AuthenticationPlugin.UI.UITester. The AuthenticationPlugin.Common project contains the IAuthenticationPlugin interface and the AuthenticationPluginAttribute, which are used to develop new plug-ins and call them with other applications. The AuthenticationPlugin.Plugins.MyTest project contains a very simple plug-in. The AuthenticationPlugin.UI.UITester project contains a Windows application that can be run to visually test the plug-in.
Some of the concepts that were reviewed in this article are the use of interfaces, inheritance, and reflection.
The basic steps that were followed to create the solution were:
- Create a common project with an interface and an attribute class which will be used by the plug-ins and applications to define, load, and call the plug-ins.
- Create a plug-in by adding a new project that will compile to its own .NET assembly. This project will refer to the common project. The implementation class implements the interface and is identified by an attribute. The attribute is metadata that is used in reflection later to know which class, or type, to load and use.
- Create an application that uses the .NET reflection classes Assembly and Activator to load the assembly, find the implementation class, and run the correct method.
The downloadable solution contains the three projects and code that demonstrates these concepts.
The next article in this series will cover what happens when one of these plug-ins requires its own configuration, and will also cover authenticating users against an XML file.