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


C# IComponentContext.Resolve方法代码示例

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


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

示例1: RequestContextFactory

        static RequestContext RequestContextFactory(IComponentContext context)
        {
            var httpContextAccessor = context.Resolve<IHttpContextAccessor>();
            var httpContext = httpContextAccessor.Current();
            if (httpContext != null)
            {

                var mvcHandler = httpContext.Handler as MvcHandler;
                if (mvcHandler != null)
                {
                    return mvcHandler.RequestContext;
                }

                var hasRequestContext = httpContext.Handler as IHasRequestContext;
                if (hasRequestContext != null)
                {
                    if (hasRequestContext.RequestContext != null)
                        return hasRequestContext.RequestContext;
                }
            }
            else
            {
                httpContext = HttpContextBaseFactory(context);
            }

            return new RequestContext(httpContext, new RouteData());
        }
开发者ID:qhme,项目名称:OrchardLite,代码行数:27,代码来源:MvcModule.cs

示例2: WithAutofacDefaults

 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithTypesFrom(componentContext.Resolve<ITypeProvider>())
         .WithDependencyResolver(componentContext.Resolve<IDependencyResolver>())
         ;
 }
开发者ID:fenix2222,项目名称:Nimbus,代码行数:7,代码来源:AutofacBusBuilderConfigurationExtensions.cs

示例3: Start

        internal void Start(IComponentContext context)
        {
            var engine = context.Resolve<ClientEngine>();
            var dhtListner = context.Resolve<DhtListener>();
            var dht = context.Resolve<IDhtEngine>();
            var settingsUtility = context.Resolve<ISettingsUtility>();

            var port = settingsUtility.Read(ApplicationConstants.TorrentPortKey,
                   ApplicationConstants.DefaultTorrentPort);

          OpenPort(port);

            // register the dht engine
            engine.RegisterDht(dht);

            // start the dht listener
            dhtListner.Start();

            // annnnnddd start the dht engine
            engine.DhtEngine.Start();
            
            // clear up torrent folder
            Task.Factory.StartNew(async () =>
            {
                var torrentsFolder = engine.Settings.SaveFolder;
                await StorageHelper.DeleteFolderContentAsync(torrentsFolder);
            });
        }
开发者ID:haroldma,项目名称:PopcornTime,代码行数:28,代码来源:TorrentBootstrapper.cs

示例4: OnStartupExtracted

 private static ITwitterFeed OnStartupExtracted(IComponentContext ctx, bool useTwitter)
 {
     if (useTwitter)
         return ctx.Resolve<TwitterFeedAsync>();
     else
         return ctx.Resolve<FakeTwitterFeed>();
 }
开发者ID:holdensmagicalunicorn,项目名称:Rx-Demo,代码行数:7,代码来源:App.xaml.cs

示例5: AgencyBanks

 public AgencyBanks(IComponentContext container)
 {
         this.iContainer = container;
         queueConfiguration = iContainer.Resolve<IQueueConfiguration>();
         publisher = iContainer.Resolve<IExchangePublisher<Job>>();
         publisher.Declare(queueConfiguration.ResponseExchangeName);
 }
开发者ID:jhonner72,项目名称:plat,代码行数:7,代码来源:AgencyBanks.cs

示例6: ConfigureSessionFactory

        private static ISessionFactory ConfigureSessionFactory(IComponentContext context)
        {
            var connectionStringProvider = context.Resolve<IConnectionStringProvider>();
            EntryMapping.CurrentSchema = connectionStringProvider.Schema;
            var databaseProvider = context.ResolveNamed<IDatabaseProvider>(connectionStringProvider.DatabaseProvider.ToLower());

            var databaseConfiguration = databaseProvider.GetDatabaseConfiguration(connectionStringProvider);
            var configuration =
                Fluently
                    .Configure()
                    .Database(databaseConfiguration)
                    .Mappings(m =>
                                  {
                                      m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly());

                                      //Scan extensions for nHibernate mappings
                                      var extension = context.Resolve<IEnumerable<ScriptedExtension>>();
                                      foreach (var assembly in extension.Select(provider => provider.SourceAssembly))
                                      {
                                          m.FluentMappings.AddFromAssembly(assembly);
                                      }
                                  })
                    .ProxyFactoryFactory(typeof (DefaultProxyFactoryFactory));

            return configuration.BuildSessionFactory();
        }
开发者ID:slavo,项目名称:FunnelWeb,代码行数:26,代码来源:RepositoriesModule.cs

示例7: CreateRunner

 private static IServiceRunner CreateRunner(RunMode mode, IComponentContext c)
 {
     if (mode == RunMode.Console)
     {
         return c.Resolve<ConsoleRunner>();
     }
     return c.Resolve<ServiceRunner>();
 }
开发者ID:rauli67,项目名称:atlas,代码行数:8,代码来源:HostModule.cs

示例8: RuntimeProviders

 static RuntimeProviders RuntimeProviders(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildRuntimeProviders(c.ResolveOptional<ILog>());
 }
开发者ID:kmaclean,项目名称:lokad-cloud,代码行数:8,代码来源:StorageModule.cs

示例9: BuildTransport

 protected virtual ITransportMessages BuildTransport(IComponentContext c)
 {
     var threadSafeContext = c.Resolve<IComponentContext>();
     return new MessageQueueTransport(
         () => threadSafeContext.Resolve<IReceiveMessages>(),
         c.Resolve<ISendToEndpoints>(),
         this.maxThreads);
 }
开发者ID:JamesTryand,项目名称:NanoMessageBus,代码行数:8,代码来源:TransportWireup.cs

示例10: BuildMessageReceiver

 protected virtual IReceiveMessages BuildMessageReceiver(IComponentContext c)
 {
     var threadSafeContext = c.Resolve<IComponentContext>();
     return new MessageReceiverWorkerThread(
         c.Resolve<IReceiveFromEndpoints>(),
         () => threadSafeContext.Resolve<IRouteMessagesToHandlers>(),
         action => new BackgroundThread(() => action()));
 }
开发者ID:JamesTryand,项目名称:NanoMessageBus,代码行数:8,代码来源:TransportWireup.cs

示例11: QueueStorageProvider

 static IQueueStorageProvider QueueStorageProvider(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithDataSerializer(c.Resolve<IDataSerializer>())
         .WithObserver(c.Resolve<IStorageObserver>())
         .BuildQueueStorage();
 }
开发者ID:Lokad,项目名称:lokad-cloud,代码行数:8,代码来源:StorageModule.cs

示例12: WithAutofacDefaults

 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithMulticastEventBroker(componentContext.Resolve<IMulticastEventBroker>())
         .WithCompetingEventBroker(componentContext.Resolve<ICompetingEventBroker>())
         .WithCommandBroker(componentContext.Resolve<ICommandBroker>())
         .WithRequestBroker(componentContext.Resolve<IRequestBroker>())
         .WithLogger(componentContext.Resolve<ILogger>());
 }
开发者ID:nblumhardt,项目名称:Nimbus,代码行数:9,代码来源:BusBuilderConfigurationExtensions.cs

示例13: BlobStorageProvider

 static IBlobStorageProvider BlobStorageProvider(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithDataSerializer(c.Resolve<IDataSerializer>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildBlobStorage();
 }
开发者ID:kmaclean,项目名称:lokad-cloud,代码行数:9,代码来源:StorageModule.cs

示例14: BuildDefaultMessageSender

        IMessageSender BuildDefaultMessageSender(IComponentContext c)
        {
            var observer = c.Resolve<ISystemObserver>();
            var registry = c.Resolve<QueueWriterRegistry>();

            var factory = registry.GetOrAdd(_endpoint, s => _construct(c, s));
            var queues = _queueNames.Select(factory.GetWriteQueue).ToArray();
            return new DefaultMessageSender(queues, observer, _keyGenerator);
        }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:9,代码来源:SendMessageModule.cs

示例15: ResGroup

		public ResGroup(IResourceManager resourceManager, IResourceFile resourceFile, IComponentContext context)
		{
			this.resourceManager = resourceManager;
			this.resourceFile = resourceFile;
			this.context = context;

			//TODO: make public properties read-only
			this.externalResources = context.Resolve<IList<IResourceFile>>();
			this.embeddedResources = context.Resolve<IList<Managed>>();
		}
开发者ID:gleblebedev,项目名称:toe,代码行数:10,代码来源:ResGroup.cs


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