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


C# IServiceLocator.Expect方法代码示例

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


在下文中一共展示了IServiceLocator.Expect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public void Setup()
        {
            if (File.Exists(_databasePath))
                File.Delete(_databasePath);

            //Configure Db4o to cascade updates on Order and Customer entities. (Since they are our Aggregate Roots)
            var configuration = Db4oFactory.Configure();
            configuration.ObjectClass(typeof (Order)).CascadeOnUpdate(true);
            configuration.ObjectClass(typeof (Customer)).CascadeOnDelete(true);

            _db4oServer = Db4oFactory.OpenServer(_databasePath, 0);
            Db4oUnitOfWorkFactory.SetContainerProvider(() => _db4oServer.OpenClient());
            _mockLocator = MockRepository.GenerateMock<IServiceLocator>();
            _mockLocator.Expect(x => x.GetInstance<IUnitOfWorkFactory>())
                .Return(new Db4oUnitOfWorkFactory())
                .Repeat.Any();
            ServiceLocator.SetLocatorProvider(() => _mockLocator);
        }
开发者ID:Chris-Kim,项目名称:ncommon,代码行数:18,代码来源:Db4oRepositoryTests.cs

示例2: ExtendedTester

        public ExtendedTester()
        {
            var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");

            var pathApp = Path.Combine(testRoot, "App");
            var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
            var pathPackage2 = Path.Combine(testRoot, "Package2");

            var allTemplates = new TemplateRegistry<IRazorTemplate>();

            var razorSettings = new RazorEngineSettings();
            var razorSet = razorSettings.Search;

            new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet)
                .Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet)
                .Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet)))
                .Each(x =>
                {
                    if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) return;
                    allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance));
                });

            var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>();
            allTemplates.Each(x =>
            {
                viewPathPolicy.Apply(x);
                x.Descriptor = new ViewDescriptor<IRazorTemplate>(x);
            });

            var commonNamespaces = new CommonViewNamespaces();
            commonNamespaces.AddForType<string>();
            _templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator());

            _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost());

            _serviceLocator = MockRepository.GenerateMock<IServiceLocator>();

            var sharingGraph = new SharingGraph();
            sharingGraph.Dependency("Package1", ContentFolder.Application);
            sharingGraph.Dependency("Package2", ContentFolder.Application);
            var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates,
                                                                                  sharingGraph);
            _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates,
                                                                               new RazorTemplateSelector());

            var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory);
            _serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof (IPartialRenderer)))).Return(partialRenderer);
            _serviceLocator.Expect(x => x.GetInstance(typeof (IOutputWriter))).Return(MockRepository.GenerateMock<IOutputWriter>());
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.ViewEngines,代码行数:51,代码来源:ExtendedTester.cs


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