本文整理汇总了C#中IKernel.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.Scan方法的具体用法?C# IKernel.Scan怎么用?C# IKernel.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.Scan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(x =>
{
x.FromAssembliesMatching("*");
x.BindWith(new DefaultBindingGenerator());
});
}
示例2: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
var scanner = new AssemblyScanner();
scanner.FromCallingAssembly();
scanner.BindWith<DefaultBindingGenerator>();
kernel.Scan(scanner);
ProPartners.Loan.Service.Infrastructure.AppStart.RegisterAssemblies(kernel);
}
示例3: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(scanner =>
{
scanner.FromAssembliesMatching("Candidate.*");
scanner.AutoLoadModules();
scanner.BindWithDefaultConventions();
}
);
}
示例4: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(a =>
{
a.FromCallingAssembly();
a.FromAssembliesMatching("GiveCRM.*.dll");
a.AutoLoadModules();
a.BindWithDefaultConventions();
});
}
示例5: ProjectFactory
static ProjectFactory()
{
_kernel = new StandardKernel();
_kernel.Scan(x =>
{
x.FromCallingAssembly();
x.WhereTypeInheritsFrom(typeof(IProblem));
x.BindWith( new InterfaceBindingGenerator( typeof( IProblem ) ) );
});
}
示例6: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(
x =>
{
x.FromAssembliesMatching(new[] { "MvcFramework.*.dll", "Infrastructure.*.dll" });
x.BindWithDefaultConventions();
x.InTransientScope();
});
}
示例7: RegisterAssemblies
public static void RegisterAssemblies(IKernel kernel)
{
//there are better ways to getting the namespace of the mappers, but this is the most straightforward in the POC
const string mapperNamespace = "IMapperPOC.Service.Mappers";
var scanner = new AssemblyScanner();
scanner.WhereTypeIsNotInNamespace(mapperNamespace);
scanner.FromCallingAssembly();
scanner.BindWith<DefaultBindingGenerator>();
kernel.Scan(scanner);
var mapScanner = new AssemblyScanner();
mapScanner.FromCallingAssembly();
mapScanner.WhereTypeIsInNamespace(mapperNamespace);
mapScanner.BindWith<DefaultBindingGenerator>();
//only create the mappers once since AutoMapper registration has a lot of overhead.
mapScanner.InSingletonScope();
kernel.Scan(mapScanner);
}
示例8: ScanAssemblies
public static IKernel ScanAssemblies(IKernel kernel)
{
var scanner = new AssemblyScanner();
scanner.FromAssembliesMatching("Basketball.Service.dll"); // Services classes here
scanner.FromAssembliesMatching("Basketball.Data.dll"); // Repositories here
scanner.BindWithDefaultConventions();
kernel.Scan(scanner);
return kernel;
}
示例9: 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<SessionFactoryProvider>().ToSelf().InSingletonScope();
kernel.Bind<SessionProvider>().ToSelf().InRequestScope();
// Ninject.Extensions.Conventions
kernel.Scan(x =>
{
x.FromAssembliesMatching("*");
x.BindWith(new DefaultBindingGenerator());
});
}
示例10: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(a =>
{
a.FromCallingAssembly();
a.FromAssembliesMatching("GiveCRM.*.dll");
a.BindWithDefaultConventions();
a.BindWith(new RegexBindingGenerator("(I)(?<name>.+)(Repository)"));
a.BindWith(new GenericBindingGenerator(typeof(IRepository<>)));
a.InRequestScope();
});
}
示例11: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
var scanner = new AssemblyScanner();
scanner.FromCallingAssembly();
//This will register all interfaces with concrete types based on convention
//ex: IPersonService will register to PersonService
scanner.BindWith<DefaultBindingGenerator>();
kernel.Scan(scanner);
IMapperPOC.Service.Infrustructure.AppStart.RegisterAssemblies(kernel);
}
示例12: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(a =>
{
a.FromCallingAssembly();
a.FromAssembliesMatching("GiveCRM.*.dll");
a.BindWithDefaultConventions();
a.InRequestScope();
});
kernel.Bind<IMembershipService>().To<MembershipService>();
}
示例13: RegisterAssemblies
public static void RegisterAssemblies(IKernel kernel)
{
if (kernel == null)
throw new ArgumentException("can not be null", "kernel");
kernel.Bind<ITimeTrackerSession>().To<TimeTrackerSession>().InRequestScope();
kernel.Bind<ITimeTrackerReadOnlySession>().To<TimeTrackerReadOnlySession>().InRequestScope();
var scanner = new AssemblyScanner();
scanner.WhereTypeIsNotInNamespace("TimeTracker.Service.Storage.Context");
scanner.WhereTypeIsNotInNamespace("TimeTracker.Service.Mappers");
scanner.FromCallingAssembly();
scanner.BindWith<DefaultBindingGenerator>();
kernel.Scan(scanner);
//set mappers to singleton
var mapScanner = new AssemblyScanner();
mapScanner.FromCallingAssembly();
mapScanner.WhereTypeIsInNamespace("TimeTracker.Service.Mappers");
mapScanner.BindWith<DefaultBindingGenerator>();
mapScanner.InSingletonScope();
kernel.Scan(mapScanner);
}
示例14: 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(typeof(IRepository<>)).To(typeof(Repository<>));
kernel.Bind(typeof(IUnitOfWork)).To(typeof(UnitOfWork));
kernel.Bind<DbContextAdapter>().ToSelf().InRequestScope();
kernel.Bind<IObjectSetFactory>().ToMethod(x => x.Kernel.Get<DbContextAdapter>()).InRequestScope();
kernel.Bind<IObjectContext>().ToMethod(x => x.Kernel.Get<DbContextAdapter>()).InRequestScope();
kernel.Scan(scanner =>
{
scanner.From("MvcArch.IServices");
scanner.From("MvcArch.Services");
scanner.BindWithDefaultConventions();
}
);
Type contextType = Type.GetType("MvcArch.Dal.Context, MvcArch.Dal");
kernel.Bind(typeof(DbContext)).To(contextType);
}
示例15: RegisterServices
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Scan(scanner => {
scanner.FromAssembliesMatching("RazorPad.*");
scanner.BindWithDefaultConventions();
scanner.Excluding<EntityFramework.Repository>();
});
kernel.Bind<Services.IRepository>()
.To<EntityFramework.Repository>()
.InRequestScope()
.WithConstructorArgument("isSharedContext", false);
kernel.Bind<EntityFramework.RazorPadContext>()
.ToSelf()
.InRequestScope();
kernel.Bind<Authentication.Facebook.FacebookService>().ToSelf()
.InSingletonScope()
.WithPropertyValue("LocalEndpoint", x => x.Kernel.Get<UrlHelper>().ExternalAction("Authorize", "Facebook"));
}