本文整理汇总了C#中IKernel.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.Resolve方法的具体用法?C# IKernel.Resolve怎么用?C# IKernel.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNotificationEndPoint
private static INotificationEndPoint CreateNotificationEndPoint(IKernel kernel)
{
var cloudMediaContext = kernel.Resolve<CloudMediaContext>();
var cloudQueueClient = kernel.Resolve<CloudQueueClient>();
try
{
// ReSharper disable once ReplaceWithSingleCallToFirstOrDefault
INotificationEndPoint endpoint = cloudMediaContext.NotificationEndPoints
.Where(ep => ep.Name == UploadConfig.NotificationQueueName)
.FirstOrDefault();
if (endpoint != null)
return endpoint;
// Make sure the queue exists in Azure Storage
var notificationQueue = cloudQueueClient.GetQueueReference(UploadConfig.NotificationQueueName);
notificationQueue.CreateIfNotExists();
// Create the endpoint
return cloudMediaContext.NotificationEndPoints.Create(UploadConfig.NotificationQueueName, NotificationEndPointType.AzureQueue,
UploadConfig.NotificationQueueName);
}
finally
{
kernel.ReleaseComponent(cloudMediaContext);
kernel.ReleaseComponent(cloudQueueClient);
}
}
示例2: Resolve
public override object Resolve(IKernel kernel)
{
string key = null;
var argument = arguments[0];
if (arguments.Length == 2)
{
key = (string)argument;
argument = arguments[1];
}
else if (argument is string)
{
return kernel.Resolve((string)argument, ComponentType);
}
if (argument is Uri)
{
argument = WcfEndpoint.At((Uri)argument);
}
var args = new HybridDictionary { { Guid.NewGuid().ToString(), argument } };
if (key == null)
{
return kernel.Resolve(ComponentType, args);
}
return kernel.Resolve(key, ComponentType, args);
}
示例3: Resolve
/// <summary>
/// Resolves the component(s) from given kernel.
/// </summary>
/// <param name = "kernel"></param>
/// <returns>Resolved component(s).</returns>
public virtual object Resolve(IKernel kernel)
{
if (string.IsNullOrEmpty(ComponentName) == false && kernel.HasComponent(ComponentName))
{
if (ComponentType == null)
{
return kernel.Resolve(ComponentName, AdditionalArguments);
}
return kernel.Resolve(ComponentName, ComponentType, AdditionalArguments);
}
return kernel.Resolve(ComponentType, AdditionalArguments);
}
示例4: Create
private ICustomFieldManager Create(IKernel kernel, CreationContext context)
{
if (context.Handler.ComponentModel.Name == typeof(PublicController).FullName
|| context.Handler.ComponentModel.Name == typeof(DataFileController).FullName
|| context.Handler.ComponentModel.Name == typeof(CustomFieldController).FullName)
{
return kernel.Resolve<PublicFieldManager>();
}
else if (context.Handler.ComponentModel.Name == typeof(PrivateHealthController).FullName)
{
return kernel.Resolve<PrivateHealthFieldManager>();
}
throw new InvalidOperationException(string.Format("Cannot resolve {0} using given {1}.", typeof(ICustomFieldManager).Name, context.GetType().Name));
}
示例5: Create
public static IFileProcessor Create(IKernel kernel, string typeKey)
{
var blobClient = kernel.Resolve<IBlobClient>();
var repositories = kernel.Resolve<IRepositoryContainer>();
if (typeKey == "ServiceOffering")
{
return new ServiceOfferingFileProcessor(blobClient, repositories);
}
else if (typeKey == "ServiceAttendance")
{
return new ServiceAttendanceFileProcessor(blobClient, repositories);
}
return null;
}
示例6: Execute
public IResponse Execute(IKernel kernel, IRequest request, RouteBase route)
{
// This is kind of nasty and needs to be smarter as well as handling bound models
var controller = (SammyController)kernel.Resolve(route.Type);
controller.Request = new Request(request);
return (IResponse)route.Method.Invoke(controller, null);
}
示例7: RegisterIMappingEngine
private void RegisterIMappingEngine(IKernel kernel)
{
kernel.Register(
Component.For<IMappingEngine>()
.UsingFactoryMethod(k => new MappingEngine(kernel.Resolve<IConfigurationProvider>()))
);
}
示例8: GetAzureServiceConfig
private static IMicrosoftStorageConfig GetAzureServiceConfig(IKernel k, ComponentModel cm, CreationContext cc)
{
var serviceConfig = new DefaultAzureServiceConfigurationProvider(k.Resolve<IAppConfigSettings>()).GetConfigRaw();
var webConfig = serviceConfig["Web"];
return new DictionaryAdapterFactory().GetAdapter<IMicrosoftStorageConfig>(webConfig);
}
示例9: CreateAspects
public IList<IAspect> CreateAspects(IKernel kernel)
{
List<IAspect> result = new List<IAspect>();
foreach(String id in AspectComponents.Keys) {
result.Add((IAspect) kernel.Resolve(id, typeof(IAspect )));
}
return result;
}
示例10: ProcessModel
public override void ProcessModel(IKernel kernel, ComponentModel model)
{
if (model.Service is IBehaviorStore)
{
foreach (var node in kernel.GraphNodes.OfType<ComponentModel>())
{
SetProxyInformation(node, kernel.Resolve<IBehaviorConfigurator>());
}
return;
}
if (!kernel.HasComponent(typeof (IBehaviorStore))) return;
var behaviorToProxyResolver = kernel.Resolve<IBehaviorConfigurator>();
//Get the proxy info
SetProxyInformation(model, behaviorToProxyResolver);
}
示例11: CreateCloudQueueClient
private static CloudQueueClient CreateCloudQueueClient(IKernel kernel)
{
var storageAccount = kernel.Resolve<CloudStorageAccount>();
CloudQueueClient client = storageAccount.CreateCloudQueueClient();
kernel.ReleaseComponent(storageAccount);
return client;
}
示例12: ConfigureCache
private void ConfigureCache(IKernel kernel, IEducationContext instance)
{
if (EnableCaching)
{
instance.Cache = kernel.Resolve<ICache>();
instance.CachingPolicy = CachingPolicy.CacheAll;
}
}
示例13: CreateLeaseManagerConfig
private static LeaseManagerConfig CreateLeaseManagerConfig(IKernel kernel)
{
// Configure the lease manager
var configRetriever = kernel.Resolve<IGetEnvironmentConfiguration>();
var leaseManagerConfig = new LeaseManagerConfig { LeaseName = "SampleDataJobs", UniqueId = configRetriever.UniqueInstanceId };
kernel.ReleaseComponent(configRetriever);
return leaseManagerConfig;
}
示例14: ContainerContext
public ContainerContext(IKernel kernel)
{
this.kernel = kernel;
EnsureContainerContextStoreRegistered();
contextStore = kernel.Resolve<IContainerContextStore>();
contextStore.RegisterCurrent(this);
}
示例15: CreateCloudStorageAccount
private static CloudStorageAccount CreateCloudStorageAccount(IKernel kernel)
{
// Get Azure configurations
var configRetriever = kernel.Resolve<IGetEnvironmentConfiguration>();
string storageConnectionString = configRetriever.GetSetting(StorageConnectionStringAppSettingsKey);
kernel.ReleaseComponent(configRetriever);
return CloudStorageAccount.Parse(storageConnectionString);
}