Pluginの実装2
Pluginについて、アセンブリの中からPluginの実装情報を取得する必要があります。
取得した情報を格納するクラスについてはこんなカンジです。
[Serializable] public class WidgetPlugin { private string location; private string className; private string name; private string version; private string description; public string Location { get { return( this.location ); } } public string ClassName { get { return ( this.className ); } } public string Name { get { return( this.name ); } } public string Version { get { return( this.version ); } } public string Description { get { return( this.description ); } } private WidgetPlugin(string location, string className, string name, string version, string description) { this.location = location; this.className = className; this.name = name; this.version = version; this.description = description; } public override bool Equals(object obj) { if ( object.ReferenceEquals( this, obj ) ) { return( true ); } WidgetPlugin other = obj as WidgetPlugin; if ( other == null ) { return( false ); } return( ( this.location == other.location ) && ( this.className == other.className ) ); } public override int GetHashCode() { return( this.location.GetHashCode() + this.className.GetHashCode() ); } ...
そして、次はアセンブリからIWidgetの実装クラスを検索し、このWidgetPluginクラスを作成する部分になります。