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


C# IServiceLocator.Resolve方法代码示例

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


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

示例1: HttpServer

 public HttpServer(ILogFactory logFactory, IServiceLocator locator)
 {
     Logger = logFactory.Create("Http server");
     Listener = new HttpListener();
     Listener.IgnoreWriteExceptions = true;
     foreach (string key in ConfigurationManager.AppSettings.Keys)
     {
         if (key.StartsWith("HttpAddress", StringComparison.InvariantCultureIgnoreCase))
             Listener.Prefixes.Add(ConfigurationManager.AppSettings[key]);
     }
     if (Listener.Prefixes.Count == 0)
     {
         Listener.Prefixes.Add("http://*:80/");
         Listener.Prefixes.Add("https://*:443/");
     }
     Routes = new Routes(locator);
     var customAuth = ConfigurationManager.AppSettings["CustomAuth"];
     if (!string.IsNullOrEmpty(customAuth))
     {
         var authType = Type.GetType(customAuth);
         if (!typeof(HttpAuth).IsAssignableFrom(authType))
             throw new ConfigurationErrorsException("Custom auth does not inherit from HttpAuth. Please inherit from " + typeof(HttpAuth).FullName);
         Authentication = locator.Resolve<HttpAuth>(authType);
     }
     else Authentication = locator.Resolve<HttpAuth>();
 }
开发者ID:nutrija,项目名称:revenj,代码行数:26,代码来源:HttpServer.cs

示例2: 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

示例3: VerifyContainer

 protected static void VerifyContainer(IServiceLocator serviceLocator, int expected)
 {
     Assert.That(serviceLocator.Resolve(typeof(EventStore)), Is.Not.Null);
     var array = serviceLocator.ResolveAll(typeof(IEventHandler<AggregateChanged>));
     Assert.That(array, Is.Not.Null);
     Assert.That(array.Length, Is.EqualTo(expected));
     if (expected == 1)
         Assert.That(serviceLocator.Resolve(typeof(IEventHandler<AggregateChanged>)), Is.Not.Null);
 }
开发者ID:bbqchickenrobot,项目名称:EventStoreLite,代码行数:9,代码来源:InstallerTest.cs

示例4: ILGeneratorInstructionVisitor

 internal ILGeneratorInstructionVisitor(
         IServiceLocator serviceLocator,
         IILGenerator generator,
         IDictionary<VariableReference, LocalBuilder> locals)
     : this(serviceLocator,
         generator,
         locals,
         serviceLocator.Resolve<ITypeResolver>(),
         serviceLocator.Resolve<IOpCodeMapper>())
 {
 }
开发者ID:gmf520,项目名称:Smocks,代码行数:11,代码来源:ILGeneratorInstructionVisitor.cs

示例5: RegisterMsmqOneWay

        private void RegisterMsmqOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;

            b.RegisterSingleton<IMessageBuilder<Message>>(() => (IMessageBuilder<Message>)new MsmqMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<IOnewayBus>(() => (IOnewayBus)new MsmqOnewayBus(
                oneWayConfig.MessageOwners,
                l.Resolve<IMessageBuilder<Message>>(),oneWayConfig.ConfigurationSection.Bus.UseDeadLetterQueue));
        }
开发者ID:EzyWebwerkstaden,项目名称:rhino-esb,代码行数:12,代码来源:OneWayBusConfigurationAware.cs

示例6: GetMenuRegistryOrRegisterDefaultInstance

        private static IMenuRegistry GetMenuRegistryOrRegisterDefaultInstance(IServiceLocator serviceLocator)
        {
            try
            {
                return serviceLocator.Resolve<IMenuRegistry>();
            }
            catch(ServiceResolutionException)
            {
                serviceLocator.Register<IMenuRegistry>(new MenuRegistry());
            }

            return serviceLocator.Resolve<IMenuRegistry>();
        }
开发者ID:burkhartt,项目名称:Bennington,代码行数:13,代码来源:CmsBlade.cs

示例7: RegisterSqlQueuesTransport

		private void RegisterSqlQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
		{
			var busConfig = c.ConfigurationSection.Bus;

			b.RegisterSingleton<IStorage>(() => new SqlStorage(busConfig.Path ?? QueueConnectionStringContainer.ConnectionString));

			b.RegisterSingleton<ISubscriptionStorage>(() => new GenericSubscriptionStorage(
			                                                	l.Resolve<IStorage>(),
			                                                	c.Endpoint.ToString(),
			                                                	l.Resolve<IMessageSerializer>(),
			                                                	l.Resolve<IReflection>()));

			b.RegisterSingleton<ITransport>(() => new SqlQueuesTransport(
			                                      	c.Endpoint,
			                                      	l.Resolve<IEndpointRouter>(),
			                                      	l.Resolve<IMessageSerializer>(),
			                                      	c.ThreadCount,
													busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
			                                      	c.NumberOfRetries,
			                                      	l.Resolve<IMessageBuilder<MessagePayload>>()));

			b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => new SqlQueuesMessageBuilder(
			                                                           	l.Resolve<IMessageSerializer>(),
			                                                           	l.Resolve<IServiceLocator>()));
		}
开发者ID:Teleopti,项目名称:Rhino.ServiceBus.SqlQueues,代码行数:25,代码来源:SqlQueuesConfigurationAware.cs

示例8: RegisterSqlQueuesOneWay

		private void RegisterSqlQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
		{
			var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
			var busConfig = c.ConfigurationSection.Bus;

			b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => new SqlQueuesMessageBuilder(
				l.Resolve<IMessageSerializer>(),
				l.Resolve<IServiceLocator>()));

			b.RegisterSingleton<IOnewayBus>(() => new SqlQueuesOneWayBus(
				oneWayConfig.MessageOwners,
				l.Resolve<IMessageSerializer>(),
				busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
				l.Resolve<IMessageBuilder<MessagePayload>>()));
		}
开发者ID:Teleopti,项目名称:Rhino.ServiceBus.SqlQueues,代码行数:15,代码来源:SqlQueuesOneWayBusConfigurationAware.cs

示例9: RegisterRhinoQueuesOneWay

        private void RegisterRhinoQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
            var busConfig = c.ConfigurationSection.Bus;

            b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => (IMessageBuilder<MessagePayload>)new RhinoQueuesMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<IOnewayBus>(() => (IOnewayBus)new RhinoQueuesOneWayBus(
                oneWayConfig.MessageOwners,
                l.Resolve<IMessageSerializer>(),
                busConfig.QueuePath,
                busConfig.EnablePerformanceCounters,
                l.Resolve<IMessageBuilder<MessagePayload>>()));
        }
开发者ID:jberezanski,项目名称:rhino-esb,代码行数:16,代码来源:RhinoQueuesOneWayBusConfigurationAware.cs

示例10: GetTypeCatalog

 public static ITypeCatalog GetTypeCatalog(IServiceLocator serviceLocator)
 {
     var typeCatalog = serviceLocator.Resolve<ITypeCatalog>();
     if (typeCatalog != null)
     {
         return typeCatalog;
     }
     var assemblies = serviceLocator.Resolve<List<Assembly>>();
     if (assemblies == null || assemblies.Count < 1)
     {
         assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
     }
     serviceLocator.RegisterInstance(assemblies);
     typeCatalog = new AppDomainTypeCatalog(assemblies);
     serviceLocator.Register(() => typeCatalog);
     return typeCatalog;
 }
开发者ID:Hallmanac,项目名称:ServiceLocator,代码行数:17,代码来源:StartupConfiguration.cs

示例11: GetEmbeddedViewResolver

 /// <summary>
 /// Gets the <see cref="IEmbeddedViewResolver"/> resolver for the system.
 /// </summary>
 /// <param name="serviceLocator"></param>
 /// <returns></returns>
 protected virtual IEmbeddedViewResolver GetEmbeddedViewResolver(IServiceLocator serviceLocator) {
     try {
         return serviceLocator.Resolve<IEmbeddedViewResolver>();
     }
     catch {
         return new EmbeddedViewResolver();
     }
 }
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:13,代码来源:EmbeddedViewBlade.cs

示例12: RegisterRhinoQueuesTransport

        private void RegisterRhinoQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var busConfig = c.ConfigurationSection.Bus;
            var fileManagerConfiguration = new QueueManagerConfiguration();

            b.RegisterSingleton<ISubscriptionStorage>(() => (ISubscriptionStorage)new FileSubscriptionStorage(
                busConfig.SubscriptionPath,
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IReflection>()));

            b.RegisterSingleton<ITransport>(() => (ITransport)new RhinoFilesTransport(
                c.Endpoint,
                l.Resolve<IEndpointRouter>(),
                l.Resolve<IMessageSerializer>(),
                c.ThreadCount,
                busConfig.QueuePath,
                c.IsolationLevel,
                c.NumberOfRetries,
                busConfig.EnablePerformanceCounters,
                l.Resolve<IMessageBuilder<MessagePayload>>(),
                fileManagerConfiguration));

            b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => (IMessageBuilder<MessagePayload>)new RhinoFilesMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<QueueManagerConfiguration>(() => fileManagerConfiguration);
        }
开发者ID:BclEx,项目名称:rhino-esb,代码行数:28,代码来源:RhinoFilesConfigurationAware.cs

示例13: RegisterViewEngine

        protected virtual void RegisterViewEngine(IServiceLocator locator) {
            try {
                var engineManager = locator.Resolve<IViewEngineManager>();
                if (engineManager == null) return;

                engineManager.RegisterEngines();
            }
            catch { }           
        }
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:9,代码来源:ViewBlade.cs

示例14: MainWindow

        /// <summary>
        /// 
        /// </summary>
        /// <param name="locator"></param>
        /// <param name="resetEvent">invoked after all region defined</param>
        public MainWindow(IServiceLocator locator, ManualResetEvent resetEvent)
        {
            _locator = locator;
            InitializeComponent();

            var regionManager = locator.Resolve<RegionManager>();

            regionManager.AttachRegion("mainTab", OurTabcontrol);
            resetEvent.Set();
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:15,代码来源:MainWindow.xaml.cs

示例15: Register

        public void Register(IServiceLocator locator)
        {
            locator.Register<IAdminAccountRepository, AdminAccountRepository>();
            locator.Register<IAdminAccountListPageViewModelMapper, AdminAccountListPageViewModelMapper>();
            locator.Register<IAdminAccountEditFormStore, AdminAccountEditFormStore>();
            locator.Register<IAdminAccountIdGenerator, AdminAccountIdGenerator>();

            locator.Register<IDatabaseRetriever>(() =>
                                                     {
                                                         var adminAccountSettings = locator.Resolve<IAdminAccountSettings>();
                                                         return new DatabaseRetriever(adminAccountSettings.ConnectionString);
                                                     });

            locator.Register<IPasswordHasher>(() =>
                                                  {
                                                      var adminAccountSettings = locator.Resolve<IAdminAccountSettings>();
                                                      return new PasswordHasher(adminAccountSettings);
                                                  });
        }
开发者ID:burkhartt,项目名称:Bennington,代码行数:19,代码来源:AdminAccountRegistration.cs


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