public override void Load() { var cfg = new LuceneRepositoryConfigurator { EnablePackageFileWatcher = GetFlagFromAppSetting("enablePackageFileWatcher", true), GroupPackageFilesById = GetFlagFromAppSetting("groupPackageFilesById", true), LuceneIndexPath = MapPathFromAppSetting("lucenePath", "~/App_Data/Lucene"), PackagePath = MapPathFromAppSetting("packagesPath", "~/App_Data/Packages") }; cfg.Initialize(); Kernel.Components.Add<IInjectionHeuristic, NonDecoratedPropertyInjectionHeuristic>(); Bind<Func<IKernel>>().ToMethod(ctx => () => Kernel); Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); Bind<ILucenePackageRepository>().ToConstant(cfg.Repository).OnDeactivation(_ => cfg.Dispose()); Bind<LuceneDataProvider>().ToConstant(cfg.Provider); Bind<IQueryable<ApiUser>>().ToConstant(cfg.Provider.AsQueryable<ApiUser>()); Bind<IApiKeyAuthentication>().To<LuceneApiKeyAuthentication>(); Bind<IHttpModule>().To<ApiKeyAuthenticationModule>(); var tokenSource = new ReusableCancellationTokenSource(); Bind<ReusableCancellationTokenSource>().ToConstant(tokenSource); var repository = base.Kernel.Get<ILucenePackageRepository>(); if (GetFlagFromAppSetting("synchronizeOnStart", true)) { repository.SynchronizeWithFileSystem(tokenSource.Token); } }
protected virtual ILuceneRepositoryConfigurator InitializeRepositoryConfigurator(INuGetWebApiSettings settings) { var cfg = new LuceneRepositoryConfigurator { EnablePackageFileWatcher = settings.EnablePackageFileWatcher, GroupPackageFilesById = settings.GroupPackageFilesById, LuceneIndexPath = settings.LucenePackagesIndexPath, PackagePath = settings.PackagesPath, PackageOverwriteMode = settings.PackageOverwriteMode, LuceneMergeFactor = settings.LuceneMergeFactor }; cfg.Initialize(); return(cfg); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var cfg = new LuceneRepositoryConfigurator { EnablePackageFileWatcher = true, LuceneIndexPath = @"D:\Workspace\NuGet.Lucene\SampleData\Lucene", PackagePath = @"D:\Workspace\NuGet.Lucene\SampleData\Packages" }; cfg.Initialize(); kernel.Bind<LuceneRepositoryConfigurator>().ToConstant(cfg); kernel.Bind<ILucenePackageRepository>().ToConstant(cfg.Repository); GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel); }
public override void Load() { var cfg = new LuceneRepositoryConfigurator { EnablePackageFileWatcher = GetFlagFromAppSetting("enablePackageFileWatcher", true), GroupPackageFilesById = GetFlagFromAppSetting("groupPackageFilesById", true), LuceneIndexPath = MapPathFromAppSetting("lucenePath", "~/App_Data/Lucene"), PackagePath = MapPathFromAppSetting("packagesPath", "~/App_Data/Packages") }; cfg.Initialize(); Kernel.Components.Add<IInjectionHeuristic, NonDecoratedPropertyInjectionHeuristic>(); var routeMapper = new NuGetWebApiRouteMapper(RoutePathPrefix); var mirroringPackageRepository = MirroringPackageRepositoryFactory.Create( cfg.Repository, PackageMirrorTargetUrl, PackageMirrorTimeout, AlwaysCheckMirror); var userStore = InitializeUserStore(); Bind<NuGetWebApiRouteMapper>().ToConstant(routeMapper); Bind<ILucenePackageRepository>().ToConstant(cfg.Repository).OnDeactivation(_ => cfg.Dispose()); Bind<IMirroringPackageRepository>().ToConstant(mirroringPackageRepository); Bind<LuceneDataProvider>().ToConstant(cfg.Provider); Bind<UserStore>().ToConstant(userStore); var symbolsPath = MapPathFromAppSetting("symbolsPath", "~/App_Data/Symbols"); Bind<ISymbolSource>().ToConstant(new SymbolSource { SymbolsPath = symbolsPath }); Bind<SymbolTools>().ToConstant(new SymbolTools { SymbolPath = symbolsPath, ToolPath = MapPathFromAppSetting("debuggingToolsPath", "") }); LoadAuthentication(); var tokenSource = new ReusableCancellationTokenSource(); Bind<ReusableCancellationTokenSource>().ToConstant(tokenSource); var repository = base.Kernel.Get<ILucenePackageRepository>(); if (GetFlagFromAppSetting("synchronizeOnStart", true)) { repository.SynchronizeWithFileSystem(tokenSource.Token); } }
protected virtual ILuceneRepositoryConfigurator InitializeRepositoryConfigurator(INuGetWebApiSettings settings) { var cfg = new LuceneRepositoryConfigurator { EnablePackageFileWatcher = settings.EnablePackageFileWatcher, GroupPackageFilesById = settings.GroupPackageFilesById, LuceneIndexPath = settings.LucenePackagesIndexPath, PackagePath = settings.PackagesPath, PackageOverwriteMode = settings.PackageOverwriteMode, LuceneMergeFactor = settings.LuceneMergeFactor, DisablePackageHash = settings.DisablePackageHash, IgnorePackageFiles = settings.IgnorePackageFiles }; cfg.Initialize(); return cfg; }