public static void Register(HttpConfiguration config) { // Web API configuration and services var kernel = new StandardKernel(); // services dependency injections kernel.Bind<AuthenticationService>().To<AuthenticationService>().InSingletonScope(); kernel.Bind<IMessangerService>().To<MessangerService>().InSingletonScope(); kernel.Bind<IUserSearchingService>().To<UserSearchingService>().InSingletonScope(); kernel.Bind<MessageSearchingService>().To<MessageSearchingService>().InSingletonScope(); kernel.Bind<RegistrationService>().To<RegistrationService>().InSingletonScope(); kernel.Bind<CsvUserExportService>().To<CsvUserExportService>().InSingletonScope(); kernel.Bind<CsvMessageExportService>().To<CsvMessageExportService>().InSingletonScope(); kernel.Bind<IFriendsService>().To<FriendsService>().InSingletonScope(); kernel.Bind<UserValidationService>().To<UserValidationService>().InSingletonScope(); kernel.Bind<IMessageSearchingService>().To<MessageSearchingService>().InSingletonScope(); kernel.Bind<IMessageHistoryService>().To<MessagesHistoryService>().InSingletonScope(); kernel.Bind<IShortestUserPathService>().To<ShortestUserPathService>().InSingletonScope(); kernel.Bind<IPathProvider>().To<PathProvider>().InSingletonScope(); kernel.Bind<IImageService>().To<ImageService>().InSingletonScope(); kernel.Bind<IEndPointSetter>().To<AuthenticationService>().InSingletonScope(); config.DependencyResolver = new NinjectResolver(kernel); // Run Bot1 var botRunner = new BotRunner(); botRunner.Run(); // Configure Web API to use only bearer token authentication. config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
private static void Main() { using (var work = new UnitOfWork()) { var res = work.Cities; } var iOService = NinjectKernel.Get<IInputOutputSevice>(); // Run Bot1 var botRunner = new BotRunner(); botRunner.Run(); iOService.Out.WriteLine(Resources.InfoGreeting); Logger.Info(Resources.InfoGreeting); Command authenHandlers = GetAuthenticationCommand(); Command loggedInHandlers = GetLoggedInCommand(); var exitCommand = false; exitMethod = (sender, e) => { exitCommand = true; }; while (!exitCommand) { while (!CommandHandler.Session.IsLogged) { iOService.Out.WriteLine(Resources.InfoFirsUsage); iOService.Out.Write(Resources.InfoNewCommandLine); authenHandlers.Execute(iOService.In.ReadLine()); iOService.Out.WriteLine(); } iOService.Out.Write(Resources.InfoNewCommandLine); loggedInHandlers.Execute(iOService.In.ReadLine()); iOService.Out.WriteLine(); } }