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


C# IKernel.GetBindings方法代码示例

本文整理汇总了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);
                    }
                }
            }
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:29,代码来源:ControllerMapper.cs

示例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());
        }        
开发者ID:M-Yankov,项目名称:UniversityStudentSystem,代码行数:15,代码来源:NinjectWebCommon.cs

示例3: NoBindingsIn

 private bool NoBindingsIn(IKernel kernel)
 {
     return !kernel.GetBindings(_service).Any(HasAssemblyKey);
 }
开发者ID:afifmohammed,项目名称:efsession,代码行数:4,代码来源:OverridableBindingGenerator.cs

示例4: DefaultBindingIn

 private bool DefaultBindingIn(IKernel kernel)
 {
     return kernel.GetBindings(_service).Any(IsServiceAssemblyBinding);
 }
开发者ID:afifmohammed,项目名称:efsession,代码行数:4,代码来源:OverridableBindingGenerator.cs

示例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;
 }
开发者ID:NetUtil,项目名称:Util,代码行数:13,代码来源:StandardConstructorScorer.cs

示例6: GetRegistrationInfo

 private bool GetRegistrationInfo(IKernel kernel, Type interfaceType)
 {
     return kernel.GetBindings(interfaceType).Any();
 }
开发者ID:pars87,项目名称:Catel,代码行数:4,代码来源:NinjectHelperTest.cs


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