• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IServiceLocator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetInstance

 /// <summary>
 /// Get IServiceLocator instace.
 /// </summary>
 /// <returns></returns>
 public static IServiceLocator GetInstance()
 {
     if (singletonServiceLocator == null) {
         singletonServiceLocator = new AbstractServiceLocator ();
     }
     return singletonServiceLocator;
 }
开发者ID:jioe,项目名称:appverse-mobile,代码行数:11,代码来源:AbstractServiceLocator.cs


示例2: ServiceLocatorAutoRegistrationManager

        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceLocatorAutoRegistrationManager" /> class.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="serviceLocator"/> is <c>null</c>.</exception>
        public ServiceLocatorAutoRegistrationManager(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            _serviceLocator = serviceLocator;

            if (EnvironmentHelper.IsProcessCurrentlyHostedByTool())
            {
                return;
            }

            TypeCache.AssemblyLoaded += (sender, args) =>
            {
                foreach (var type in args.LoadedTypes)
                {
                    _pendingTypes.Enqueue(type);
                }

                if (_autoRegisterTypesViaAttributes)
                {
                    try
                    {
                        InspectLoadedAssemblies();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Failed to handle dynamically loaded assembly '{0}'", args.Assembly.FullName);
                    }
                }
            };
        }
开发者ID:jensweller,项目名称:Catel,代码行数:36,代码来源:ServiceLocatorAutoRegistrationManager.cs


示例3: AbstractTestRunner

 public AbstractTestRunner(IServiceLocator services, TestPackage package)
 {
     Services = services;
     TestPackage = package;
     TestRunnerFactory = Services.GetService<ITestRunnerFactory>();
     ProjectService = Services.GetService<IProjectService>();
 }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:7,代码来源:AbstractTestRunner.cs


示例4: XmlMessageSerializer

 	public XmlMessageSerializer(IReflection reflection, IServiceLocator serviceLocator )
     {
         this.reflection = reflection;
         this.serviceLocator = serviceLocator;
     	customElementSerializers = this.serviceLocator.ResolveAll<ICustomElementSerializer>().ToArray();
 		elementSerializationBehaviors = this.serviceLocator.ResolveAll<IElementSerializationBehavior>().ToArray();
     }
开发者ID:JackWangCUMT,项目名称:rhino-esb,代码行数:7,代码来源:XmlMessageSerializer.cs


示例5: ApplicationController

 public ApplicationController(IShellView shellView, IServiceLocator serviceLocator)
 {
     if (shellView == null) throw new ArgumentNullException("shellView");
     if (serviceLocator == null) throw new ArgumentNullException("serviceLocator");
     this.shellView = shellView;
     this.serviceLocator = serviceLocator;
 }
开发者ID:jenrom,项目名称:LogSpy,代码行数:7,代码来源:ApplicationController.cs


示例6: ExampleHtmlWriter

 public ExampleHtmlWriter(IServiceLocator serviceLocator, IUrlRegistry urlRegistry, BehaviorGraph behaviorGraph)
 {
     _serviceLocator = serviceLocator;
     _urlRegistry = urlRegistry;
     _behaviorGraph = behaviorGraph;
     _examplePageUrl = "_fubu/html/example".ToAbsoluteUrl();
 }
开发者ID:nhsevidence,项目名称:fubumvc,代码行数:7,代码来源:ExampleHtmlWriter.cs


示例7: Setup

        internal static void Setup(IServiceLocator locator, ProviderConfiguration config)
        {
            var factories = config.Datastores.Cast<Datastore>().Select(LoadFactory);
            var proxy = new UnitOfWorkFactoryProxy(factories);

            locator.Inject<IUnitOfWorkFactory>(proxy);
        }
开发者ID:brendanhay,项目名称:Shared,代码行数:7,代码来源:DataBootstrapper.cs


示例8: RegisterHandlers

 private static void RegisterHandlers(IServiceLocator serviceLocator)
 {
     var registrar = new BusRegistrar(serviceLocator);
     registrar.Register(typeof(CartHandlers));
     registrar.Register(typeof(CartViewProjections));
     registrar.Register(typeof(CustomerCreatedEventHandler));
 }
开发者ID:petarkorudzhiev,项目名称:d3es,代码行数:7,代码来源:Bootstrapper.cs


示例9: SetLocator

			public static void SetLocator(IServiceLocator locator)
			{
				if (locator == null)
					throw new ArgumentNullException();

				instance = locator;
			}
开发者ID:ArildF,项目名称:Smeedee,代码行数:7,代码来源:ServiceLocator.cs


示例10: EventMigratorManager

 /// <summary>
 /// Initializes an instance of <see cref="EventMigratorManager">EventMigratorManager</see>
 /// </summary>
 /// <param name="typeDiscoverer"></param>
 /// <param name="serviceLocator"></param>
 public EventMigratorManager(ITypeDiscoverer typeDiscoverer, IServiceLocator serviceLocator)
 {
     _typeDiscoverer = typeDiscoverer;
     _serviceLocator = serviceLocator;
     _migratorTypes = new Dictionary<Type, Type>();
     Initialize();
 }
开发者ID:TormodHystad,项目名称:Bifrost,代码行数:12,代码来源:EventMigratorManager.cs


示例11: Initialize

 public override void Initialize(IServiceLocator locator)
 {
     //Initializácia kodových tabuliek modulu administrácia
     locator.GetInstance<AdministrationCodeTableService>()
         .Initialize();
     
 }
开发者ID:aytacozkan,项目名称:nisproject,代码行数:7,代码来源:Configuration.cs


示例12: TurbineControllerActivator

        /// <summary>
        /// Default constructor for the type
        /// </summary>
        /// <param name="serviceLocator"></param>
        public TurbineControllerActivator(IServiceLocator serviceLocator) {
            if (serviceLocator == null) {
                throw new ArgumentNullException("serviceLocator");
            }

            ServiceLocator = serviceLocator;
        }
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:11,代码来源:TurbineControllerActivator.cs


示例13: MailService

        public MailService(IServiceLocator locator)
        {
            Contract.Requires(locator != null);

            this.Serialization = locator.Resolve<ISerialization<byte[]>>();
            this.Repository = locator.Resolve<Func<string, IMailMessage>>();
        }
开发者ID:nutrija,项目名称:revenj,代码行数:7,代码来源:MailService.cs


示例14: Execute

 /// <summary>
 /// Create executor 
 /// </summary>
 public void Execute(Object message, IServiceLocator serviceLocator)
 {
     if (_shortAction != null)
         _shortAction(message);
     else
         _fullAction(message, serviceLocator);
 }
开发者ID:paralect,项目名称:Paralect.ServiceBus,代码行数:10,代码来源:DelegateHandler.cs


示例15: Initialize

        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered<IConnectionStringManager, ConnectionStringManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IContextFactory, ContextFactory>();
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:11,代码来源:ExtensionsEntityFramework6Module.cs


示例16: Initialize

        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered<IDataContextSubscriptionService, DataContextSubscriptionService>();
            serviceLocator.RegisterTypeIfNotYetRegistered<ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IViewLoadManager, ViewLoadManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelWrapperService, ViewModelWrapperService>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelManager, ViewModelManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered<IAutoCompletionService, AutoCompletionService>();

#if !XAMARIN && !WIN80
            serviceLocator.RegisterTypeIfNotYetRegistered<IInteractivityManager, InteractivityManager>();
#endif

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);

            // Don't use property, we cannot trust the cached property here yet in Visual Studio
            if (CatelEnvironment.GetIsInDesignMode())
            {
                foreach (var assembly in AssemblyHelper.GetLoadedAssemblies())
                {
                    var attributes = assembly.GetCustomAttributesEx(typeof (DesignTimeCodeAttribute));
                    foreach (var attribute in attributes)
                    {
                        // No need to do anything
                    }
                }
            }
        }
开发者ID:rishabh8,项目名称:Catel,代码行数:35,代码来源:MVVMModule.cs


示例17: CatelWebApiDependencyResolver

        public CatelWebApiDependencyResolver(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            _serviceLocator = serviceLocator;
            _typeFactory = serviceLocator.ResolveType<ITypeFactory>();
        }
开发者ID:sk8tz,项目名称:Orc.LicenseManager,代码行数:7,代码来源:CatelWebApiDependencyResolver.cs


示例18: ContainerSwitcher

        public ContainerSwitcher(IServiceLocator newContainer, bool shouldDisposeContainerWhenDone)
        {
            originalContainer = EnterpriseLibraryContainer.Current;
            shouldDisposeNewContainer = shouldDisposeContainerWhenDone;

            EnterpriseLibraryContainer.Current = newContainer;
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:ContainerSwitcher.cs


示例19: SetupFilterRegistries

        /// <summary>
        /// Queries the <see cref="IServiceLocator"/> instance for any instances of <see cref="IFilterRegistry"/> to process.
        /// </summary>
        /// <param name="serviceLocator">Current <see cref="IServiceLocator"/> instance for the application.</param>
        public virtual void SetupFilterRegistries(IServiceLocator serviceLocator) {
            var filterRegistries = GetFilterRegistries(serviceLocator);
            if (filterRegistries == null) return;

            var filterList = new List<Filter>();
            var typeList = new List<Type>();

            foreach (var filterRegistry in filterRegistries) {
                var registrations = filterRegistry.GetFilterRegistrations();

                using (serviceLocator.Batch()) {
                    foreach (var registration in registrations) {
                        var filterType = registration.FilterType;

                        // Prevent double registration of the same filter
                        if (typeList.Contains(filterType)) continue;

                        serviceLocator.Register(filterType, filterType);
                        typeList.Add(filterType);
                    }
                }

                filterList.AddRange(registrations);
            }

            typeList.Clear();
            FilterProviders.Providers.Add(new FilterRegistryProvider(serviceLocator, filterList));
        }
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:32,代码来源:FilterBlade.cs


示例20: DbAccessProvider

        /// <summary>
        ///     Initializes a new instance of the <see cref="DbAccessProvider" /> class.
        /// </summary>
        /// <param name="dbAccessProviders">
        ///     The db access providers.
        /// </param>
        /// <param name="serviceLocator">
        ///     The service locator.
        /// </param>
        public DbAccessProvider(IIndex<string, IDbAccess> dbAccessProviders, IServiceLocator serviceLocator)
        {
            this._dbAccessProviders = dbAccessProviders;
            this._serviceLocator = serviceLocator;
            this._providerName = Config.ConnectionProviderName;

            this._dbAccessSafe = new SafeReadWriteProvider<IDbAccess>(
                () =>
                    {
                        IDbAccess dbAccess;

                        // attempt to get the provider...
                        if (this._dbAccessProviders.TryGetValue(this.ProviderName, out dbAccess))
                        {
                            // first time...
                            this._serviceLocator.Get<IRaiseEvent>().Raise(new InitDatabaseProviderEvent(this.ProviderName, dbAccess));
                        }
                        else
                        {
                            throw new NoValidDbAccessProviderFoundException(
                                @"Unable to Locate Provider Named ""{0}"" in Data Access Providers (DLL Not Located in Bin Directory?).".FormatWith(
                                    this.ProviderName));
                        }

                        return dbAccess;
                    });
        }
开发者ID:RH-Code,项目名称:YAFNET,代码行数:36,代码来源:DbAccessProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IServiceManagement类代码示例发布时间:2022-05-24
下一篇:
C# IServiceFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap