我在类库中有以下代码:
public class Manager
{
private static readonly Manager instance = new Manager();
public static IHelper Helper { get { return Manager.instance.helper; } }
[Import(typeof(IHelper))]
internal IHelper helper { get; set; }
private Manager()
{
using (DirectoryCatalog catalog =new DirectoryCatalog(@"c:\Dev\Plugins"))
{
CompositionContainer container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
}
}
我正在使用上面的类在运行时设置自定义用户界面设置,构造函数会在我每次访问成员时运行(它会扫描目录)吗?
一个示例调用可能是lblMask.Text = Helper.SearchMask;