当前位置: 首页>>代码示例>>C#>>正文


C# Loader.LoadInto方法代码示例

本文整理汇总了C#中Loader.LoadInto方法的典型用法代码示例。如果您正苦于以下问题:C# Loader.LoadInto方法的具体用法?C# Loader.LoadInto怎么用?C# Loader.LoadInto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Loader的用法示例。


在下文中一共展示了Loader.LoadInto方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
        }
开发者ID:sdether,项目名称:LinFu,代码行数:16,代码来源:ConfigurationTests.cs

示例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();
        }
开发者ID:sdether,项目名称:LinFu,代码行数:21,代码来源:ConfigurationTests.cs

示例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);
        }
开发者ID:slieser,项目名称:LinFu,代码行数:15,代码来源:ReflectionEmitTests.cs

示例4: LoaderMustCallCustomLoaderActions

        public void LoaderMustCallCustomLoaderActions()
        {
            var mockContainer = new Mock<IServiceContainer>();
            var mockListing = new Mock<IDirectoryListing>();

            var loader = new Loader<IServiceContainer>();
            loader.DirectoryLister = mockListing.Object;

            // Return an empty file listing
            mockListing.Expect(listing => listing.GetFiles(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new string[0]);

            // Use the initializer mock to verify
            // that the custom action was called

            var mockInitializer = new Mock<IInitialize>();
            mockInitializer.Expect(initializer => initializer.Initialize(mockContainer.Object));

            // HACK: In order to verify the call,
            // we need to adapt the mock to an
            // Action<ILoader<IServiceContainer>> instance
            Action<ILoader<IServiceContainer>> customAction =
                targetLoader =>
                    {
                        IInitialize initializer = mockInitializer.Object;
                        IServiceContainer container = mockContainer.Object;

                        // The test will only succeed if
                        // the following line of code
                        // is invoked:
                        initializer.Initialize(container);
                    };

            loader.CustomLoaderActions.Add(customAction);
            loader.LoadInto(mockContainer.Object);

            mockInitializer.VerifyAll();
        }
开发者ID:sdether,项目名称:LinFu,代码行数:38,代码来源:ConfigurationTests.cs

示例5: 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();
        }
开发者ID:sdether,项目名称:LinFu,代码行数:28,代码来源:ConfigurationTests.cs

示例6: 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();
        }
开发者ID:sdether,项目名称:LinFu,代码行数:30,代码来源:ConfigurationTests.cs


注:本文中的Loader.LoadInto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。