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


C# IServiceProvider.Stub方法代码示例

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


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

示例1: Setup

 public void Setup()
 {
     mr = new MockRepository();
     this.services = mr.Stub<IServiceProvider>();
     var tlSvc = new TypeLibraryLoaderServiceImpl(services);
     var configSvc = mr.StrictMock<IConfigurationService>();
     var fsSvc = new FileSystemServiceImpl();
     var win32env = new OperatingEnvironmentElement
     {
         TypeLibraries = 
         {
             new TypeLibraryElement {  Name= "msvcrt.xml" },
             new TypeLibraryElement {  Name= "windows32.xml" },
         }
     };
     configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
     configSvc.Stub(c => c.GetInstallationRelativePath(null)).IgnoreArguments()
         .Do(new Func<string, string>(s => s));
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
     services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(new FakeDecompilerEventListener());
     services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null);
     services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(new FileSystemServiceImpl());
     services.Replay();
     configSvc.Replay();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     win32 = new Reko.Environments.Windows.Win32Platform(services, arch);
 }
开发者ID:gitter-badger,项目名称:reko,代码行数:28,代码来源:Rewrite32.cs

示例2: AddServiceToFakeServiceProvider

		void AddServiceToFakeServiceProvider(IServiceProvider serviceProvider, Type serviceType, object service)
		{
			serviceProvider
				.Stub(provider => provider.GetService(serviceType))
				.Return(service);
		}
开发者ID:Netring,项目名称:SharpDevelop,代码行数:6,代码来源:TextTemplatingServiceProviderTests.cs

示例3: Setup

 public void Setup()
 {
     mr = new MockRepository();
     this.services = mr.Stub<IServiceProvider>();
     var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
     var configSvc = mr.StrictMock<IConfigurationService>();
     var win32env = new OperatingEnvironmentElement
     {
         TypeLibraries =
         {
             new TypeLibraryElement {  Name= "msvcrt.xml" },
             new TypeLibraryElement {  Name= "windows32.xml" },
         }
     };
     configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
     configSvc.Stub(c => c.GetPath(null)).IgnoreArguments()
         .Do(new Func<string, string>(s => s));
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
     services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(new FakeDecompilerEventListener());
     services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null);
     tlSvc.Stub(t => t.LoadLibrary(null, null)).IgnoreArguments()
         .Do(new Func<Platform, string, TypeLibrary>((p, n) =>
         {
             var lib = TypeLibrary.Load(p, Path.ChangeExtension(n, ".xml"));
             return lib;
         }));
     services.Replay();
     tlSvc.Replay();
     configSvc.Replay();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     win32 = new Reko.Environments.Windows.Win32Platform(services, arch);
 }
开发者ID:nemerle,项目名称:reko,代码行数:33,代码来源:Rewrite32.cs

示例4: AddServiceObjectToReturnFromServiceProvider

 void AddServiceObjectToReturnFromServiceProvider(IServiceProvider serviceProvider, Type type, object objectToReturn)
 {
     serviceProvider.Stub(provider => provider.GetService(type)).Return(objectToReturn);
 }
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:4,代码来源:CustomTextTemplatingServiceProvidersTests.cs

示例5: Setup

 public void Setup()
 {
     this.mr = new MockRepository();
     this.arch = mr.Stub<IProcessorArchitecture>();
     this.services = mr.Stub<IServiceProvider>();
     this.dcSvc = mr.Stub<IConfigurationService>();
     this.tlSvc = mr.Stub<ITypeLibraryLoaderService>(); 
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(dcSvc);
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     dcSvc.Stub(d => d.GetArchitecture("x86-protected-32")).Return(arch);
     dcSvc.Stub(d => d.GetEnvironment("elf-neutral")).Return(new OperatingEnvironmentElement
         {
             TypeName = typeof(SysVPlatform).AssemblyQualifiedName
         });
 }
开发者ID:killbug2004,项目名称:reko,代码行数:15,代码来源:ElfImageLoaderTests.cs


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