本文整理汇总了C#中LinFu.IoC.ServiceContainer.AutoLoadFrom方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer.AutoLoadFrom方法的具体用法?C# ServiceContainer.AutoLoadFrom怎么用?C# ServiceContainer.AutoLoadFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinFu.IoC.ServiceContainer
的用法示例。
在下文中一共展示了ServiceContainer.AutoLoadFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldLoadAssemblyIntoLoaderAtRuntime
public void ShouldLoadAssemblyIntoLoaderAtRuntime()
{
string path = Path.Combine(@"..\..\..\SampleFileWatcherLibrary\bin\Debug",
AppDomain.CurrentDomain.BaseDirectory);
string targetFile = "SampleFileWatcherLibrary.dll";
string sourceFileName = Path.Combine(path, targetFile);
var container = new ServiceContainer();
container.AutoLoadFrom(AppDomain.CurrentDomain.BaseDirectory, "dummy.dll");
// There should be nothing loaded at this point since the assembly hasn't
// been copied to the target directory yet
Assert.IsFalse(container.Contains(typeof (ISampleService)));
// Copy the assembly to the target directory
// and watch for changes
string targetFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dummy.dll");
File.Copy(sourceFileName, targetFileName, true);
// Give the watcher thread enough time to load the assembly into memory
Thread.Sleep(500);
Assert.IsTrue(container.Contains(typeof (ISampleService)));
var instance = container.GetService<ISampleService>();
Assert.IsNotNull(instance);
string typeName = instance.GetType().Name;
Assert.AreEqual("SampleFileWatcherServiceClassAddedAtRuntime", typeName);
}