本文整理汇总了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());
}
示例2: WithAutofacDefaults
public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
{
return configuration
.WithTypesFrom(componentContext.Resolve<ITypeProvider>())
.WithDependencyResolver(componentContext.Resolve<IDependencyResolver>())
;
}
示例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);
});
}
示例4: OnStartupExtracted
private static ITwitterFeed OnStartupExtracted(IComponentContext ctx, bool useTwitter)
{
if (useTwitter)
return ctx.Resolve<TwitterFeedAsync>();
else
return ctx.Resolve<FakeTwitterFeed>();
}
示例5: AgencyBanks
public AgencyBanks(IComponentContext container)
{
this.iContainer = container;
queueConfiguration = iContainer.Resolve<IQueueConfiguration>();
publisher = iContainer.Resolve<IExchangePublisher<Job>>();
publisher.Declare(queueConfiguration.ResponseExchangeName);
}
示例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();
}
示例7: CreateRunner
private static IServiceRunner CreateRunner(RunMode mode, IComponentContext c)
{
if (mode == RunMode.Console)
{
return c.Resolve<ConsoleRunner>();
}
return c.Resolve<ServiceRunner>();
}
示例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>());
}
示例9: BuildTransport
protected virtual ITransportMessages BuildTransport(IComponentContext c)
{
var threadSafeContext = c.Resolve<IComponentContext>();
return new MessageQueueTransport(
() => threadSafeContext.Resolve<IReceiveMessages>(),
c.Resolve<ISendToEndpoints>(),
this.maxThreads);
}
示例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()));
}
示例11: QueueStorageProvider
static IQueueStorageProvider QueueStorageProvider(IComponentContext c)
{
return CloudStorage
.ForAzureAccount(c.Resolve<CloudStorageAccount>())
.WithDataSerializer(c.Resolve<IDataSerializer>())
.WithObserver(c.Resolve<IStorageObserver>())
.BuildQueueStorage();
}
示例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>());
}
示例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();
}
示例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);
}
示例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>>();
}