本文整理汇总了C#中Loader.LoadDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# Loader.LoadDirectory方法的具体用法?C# Loader.LoadDirectory怎么用?C# Loader.LoadDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader.LoadDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClassMarkedWithPreprocessorAttributeMustBeInjectedIntoContainer
public void ClassMarkedWithPreprocessorAttributeMustBeInjectedIntoContainer()
{
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var loader = new Loader();
loader.LoadDirectory(baseDirectory, "*.dll");
var container = new ServiceContainer();
loader.LoadInto(container);
IEnumerable<IPreProcessor> matches = from p in container.PreProcessors
where p != null &&
p.GetType() == typeof(SamplePreprocessor)
select p;
Assert.IsTrue(matches.Count() > 0, "The preprocessor failed to load.");
}
示例2: CreatedServicesMustBeAbleToInitializeThemselves
public void CreatedServicesMustBeAbleToInitializeThemselves()
{
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var loader = new Loader();
loader.LoadDirectory(baseDirectory, "*.dll");
var mockInitialize = new Mock<IInitialize>();
var container = new ServiceContainer();
// The service container should call the Initialize method
mockInitialize.Expect(target => target.Initialize(container));
loader.LoadInto(container);
container.AddService(mockInitialize.Object);
var result = container.GetService<IInitialize>();
Assert.IsNotNull(result);
Assert.AreSame(mockInitialize.Object, result);
mockInitialize.VerifyAll();
}
示例3: OnInit
protected override void OnInit()
{
if (File.Exists(filename))
File.Delete(filename);
// Initialize the loader
// with all of the default LinFu plugins
loader = new Loader();
container = new ServiceContainer();
filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}.dll", Guid.NewGuid().ToString()));
AutoDelete(filename);
loader.LoadDirectory(AppDomain.CurrentDomain.BaseDirectory, "LinFu*.dll");
loader.LoadInto(container);
}
示例4: LoaderMustSignalToPluginsWhenTheLoadBeginsAndEnds
public void LoaderMustSignalToPluginsWhenTheLoadBeginsAndEnds()
{
var mockPlugin = new Mock<ILoaderPlugin<IServiceContainer>>();
var container = new Mock<IServiceContainer>();
var mockListing = new Mock<IDirectoryListing>();
var loader = new Loader<IServiceContainer>();
// Setup the directory listing and
// return an empty listing since
// we're only interested in the plugin behavior
mockListing.Expect(listing => listing.GetFiles(It.IsAny<string>(), string.Empty))
.Returns(new string[0]);
// Initialize the loader
loader.DirectoryLister = mockListing.Object;
loader.Plugins.Add(mockPlugin.Object);
// Both the BeginLoad and EndLoad methods should be called
mockPlugin.Expect(p => p.BeginLoad(container.Object));
mockPlugin.Expect(p => p.EndLoad(container.Object));
// Execute the loader
loader.LoadDirectory(string.Empty, string.Empty);
loader.LoadInto(container.Object);
mockPlugin.VerifyAll();
mockListing.VerifyAll();
}
示例5: LoaderMustPassFilenameToContainerLoaders
public void LoaderMustPassFilenameToContainerLoaders()
{
var mockContainer = new Mock<IServiceContainer>();
var mockLoader = new Mock<IContainerLoader>(MockBehavior.Loose);
var mockListing = new Mock<IDirectoryListing>();
var loader = new Loader<IServiceContainer>()
{
DirectoryLister = mockListing.Object
};
string filename = "input.dll";
mockListing.Expect(listing => listing.GetFiles(It.IsAny<string>(), filename))
.Returns(new[] {filename});
loader.FileLoaders.Add(mockLoader.Object);
// The container should call the load method
// with the given filename
string path = string.Empty;
var emptyActions = new Action<IServiceContainer>[] {};
mockLoader.Expect(l => l.CanLoad(filename)).Returns(true);
mockLoader.Expect(l => l.Load(filename)).Returns(emptyActions);
loader.LoadDirectory(path, filename);
loader.LoadInto(mockContainer.Object);
mockLoader.VerifyAll();
mockListing.VerifyAll();
}