本文整理汇总了C#中IKernel.GetBindings方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.GetBindings方法的具体用法?C# IKernel.GetBindings怎么用?C# IKernel.GetBindings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.GetBindings方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ControllerMapper
public ControllerMapper(ITypeFinder typeFinder, IContentTypeManager definitionManager, IKernel kernel)
{
IList<ControlsAttribute> controllerDefinitions = FindControllers(typeFinder);
foreach (ContentType id in definitionManager.GetContentTypes())
{
IAdapterDescriptor controllerDefinition = GetControllerFor(id.ItemType, controllerDefinitions);
if (controllerDefinition != null)
{
string controllerName = GetControllerName(controllerDefinition.AdapterType, controllerDefinition.AreaName);
ControllerMap[id.ItemType] = controllerDefinition.ControllerName;
AreaMap[id.ItemType] = controllerDefinition.AreaName;
if (!kernel.GetBindings(typeof(IController)).Any(b => b.Metadata.Name == controllerName))
kernel.Bind<IController>().To(controllerDefinition.AdapterType)
.InTransientScope()
.Named(controllerName);
IList<IPathFinder> finders = PathDictionary.GetFinders(id.ItemType);
if (0 == finders.Where(f => f is ActionResolver).Count())
{
// TODO: Get the list of methods from a list of actions retrieved from somewhere within MVC
var methods = controllerDefinition.AdapterType.GetMethods().Select(m => m.Name).ToArray();
var actionResolver = new ActionResolver(this, methods);
PathDictionary.PrependFinder(id.ItemType, actionResolver);
}
}
}
}
示例2: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<DbContext>().To<UniversityDbContext>().InRequestScope();
kernel.Bind(typeof(IRepository<>)).To(typeof(EfRepository<>));
kernel.Bind(typeof(IRepository<,>)).To(typeof(EfRepository<,>));
var h = kernel.GetBindings(typeof(IRepository<>));
kernel.Bind(b => b.From("UniversityStudentSystem.Services").SelectAllClasses().BindDefaultInterfaces());
}
示例3: NoBindingsIn
private bool NoBindingsIn(IKernel kernel)
{
return !kernel.GetBindings(_service).Any(HasAssemblyKey);
}
示例4: DefaultBindingIn
private bool DefaultBindingIn(IKernel kernel)
{
return kernel.GetBindings(_service).Any(IsServiceAssemblyBinding);
}
示例5: BindingExists
/// <summary>
/// Checkes whether a binding exists for a given target on the specified kernel.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="context">The context.</param>
/// <param name="target">The target.</param>
/// <returns>Whether a binding exists for the target in the given context.</returns>
protected virtual bool BindingExists(IKernel kernel, IContext context, ITarget target)
{
var targetType = GetTargetType(target);
return kernel.GetBindings(targetType).Any(b => !b.IsImplicit)
|| target.HasDefaultValue;
}
示例6: GetRegistrationInfo
private bool GetRegistrationInfo(IKernel kernel, Type interfaceType)
{
return kernel.GetBindings(interfaceType).Any();
}