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


C# IServiceContainer.GetService方法代码示例

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


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

示例1: UndoEngineImplication

 public UndoEngineImplication(IServiceContainer provider)
     : base(provider)
 {
     service = provider;
     editToolStripMenuItem = (ToolStripMenuItem)service.GetService(typeof(ToolStripMenuItem));
     cassPropertyGrid = (FilteredPropertyGrid)service.GetService(typeof(FilteredPropertyGrid));
 }
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:7,代码来源:UndoEngineImplication.cs

示例2: VerifyOncePerRequest

        private static bool VerifyOncePerRequest(string serviceName, IServiceContainer container)
        {
            // The container must be able to create an
            // ISampleService instance
            Assert.IsTrue(container.Contains(serviceName, typeof(ISampleService)), "Service not found!");

            // Both instances must be unique
            var first = container.GetService<ISampleService>(serviceName);
            var second = container.GetService<ISampleService>(serviceName);
            Assert.AreNotSame(first, second, "The two instances returned from the container must be unique!");

            return true;
        }
开发者ID:sdether,项目名称:LinFu,代码行数:13,代码来源:FluentExtensionTests.Implementation.cs

示例3: PluginManager

        /// <summary>
        /// Initializes a new instance of the <see cref="PluginManager"/> class.
        /// </summary>
        /// <param name="serviceContainer">The service container.</param>
        public PluginManager(IServiceContainer serviceContainer)
        {
            if (serviceContainer == null) throw new ArgumentNullException("serviceContainer");
            services = serviceContainer;

            settingsService = services.GetService<ISettingsService>(true);
        }
开发者ID:odalet,项目名称:CITray,代码行数:11,代码来源:PluginManager.cs

示例4: GitStatusBarManager

        protected GitStatusBarManager(Guid commandSetGuid, int branchMenuCmId, int branchCommandMenuCmId, int repositoryCommandMenuCmId,  IServiceContainer serviceProvider, IStatusBarService statusBarService)
        {
            BranchMenuCmId = branchMenuCmId;
            BranchCommandMenuCmId = branchCommandMenuCmId;
            RepositoryCommandMenuCmId = repositoryCommandMenuCmId;
            StatusBarService = statusBarService;
            CommandSetGuid = commandSetGuid;
            _menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
            _serviceProvider = serviceProvider;
            _branchCommandMenuCommands = new List<Tuple<string, MenuCommand>>();

        }
开发者ID:Frrank1,项目名称:Git-Source-Control-Provider,代码行数:12,代码来源:GitStatusBarManager.cs

示例5: DefaultRailsEngineContext

		/// <summary>
		/// Initializes a new instance of the <see cref="DefaultRailsEngineContext"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="urlInfo">Url information</param>
		/// <param name="context">The context.</param>
		/// <param name="container">External container instance</param>
		public DefaultRailsEngineContext(IServiceContainer parent, UrlInfo urlInfo,
										 HttpContext context, IServiceProvider container)
			: base(parent)
		{
			_urlInfo = urlInfo;
			_context = context;
			_request = new RequestAdapter(context.Request);
			_trace = new TraceAdapter(context.Trace);
			_server = new ServerUtilityAdapter(context.Server);
			_response = new ResponseAdapter(context.Response, this, ApplicationPath);
			_url = _context.Request.RawUrl;
			_cache = parent.GetService(typeof(ICacheProvider)) as ICacheProvider;
			this.container = container;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:21,代码来源:DefaultRailsEngineContext.cs

示例6: Get

 public static MenuCreationServiceContainer Get(IServiceContainer serviceContainer)
 {
     var current = serviceContainer.GetService<IMenuCreationService>();
     var r = current as MenuCreationServiceContainer;
     if (r == null)
     {
         r = new MenuCreationServiceContainer();
         if (current != null)
         {
             r.Add(current);
             serviceContainer.RemoveService(typeof(IMenuCreationService));
         }
         serviceContainer.AddService(typeof(IMenuCreationService), r);
     }
     return r;
 }
开发者ID:gitter-badger,项目名称:DevExpressMods,代码行数:16,代码来源:MenuCreationServiceContainer.cs

示例7: ResolveFrom

        /// <summary>
        /// Generates method arguments from the given <paramref name="parameterTypes"/>
        /// and <paramref name="container"/>.
        /// </summary>
        /// <param name="parameterTypes">The parameter types for the target method.</param>
        /// <param name="container">The container that will provide the method arguments.</param>
        /// <param name="additionalArguments">The additional arguments that will be passed to the target method.</param>
        /// <returns>An array of objects that represent the arguments to be passed to the target method.</returns>
        public object[] ResolveFrom(IEnumerable<Type> parameterTypes, IServiceContainer container, params object[] additionalArguments)
        {
            var enumerableDefinition = typeof(IEnumerable<>);

            var argumentList = new List<object>();
            foreach (var parameterType in parameterTypes)
            {
                // Substitute the parameter if and only if
                // the container does not have service that
                // that matches the parameter type
                var parameterTypeExists = container.Contains(parameterType);

                if (parameterTypeExists)
                {
                    // Instantiate the service type and build
                    // the argument list
                    object currentArgument = container.GetService(parameterType);
                    argumentList.Add(currentArgument);
                    continue;
                }

                // Determine if the parameter type is an IEnumerable<T> type
                // and generate the list if necessary
                if (parameterType.IsGenericType &&
                    parameterType.GetGenericTypeDefinition() == enumerableDefinition)
                {
                    AddEnumerableArgument(parameterType, container, argumentList);
                    continue;
                }

                if (!parameterType.IsArray)
                    continue;

                // Determine if the parameter type is an array
                // of existing services and inject the current
                // set of services as a parameter value
                AddArrayArgument(parameterType, container, argumentList);
            }

            // Append the existing arguments
            if (additionalArguments != null && additionalArguments.Length > 0)
                argumentList.AddRange(additionalArguments);

            return argumentList.ToArray();
        }
开发者ID:slieser,项目名称:LinFu,代码行数:53,代码来源:ArgumentResolver.cs

示例8: VerifyOncePerThread

        private static bool VerifyOncePerThread(string serviceName, IServiceContainer container)
        {
            var results = new List<ISampleService>();
            Func<ISampleService> createService = () =>
            {
                var result = container.GetService<ISampleService>(serviceName);
                lock (results)
                {
                    results.Add(result);
                }

                return null;
            };

            Assert.IsTrue(container.Contains(serviceName, typeof(ISampleService)));

            // Create the other instance from another thread
            var asyncResult = createService.BeginInvoke(null, null);

            // Two instances created within the same thread must be
            // the same
            var first = container.GetService<ISampleService>(serviceName);
            var second = container.GetService<ISampleService>(serviceName);

            Assert.IsNotNull(first);
            Assert.AreSame(first, second);

            // Wait for the other thread to finish executing
            createService.EndInvoke(asyncResult);
            Assert.IsTrue(results.Count > 0);

            // The service instance created in the other thread
            // must be unique
            Assert.IsNotNull(results[0]);
            Assert.AreNotSame(first, results[0]);

            // NOTE: The return value will be ignored
            return true;
        }
开发者ID:sdether,项目名称:LinFu,代码行数:39,代码来源:FluentExtensionTests.Implementation.cs

示例9: Stop

        internal static void Stop(IServiceContainer container)
        {
            var service = container.GetService(typeof(BooLanguageService))
                                      as BooLanguageService;
            if (service == null || service.mComponentId == 0)
                return;

            var mgr = container.GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;
            if (mgr != null)
            {
                mgr.FRevokeComponent(service.mComponentId);
            }
            service.mComponentId = 0;
        }
开发者ID:Rfvgyhn,项目名称:Boo-Plugin,代码行数:15,代码来源:BooLanguageService.cs

示例10: Initialize

 /// <summary>
 /// Initializes the class with the <paramref name="source"/> container.
 /// </summary>
 /// <param name="source">The <see cref="IServiceContainer"/> instance that will create the class instance.</param>
 public virtual void Initialize(IServiceContainer source)
 {
     Emitter = (IMethodBodyEmitter) source.GetService(typeof (IMethodBodyEmitter));
 }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:8,代码来源:ProxyMethodBuilder.cs

示例11: InitializeSurface

		private void InitializeSurface ()
		{
			DesignSurface surface = new DesignSurfaceManager ().CreateDesignSurface ();

			surface.BeginLoad (typeof (MyForm));
			this._panelDesignerView.Controls.Add ((Control)surface.View);
			((Control)surface.View).Dock = DockStyle.Fill;
			this.serviceContainer = surface.GetService (typeof (IServiceContainer)) as IServiceContainer;
			serviceContainer.AddService (typeof (IToolboxService), _toolbox);

			ISelectionService s = (ISelectionService)serviceContainer.GetService (typeof (ISelectionService));
			s.SelectionChanged += new EventHandler (OnSelectionChanged);

			PopulateToolbox (_toolbox);
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:15,代码来源:frmMain.cs

示例12: Initialize

 /// <summary>
 /// Initializes the current instance
 /// with the <paramref name="source"/> container.
 /// </summary>
 /// <param name="source">The <see cref="IServiceContainer"/> instance that will hold the current instance.</param>
 public void Initialize(IServiceContainer source)
 {
     ProxyImplementor = (ITypeBuilder) source.GetService("ProxyImplementor", typeof (ITypeBuilder));
     MethodPicker = (IMethodPicker) source.GetService(typeof (IMethodPicker));
     ProxyMethodBuilder = (IMethodBuilder) source.GetService("ProxyMethodBuilder", typeof (IMethodBuilder));
 }
开发者ID:philiplaureano,项目名称:LinFu,代码行数:11,代码来源:ProxyBuilder.cs

示例13: Initialize

 public void Initialize(IServiceContainer container)
 {
     _engine = container.GetService<IEngine>();
     _person = container.GetService<IPerson>();
 }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:5,代码来源:Car.cs

示例14: OnCreateLuaLanguageService

 /// <summary>
 /// 
 /// </summary>
 /// <param name="container"></param>
 /// <param name="serviceType"></param>
 /// <returns></returns>
 private static ILuaLanguageService OnCreateLuaLanguageService(IServiceContainer container, Type serviceType)
 {
     if (serviceType == typeof(ILuaLanguageService))
         return container.GetService(typeof(LanguageService)) as ILuaLanguageService;
     return null;
 }
开发者ID:jda808,项目名称:NPL,代码行数:12,代码来源:NPLLanguageServicePackage.cs

示例15: Initialize

 public void Initialize(IServiceContainer source)
 {
     _createAdapterType = source.GetService<ITypeBuilder>("CreateAdapterType");
 }
开发者ID:philiplaureano,项目名称:Taiji,代码行数:4,代码来源:AdapterBuilder.cs


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