差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| appendix:他プラグイン [2022/01/17 16:04] fumble | appendix:他プラグイン [2022/03/05 16:07] (現在) fumble | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| =====他プラグインの存在確認方法===== | =====他プラグインの存在確認方法===== | ||
| 汎用的に行うならばアセンブリを列挙して探す。 | 汎用的に行うならばアセンブリを列挙して探す。 | ||
| - | < | + | < | 
| AppDomain.CurrentDomain.GetAssemblies() | AppDomain.CurrentDomain.GetAssemblies() | ||
| + | </ | ||
| + | |||
| + | ????? | ||
| + | <code csharp> | ||
| + | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) | ||
| + | { | ||
| + | if (String.IsNullOrEmpty(assembly.Location)) | ||
| + | continue; | ||
| + | foreach (var type in assembly.GetTypes()) | ||
| + | { | ||
| + | // プラグイン名を取る | ||
| + | var attributesName = type.GetCustomAttributes(typeof(PluginNameAttribute), | ||
| + | if (attributesName != null && attributesName.Count() != 0) | ||
| + | { | ||
| + | // プラグインっぽいのでバージョンも取る | ||
| + | var attributesVertion = type.GetCustomAttributes(typeof(PluginVersionAttribute), | ||
| + | } | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
| 連携用にインターフェースがあるものは、それを使えば・・・\\ | 連携用にインターフェースがあるものは、それを使えば・・・\\ | ||