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


C# ServiceProvider.GetService方法代码示例

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


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

示例1: TestDataPersistence

        public void TestDataPersistence()
        {
            IService srv;
            srv = new GenericSingletonService<IContract, ContractImplementation>();
            ServiceProvider container = new ServiceProvider();
            container.RegisterService<IContract>(srv);

            IContract imp;
            imp = container.GetService<IContract>();
            imp.Name = "asdf";
            Assert.AreEqual("asdf", imp.Name);
            imp = container.GetService<IContract>();
            //verify that the name has persisted.
            Assert.AreEqual("asdf", imp.Name);
        }
开发者ID:SignedUp,项目名称:omni-foundation,代码行数:15,代码来源:GenericSingletonServiceTest.cs

示例2: DocumentProperties

 /// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.DocumentProperties"]/*' />
 protected DocumentProperties(CodeWindowManager mgr) {
     this.mgr = mgr;
     this.visible = true;
     if (mgr != null) {
         IOleServiceProvider sp = mgr.CodeWindow as IOleServiceProvider;
         if (sp != null) {
             ServiceProvider site = new ServiceProvider(sp);
             this.tracker = site.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx;
         }
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:12,代码来源:DocumentProperties.cs

示例3: SelectionListener

        protected SelectionListener(ServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.monSel = serviceProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

            Debug.Assert(this.monSel != null, "Could not get the IVsMonitorSelection object from the services exposed by this project");

            if (this.monSel == null)
            {
                throw new InvalidOperationException();
            }
        }
开发者ID:zooba,项目名称:wix3,代码行数:12,代码来源:selectionlistener.cs

示例4: ProjectDocumentsListener

        protected ProjectDocumentsListener(ServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.projectDocTracker = serviceProvider.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments2;

            Debug.Assert(this.projectDocTracker != null, "Could not get the IVsTrackProjectDocuments2 object from the services exposed by this project");

            if (this.projectDocTracker == null)
            {
                throw new InvalidOperationException();
            }
        }
开发者ID:einaregilsson,项目名称:Process-Language-Runtime,代码行数:12,代码来源:ProjectDocumentsListener.cs

示例5: GetService

        public void GetService()
        {
            SqlServer2000Platform sqlServer2000Platform = new SqlServer2000Platform();

            IServiceProvider serviceProvider = new ServiceProvider();
            serviceProvider.RegisterService(sqlServer2000Platform);

            Assert.AreSame(sqlServer2000Platform, serviceProvider.GetService<IDbPlatform>());
            Assert.AreSame(sqlServer2000Platform, serviceProvider.GetService(typeof(IDbPlatform)));
            Assert.AreSame(sqlServer2000Platform, serviceProvider.GetService<SqlServer2000Platform>());

            serviceProvider.RegisterService(typeof(IDbTypeMapper), delegate { return new SqlServer2000TypeMapper(); });

            IDbTypeMapper dbTypeMapper = serviceProvider.GetService<IDbTypeMapper>();
            Assert.IsNotNull(dbTypeMapper);
            Assert.AreNotSame(dbTypeMapper, serviceProvider.GetService<IDbTypeMapper>());

            serviceProvider.RegisterService<IDbNamingStrategy>(delegate { return new SqlServer2000NamingStrategy(); });

            IDbNamingStrategy dbNamingStrategy = serviceProvider.GetService<IDbNamingStrategy>();
            Assert.IsNotNull(dbNamingStrategy);
            Assert.AreNotSame(dbNamingStrategy, serviceProvider.GetService<IDbNamingStrategy>());
        }
开发者ID:hoonsbara,项目名称:octalforty-wizardby,代码行数:23,代码来源:ServiceProviderTestFixture.cs

示例6: TestBase

        protected TestBase ()
        {
            mServiceProvider = ServiceProvider.Instance;
            SqlHelper.InitDatabase();
            LoginService = mServiceProvider.GetService<IWcfLoginService>();
            SystemService = mServiceProvider.GetService<IWcfSystemService>();
            DianpuService = mServiceProvider.GetService<IWcfDianpuService>();
            BiaoService = mServiceProvider.GetService<IWcfBiaoService>();
            HelpService = mServiceProvider.GetService<IWcfHelpService>();
            FuwuqiService = mServiceProvider.GetService<IWcfFuwuqiService>();
            JubenService = mServiceProvider.GetService<IWcfJubenService>();
            XiakeService = mServiceProvider.GetService<IWcfXiakeService>();
            GonggaoService = mServiceProvider.GetService<IWcfGonggaoService>();
            BiaoshiService = mServiceProvider.GetService<IWcfBiaoshiService>();
            ChargeService = mServiceProvider.GetService<IWcfChargeService>();
            ValidationService = mServiceProvider.GetService<IWcfValidationService>();
            DingdanService = mServiceProvider.GetService<IWcfDingdanService>();
            RenwuService = mServiceProvider.GetService<IWcfRenwuService>();
            PayService = mServiceProvider.GetService<IWcfPayService>();

            InviteIncomeController = mServiceProvider.GetService<InviteIncomeController>();
            RenwuHandleController = mServiceProvider.GetService<RenwuHandleController>();
            PayHandleController = mServiceProvider.GetService<PayHandleController>();
        }
开发者ID:powerhai,项目名称:Jinchen,代码行数:24,代码来源:TestBase.cs

示例7: Setup

 public void Setup()
 {
     ServiceProvider provider = new ServiceProvider();
     queryBuilder = (IWikiQueryBuilder)provider.GetService(typeof(IWikiQueryBuilder));
 }
开发者ID:ianchute,项目名称:OWiki,代码行数:5,代码来源:E2ETests.cs

示例8: GetService

 //
 // Summary:
 //     Returns an object that represents a service provided by the System.ComponentModel.Component
 //     or by its System.ComponentModel.Container.
 //
 // Parameters:
 //   service:
 //     A service provided by the System.ComponentModel.Component.
 //
 // Returns:
 //     An System.Object that represents a service provided by the System.ComponentModel.Component,
 //     or null if the System.ComponentModel.Component does not provide the specified
 //     service.
 protected override object GetService(Type service)
 {
     if (_vsServiceProvider != null)
     {
         ServiceProvider sp = new ServiceProvider(_vsServiceProvider);
         return sp.GetService(service);
     }
     return null;
 }
开发者ID:biegomar,项目名称:nuodb-dotnet,代码行数:22,代码来源:SQLEditor.cs

示例9: GetCodeWindowManager

        // GetCodeWindowManager -- this gives us the VsCodeWindow which is what we need to
        // add adornments and so forth.
        /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.GetCodeWindowManager"]/*' />
        public int GetCodeWindowManager(IVsCodeWindow codeWindow, out IVsCodeWindowManager mgr)
        {
            //set the inheritKeyBinding guid so that navigation keys work. Do this before deriving class's
            //CreateCodeWindowManager method gets called, so they may override if required
            IOleServiceProvider sp = codeWindow as IOleServiceProvider;
            if (sp != null) {
                ServiceProvider site = new ServiceProvider(sp);
                object window = site.GetService(typeof(IVsWindowFrame).GUID);
                if (window is IVsWindowFrame) {
                    IVsWindowFrame frame = (IVsWindowFrame)window;
                    Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2);
                    NativeMethods.ThrowOnFailure(frame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref CMDUIGUID_TextEditor));
                }
            }

            Initialize();
            IVsTextLines buffer = null;
            NativeMethods.ThrowOnFailure(codeWindow.GetBuffer(out buffer));
            mgr = CreateCodeWindowManager(codeWindow, GetOrCreateSource(buffer));
            return NativeMethods.S_OK;
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:24,代码来源:LanguageService.cs


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