public ShellForm(IKernel kernel) { Asserter.AssertIsNotNull(kernel, "kernel"); _kernel = kernel; _applicationService = _kernel.Get<IApplicationService>(); _storageService = _kernel.Get<IStorageService>(); _settingsService = _kernel.Get<ISettingsService>(); _siteService = _kernel.Get<ISiteService>(); _controller = _kernel.Get<ShellController>(); Asserter.AssertIsNotNull(_applicationService, "_applicationService"); Asserter.AssertIsNotNull(_storageService, "_storageService"); Asserter.AssertIsNotNull(_settingsService, "_settingsService"); Asserter.AssertIsNotNull(_siteService, "_siteService"); InitializeComponent(); _siteService.Register(SiteNames.ContentSite, contentPanel); _siteService.Register(SiteNames.NavigationSite, navigationPanel); _siteService.Register(SiteNames.ContentActionsSite, contentActionPanel); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); }
public static void MyClassInitialize(TestContext testContext) { kernel = new StandardKernel(new TestModule(), new DalIoc(), new BusinessIoc()); var auth = kernel.Get<IAuthenticationService>(); var uh = kernel.Get<IUtilisateurBusinessHelper<Utilisateur>>(); uh.DeleteAll().Wait(); uh.Create("999", "jcambert", "korben90", "Ambert", "Jean-Christophe", "*****@*****.**") .ContinueWith(x => { uh.AddRole(x.Result, "Administrateur"); }) .ContinueWith(x => { uh.Save(); }).ContinueWith(x => { var islogin = auth.Login("999", "jcambert", "korben90"); Assert.IsTrue(islogin.Result); }).Wait() ; ah = kernel.Get<ArticleBusinessHelper<Article>>(); ctx = kernel.Get<IDbContext>(); }
private async Task <bool> CheckCanCloseAppAsync() { var app = _kernel?.Get <IAppService>(); if (app != null) { bool isWorking = app.CheckIfStopCancelsWorkInProgress(); if (isWorking) { var window = this.MainWindow as MahApps.Metro.Controls.MetroWindow; RestoreFromTray(); window.Activate(); var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "OK", NegativeButtonText = "Cancel", AnimateShow = true, AnimateHide = false }; var result = await window.ShowMessageAsync("Quit?", "Sure you want to quit?", MessageDialogStyle.AffirmativeAndNegative, mySettings); return(result == MessageDialogResult.Affirmative); } } return(true); }
public static void ClassInit(TestContext context) { Debug.WriteLine("ClassInit " + context.TestName); kernel = Helper.CreateKernel(new TestModule(), new BusinessIoc(), new DalIoc()); var auth = kernel.Get<IAuthenticationService>(); var uh = kernel.Get<IUtilisateurBusinessHelper<Utilisateur>>(); uh.DeleteAll().Wait(); uh.Create("999", "jcambert", "korben90", "Ambert", "Jean-Christophe", "*****@*****.**") .ContinueWith(x => { uh.AddRole(x.Result, "Administrateur"); }) .ContinueWith(x => { uh.Save(); }).ContinueWith(x => { var islogin = auth.Login("999", "jcambert", "korben90"); Assert.IsTrue(islogin.Result); }).Wait() ; Helper.CreateStandardPParametres(true).Wait(); Helper.CreateStandardParametres(true).Wait(); }
public Form1(IKernel kernel) { #region Splash screen Start //this.Hide(); //Thread splashthread = new Thread(new ThreadStart(SplashScreen.ShowSplashScreen)); //splashthread.IsBackground = true; //splashthread.Start(); #endregion Kernel = kernel; UserRepository = Kernel.Get<UserRepository>(); SystemRepository = Kernel.Get<SystemRepository>(); UserDesktopRepository = Kernel.Get<UserDesktopRepository>(); InitializeComponent(); var details = UserRepository.GetSessionDetails(AppSettings.Instance.LiveUserAccount.Username); if (details.GoDaddyAccount == null && !string.IsNullOrEmpty(Settings.Default.GDUsername)) { details.GoDaddyAccount = new GoDaddyAccount() { AccountId = Guid.NewGuid(), AccountUsername = details.Username, Password = Settings.Default.GDPassword, Username = Settings.Default.GDUsername, UserID = AppSettings.Instance.LiveUserAccount.AccountID }; SystemRepository.SaveGodaddyAccount(details.GoDaddyAccount); } AppSettings.Instance.SessionDetails = details; AppSettings.Instance.GoDaddy = new GoDaddyAuctionSniper(AppSettings.Instance.SessionDetails.Username, Kernel.Get<IUserRepository>()); LoadAuctions(); Instance = this; //Login(); }
private static ICharacter SetupCharacter(IKernel kernel) { ICharacter adventurer = null; do { ConsoleKeyInfo option = Console.ReadKey(); switch (option.Key) { case ConsoleKey.Escape: Environment.Exit(0); break; case ConsoleKey.A: adventurer = kernel.Get<Warrior>(); Console.WriteLine("You are a Warrior"); break; case ConsoleKey.B: adventurer = kernel.Get<Elf>(); Console.WriteLine("You are a Elf"); break; case ConsoleKey.C: adventurer = kernel.Get<Wizard>(); Console.WriteLine("You are a Wizard"); break; } } while (adventurer == null); Console.WriteLine("Give a new name to your character\nName:"); adventurer.Name = Console.ReadLine(); return adventurer; }
private static void SetupAuth(IAppBuilder app, IKernel kernel) { app.UseFormsAuthentication(new FormsAuthenticationOptions { LoginPath = "/account/login", LogoutPath = "/account/logout", CookieHttpOnly = true, AuthenticationType = Constants.JabbRAuthType, CookieName = "jabbr.id", ExpireTimeSpan = TimeSpan.FromDays(30), DataProtection = kernel.Get<IDataProtection>(), Provider = kernel.Get<IFormsAuthenticationProvider>() }); //var config = new FederationConfiguration(loadConfig: false); //config.WsFederationConfiguration.Issuer = ""; //config.WsFederationConfiguration.Realm = "http://localhost:16207/"; //config.WsFederationConfiguration.Reply = "http://localhost:16207/wsfederation"; //var cbi = new ConfigurationBasedIssuerNameRegistry(); //cbi.AddTrustedIssuer("", ""); //config.IdentityConfiguration.AudienceRestriction.AllowedAudienceUris.Add(new Uri("http://localhost:16207/")); //config.IdentityConfiguration.IssuerNameRegistry = cbi; //config.IdentityConfiguration.CertificateValidationMode = X509CertificateValidationMode.None; //config.IdentityConfiguration.CertificateValidator = X509CertificateValidator.None; //app.UseFederationAuthentication(new FederationAuthenticationOptions //{ // ReturnPath = "/wsfederation", // SigninAsAuthenticationType = Constants.JabbRAuthType, // FederationConfiguration = config, // Provider = new FederationAuthenticationProvider() //}); app.Use(typeof(WindowsPrincipalHandler)); }
public override void OnClick(IKernel kernel) { Item.Server.Favorite = true; kernel.Get<IStorageService>().SaveChanges(); kernel.Get<IShellController>().CurrentView = Views.FavoritesServers; }
public SplashScreen(IKernel kernel) { InitializeComponent(); _kernel = kernel; _applicationService = kernel.Get<IApplicationService>(); _storageService = kernel.Get<IStorageService>(); }
public void Init() { ninject = new StandardKernel(new BindingsModule()); movementHandler = ninject.Get<IMovementHandler>(); player = ninject.Get<IPlayer>(); }
public static void RegisterGlobalFilters(GlobalFilterCollection filters, IKernel kernel) { filters.Add(new CustomHandleErrorAttribute(kernel.Get<ILog>())); filters.Add(new CultureFilterAttribute(CompositionRootHelper.GetLanguage(kernel))); filters.Add(new AccessAuthorizationFilter(() => kernel.Get<IIdentityService>())); }
public DataGenerator() { _ninjectKernel = new StandardKernel(new Modules.MockRepositoryModule()); _ninjectKernel.Bind<IClientService>().To<ClientService>(); _ninjectKernel.Bind<IUserAccountService>().To<UserAccountService>(); _clientService = _ninjectKernel.Get<IClientService>(); _userAccountService = _ninjectKernel.Get<IUserAccountService>(); }
public IOpenIDConnectService CreateOpenIDConnectService(IKernel iocKernel = null) { if (Instance == null) { Instance = iocKernel?.Get <IOpenIDConnectService>() ?? new OpenIDConnectService(); Instance.Configuration = iocKernel?.Get <IOpenIDConnectConfiguration>() ?? new OpenIDConnectConfiguration(); } return(Instance); }
public Patcher(IKernel kernel) { _kernel = kernel; _storageService = kernel.Get<IStorageService>(); _settingsService = kernel.Get<ISettingsService>(); if (string.IsNullOrEmpty(_settingsService.UltimaOnlineDirectory)) throw new Exception("ConnectUO was unable to find the directory that Ultima Online is installed to."); }
protected override void Configure() { _kernel = new Ninject.StandardKernel(); _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope(); _eventAggregator = _kernel.Get<IEventAggregator>(); // Singletons _kernel.Bind<Settings>().ToSelf().InSingletonScope(); _kernel.Bind<PumpController>().ToSelf().InSingletonScope(); _kernel.Bind<ElementController>().ToSelf().InSingletonScope(); _kernel.Bind<Hardware>().ToSelf().InSingletonScope(); _kernel.Bind<HardwareInitializer>().ToSelf().InSingletonScope(); var settings = _kernel.Get<Settings>(); // Use real hardware if we have a GpioController - else use fakeys var shouldUseRealHardware = (GpioController.GetDefault() != null); if (shouldUseRealHardware) { // Configure the ADC for inputs // _kernel.Bind<IAnalogToDigitalConvertor>().To<Mcp3208>(); _kernel.Bind<IAnalogToDigitalConvertor>().To<Mcp3008>().InSingletonScope(); // Configure the GPIO for outputs var gpioController = GpioController.GetDefault(); var pumpGpioPin = gpioController.OpenPin(settings.PumpGpioPin); var elementGpioPin = gpioController.OpenPin(settings.ElementGpioPin); // Use real inputs/outputs where requested _kernel.Bind<IOutputConnection>().To<GpioOutputConnection>(); _kernel.Bind<ITemperatureReader>().To<ThermistorTemperatureReader>(); // Get and configure the hardware object with correct pins etc var hardware = _kernel.Get<Hardware>(); // - GPIO Outputs (hardware.PumpOutputConnection as GpioOutputConnection)?.Configure(pumpGpioPin); (hardware.ElementOutputConnection as GpioOutputConnection)?.Configure(elementGpioPin); // - ADC inputs ((ThermistorTemperatureReader) hardware.RoofTemperatureReader).PinNumber = settings.RoofThermistorAdcPin; ((ThermistorTemperatureReader) hardware.TankTemperatureReader).PinNumber = settings.TankThermistorAdcPin; ((ThermistorTemperatureReader) hardware.InletTemperatureReader).PinNumber = settings.InletThermistorAdcPin; } else { // Use fake inputs / outputs where requested _kernel.Bind<IOutputConnection>().To<FakeOutputConnection>(); _kernel.Bind<ITemperatureReader>().To<FakeTemperatureReader>(); // Setup some initial values for fake readings var hardware = _kernel.Get<Hardware>(); ((FakeTemperatureReader) hardware.RoofTemperatureReader).FakeTemperatureDegC = 50; ((FakeTemperatureReader) hardware.InletTemperatureReader).FakeTemperatureDegC = 40; ((FakeTemperatureReader) hardware.TankTemperatureReader).FakeTemperatureDegC = 30; ((FakeOutputConnection) hardware.PumpOutputConnection).State = false; ((FakeOutputConnection) hardware.ElementOutputConnection).State = false; } }
public IOpenIDConnectService CreateOpenIDConnectService(IKernel iocKernel = null) { if (Instance == null) { Instance = iocKernel?.Get <IOpenIDConnectService>() ?? throw new InvalidOperationException("Dependency injection for 'IOpenIDConnectService' not found"); Instance.Configuration = iocKernel?.Get <IOpenIDConnectConfiguration>() ?? new OpenIDConnectConfiguration(); } return(Instance); }
public void SetUp() { _view = MockRepository.GenerateMock<ICradiatorView>(); _configSettings = MockRepository.GenerateMock<IConfigSettings>(); _configSettings.Expect(c => c.ProjectNameRegEx).Return(".*").Repeat.Any(); _kernel = new StandardKernel(new CradiatorNinjaModule(_view, _configSettings)); _factory = _kernel.Get<IWebClientFactory>(); _kernel.Get<BuildDataTransformer>(); }
public void Run(IKernel kernel) { var configuration = kernel.Get<Configuration>(); if (!configuration.OutputFolder.Exists) configuration.OutputFolder.Create(); var featureCrawler = kernel.Get<DirectoryTreeCrawler>(); GeneralTree<IDirectoryTreeNode> features = featureCrawler.Crawl(configuration.FeatureFolder); var documentationBuilder = kernel.Get<IDocumentationBuilder>(); documentationBuilder.Build(features); }
public GameServer(IKernel kernel) { Debug.WriteLine("GameServer::.ctor"); _kernel = kernel; _clientsManager = _kernel.Get<IClientsManager>(); _networkServer = _kernel.Get<INetworkServer>(); _worldManager = new WorldManager(); Controllers.ControllersRegistration.Register(); }
public static IArmorGenerator CreateWith(IKernel kernel) { var collectionsSelector = kernel.Get<ICollectionsSelector>(); var percentileSelector = kernel.Get<IPercentileSelector>(); var mundaneWeaponGenerator = kernel.Get<MundaneItemGenerator>(ItemTypeConstants.Armor); var magicalWeaponGenerator = kernel.Get<MagicalItemGenerator>(ItemTypeConstants.Armor); var generator = kernel.Get<Generator>(); return new ArmorGenerator(collectionsSelector, percentileSelector, mundaneWeaponGenerator, magicalWeaponGenerator, generator); }
public override void OnClick(IKernel kernel) { IStorageService storageService = kernel.Get<IStorageService>(); ISettingsService settingsService = kernel.Get<ISettingsService>(); ShellForm form = kernel.Get<ShellForm>(); Asserter.AssertIsNotNull(form, "form"); if (MessageBoxEx.Show(form, "This will remove all applied patches for this server from your computer. Are you sure you want to continue?", "ConnectUO 2.0", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { if (storageService.ServerIsCurrentlyBeingPlayed(Item.Server)) { MessageBoxEx.Show(form, "ConnectUO has detected that you are currently playing this server and cannot reset the patches until the Ultima Online client connected bas been closed.", "ConnectUO 2.0"); return; } else { storageService.ResetPatches((int)Item.Server.Id); try { string serverDirectory = Path.Combine(settingsService.PatchDirectory, Uri.EscapeDataString(Item.Server.Name)); if (Directory.Exists(serverDirectory)) { FileInfo[] files = new DirectoryInfo(serverDirectory).GetFiles(); for (int i = 0; i < files.Length; i++) { try { files[i].Delete(); } catch (Exception ex) { //These aren't crucial, just log as info... Tracer.Info(ex); } } } } catch (Exception ex) { //These aren't crucial, just log as info... Tracer.Info(ex); } } MessageBoxEx.Show(form, "Patch Reset Complete.", "ConnectUO 2.0"); } }
public override void OnClick(IKernel kernel) { ShellForm form = kernel.Get<ShellForm>(); IStorageService storageService = kernel.Get<IStorageService>(); if (MessageBoxEx.Show(form, "Are you sure you want to remove this server?", "ConnectUO 2.0", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { storageService.DeleteServer(Item.Server); Item.Parent.RefreshDataSource(); } }
public UserInterfaceManager(IKernel kernel) { IDeviceProvider provider = kernel.Get<IDeviceProvider>(); provider.RenderForm.Resize += OnRenderFormResize; _device = provider.Device; _textureFactory = kernel.Get<ITextureFactory>(); _renderer = kernel.Get<IUserInterfaceRenderer>(); _elements = new List<Element>(); _projectionDirty = true; }
public frmMain(IKernel kernel) { _kernel = kernel; _applicationService = _kernel.Get<IApplicationService>(); _storageService = _kernel.Get<IStorageService>(); _settingsService = _kernel.Get<ISettingsService>(); InitializeComponent(); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); }
public LocalServerListControl(IKernel kernel) : base(kernel) { _shellController = kernel.Get<IShellController>(); _siteService = kernel.Get<ISiteService>(); _editLocalServerControl = kernel.Get<EditLocalServerControl>(); _addLocalServerButton = new ArrowButton(); _addLocalServerButton.Text = "Add Local Server"; _addLocalServerButton.Click += addLocalServerButton_Click; InitializeComponent(); }
static void Main(string[] args) { const string message = "Ground control to Major Tom!"; NinjectModule module = new SimpleModule(); kernel = new StandardKernel(module); var scenario1 = kernel.Get<Scenario1>(); var scenario2 = kernel.Get<Scenario2>(); scenario1.SendTheMessageYo(message); scenario2.SendTheMessageYo(message); }
public void RegisterComponents(IKernel container) { container.Rebind<IEventManager>().ToConstant(eventManager); container.Bind<IVersionOneProcessor>().ToConstant(v1Processor); container.Rebind<ILogger>().To<Logger>(); container.Bind<WorkitemWriterServiceConfiguration>().ToConstant(configuration); container.Bind<IWorkitemWriter>().To<WorkitemWriter>(); container.Bind<IWorkitemReader>().To<WorkitemReader>(); workitemWriter = container.Get<IWorkitemWriter>(); workitemReader = container.Get<IWorkitemReader>(); externalWorkitemQuerier = container.Get<ClosedExternalWorkitemQuerier>(); startupChecker = container.Get<StartupChecker>(); }
public Form1() { InitializeComponent(); _kernel = new StandardKernel(new FlooringMasteryModule()); _myOrderManger = _kernel.Get<OrderManager>(); _myProductManager = _kernel.Get<ProductManager>(); _myTaxRateManager = _kernel.Get<TaxRateManager>(); cmbProdType.DataSource = _myProductManager.GetAllProducts().Select(x => x.ProductType).ToList(); cmbState.DataSource = _myTaxRateManager.GetAllTaxRates().Select(x => x.State).ToList(); cmbTaxRate.DataSource = _myTaxRateManager.GetAllTaxRates().Select(x => x.TaxPercent).ToList(); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { kernel = new StandardKernel (new ServiceModule ()); providerService = kernel.Get<IProviderService> (); accountService = kernel.Get<IAccountService> (); Build (); Initialise (); CreateTreeViewUi (); ProviderAddedEvent += new ProviderAddedDelegate (Initialise); }
static void Main(string[] args) { AppKernel = new StandardKernel(new WeaponNinjectModule()); var warrior = AppKernel.Get<Warrior>(); warrior.Kill(); var otherWarrior = new OtherWarrior(); otherWarrior.Kill(); var anotherWarrior = AppKernel.Get<AnotherWarrior>(); anotherWarrior.Kill(); Console.ReadLine(); }
private static void ConfigureMapping(IKernel kernel) { Mapper.Initialize(cfg => { cfg.ConstructServicesUsing(t => kernel.Get(t)); foreach (var profile in typeof (NinjectWebCommon).Assembly.GetTypes() .Where(t => t.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IMapper<,>)) && !t.IsGenericType)) { cfg.AddProfile(kernel.Get(profile) as Profile); } }); Mapper.AssertConfigurationIsValid(); }
private static IEventBus InitializeEventBus(IKernel kernel) { var bus = new InProcessEventBus(); bus.RegisterHandler<MeetingScheduledEvent> (kernel.Get<MeetingDenormalizer>()); bus.RegisterHandler<MeetingScheduledEvent> (kernel.Get<StatDenormalizer>()); bus.RegisterHandler<CommentAddedEvent> (kernel.Get<MeetingDenormalizer>()); bus.RegisterHandler<CommentAddedEvent> (kernel.Get<StatDenormalizer>()); return bus; }
public GBuffer(IKernel kernel) { IDeviceProvider provider = kernel.Get<IDeviceProvider>(); _device = provider.Device; _form = provider.RenderForm; }
/// <summary> /// Initializes the mapper classes from a certain type. /// </summary> /// <param name="kernel">The kernel.</param> public static void InitializeMapperClasses <T>(IKernel kernel = null) where T : AttributeMapper { if (TypesOverrides.Count > 0 && kernel != null) { foreach (var @override in TypesOverrides.Where(i => i.Value.Kernel != kernel)) { @override.Value.Kernel = kernel; @override.Value.OnKernelLoaded(); } return; } TypesOverrides.Clear(); var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Where(i => i.IsClass && !i.ContainsGenericParameters && i.IsSubclassOf(typeof(T))).ToList(); var mappers = types.Where(i => i.HasParameterlessContructor()) .Select(i => kernel?.Get(i) ?? Activator.CreateInstance(i)).OfType <T>() .ToList(); foreach (var type in mappers) { if (kernel != null) { type.Kernel = kernel; type.OnKernelLoaded(); } TypesOverrides.Add(type.BaseType, type); } }
private void GetOrder() { _kernel.Get <CourierGetOrderPresenter>().Run(); _view.Close(); }
public static T Get <T>() => Kernel.Get <T>();
public AwayFromLayout CreateAwayFromLayout() { return(new AwayFromLayout(kernel.Get <Formula>(), kernel.Get <ITileLocator>())); }
public TService Resolve <TService>() { return(_kernel.Get <TService>()); }
public override object GetInstance(Type type) { return(Kernel.Get(type)); }
public T Resolve <T>() { return(container.Get <T>()); }
public static T Resolve <T>() { return(_ninjectKernel.Get <T>()); }
public XmlHelper(IKernel kernel) { _kernel = kernel; _settingsCache = _kernel.Get <ISettings>(); }
public T GetViewModel <T>() where T : ViewModel { return(_kernel.Get <T>()); }
public static T Get <T>() { return(_kernel.Get <T>()); }
private void Initialize(IKernel kernel) { kernel.Bind <IFeedbackRepository>().ToMethod(t => kernel.Get <MockFeedbackRepository>().Object); kernel.Bind <IServerFileManager>().ToMethod(t => kernel.Get <MockServerFileManager>().Object); }
public virtual void OnError(Exception ex, IKernel services) { ICodeActivityExecutionContextAccessor executionContextAccessor = services.Get <ICodeActivityExecutionContextAccessor>(); executionContextAccessor.HandleException(ex); }
public static T GetInstance <T>() { return(kernel.Get <T>()); }
public static void RegisterRoutes(IKernel kernel, RouteCollection routes) { var configuration = kernel.Get <IServerConfiguration>(); GlobalConfiguration.Configuration.Formatters.Clear(); GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; var jsonFormatter = new JsonMediaTypeFormatter(); GlobalConfiguration.Configuration.Formatters.Add(jsonFormatter); GlobalConfiguration.Configuration.DependencyResolver = new NinjectWebApiDependencyResolver(kernel); GlobalConfiguration.Configuration.Filters.Add(new TraceExceptionFilterAttribute()); // Git Service routes.MapHttpRoute("git-info-refs-root", "info/refs", new { controller = "InfoRefs", action = "Execute" }); routes.MapHttpRoute("git-info-refs", configuration.GitServerRoot + "/info/refs", new { controller = "InfoRefs", action = "Execute" }); // Push url routes.MapHandler <ReceivePackHandler>(kernel, "git-receive-pack-root", "git-receive-pack", deprecated: false); routes.MapHandler <ReceivePackHandler>(kernel, "git-receive-pack", configuration.GitServerRoot + "/git-receive-pack", deprecated: false); // Fetch Hook routes.MapHandler <FetchHandler>(kernel, "fetch", "deploy", deprecated: false); // Clone url routes.MapHandler <UploadPackHandler>(kernel, "git-upload-pack-root", "git-upload-pack", deprecated: false); routes.MapHandler <UploadPackHandler>(kernel, "git-upload-pack", configuration.GitServerRoot + "/git-upload-pack", deprecated: false); // Custom GIT repositories, which can be served from any directory that has a git repo routes.MapHandler <CustomGitRepositoryHandler>(kernel, "git-custom-repository", "git/{*path}", deprecated: false); // Scm (deployment repository) routes.MapHttpRouteDual("scm-info", "scm/info", new { controller = "LiveScm", action = "GetRepositoryInfo" }); routes.MapHttpRouteDual("scm-clean", "scm/clean", new { controller = "LiveScm", action = "Clean" }); routes.MapHttpRouteDual("scm-delete", "scm", new { controller = "LiveScm", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") }); // Scm files editor routes.MapHttpRouteDual("scm-get-files", "scmvfs/{*path}", new { controller = "LiveScmEditor", action = "GetItem" }, new { verb = new HttpMethodConstraint("GET", "HEAD") }); routes.MapHttpRouteDual("scm-put-files", "scmvfs/{*path}", new { controller = "LiveScmEditor", action = "PutItem" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRouteDual("scm-delete-files", "scmvfs/{*path}", new { controller = "LiveScmEditor", action = "DeleteItem" }, new { verb = new HttpMethodConstraint("DELETE") }); // Live files editor routes.MapHttpRouteDual("vfs-get-files", "vfs/{*path}", new { controller = "Vfs", action = "GetItem" }, new { verb = new HttpMethodConstraint("GET", "HEAD") }); routes.MapHttpRouteDual("vfs-put-files", "vfs/{*path}", new { controller = "Vfs", action = "PutItem" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRouteDual("vfs-delete-files", "vfs/{*path}", new { controller = "Vfs", action = "DeleteItem" }, new { verb = new HttpMethodConstraint("DELETE") }); // Zip file handler routes.MapHttpRouteDual("zip-get-files", "zip/{*path}", new { controller = "Zip", action = "GetItem" }, new { verb = new HttpMethodConstraint("GET", "HEAD") }); routes.MapHttpRouteDual("zip-put-files", "zip/{*path}", new { controller = "Zip", action = "PutItem" }, new { verb = new HttpMethodConstraint("PUT") }); // Live Command Line routes.MapHttpRouteDual("execute-command", "command", new { controller = "Command", action = "ExecuteCommand" }, new { verb = new HttpMethodConstraint("POST") }); // Deployments routes.MapHttpRouteDual("all-deployments", "deployments", new { controller = "Deployment", action = "GetDeployResults" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("one-deployment-get", "deployments/{id}", new { controller = "Deployment", action = "GetResult" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("one-deployment-put", "deployments/{id}", new { controller = "Deployment", action = "Deploy", id = RouteParameter.Optional }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRouteDual("one-deployment-delete", "deployments/{id}", new { controller = "Deployment", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpRouteDual("one-deployment-log", "deployments/{id}/log", new { controller = "Deployment", action = "GetLogEntry" }); routes.MapHttpRouteDual("one-deployment-log-details", "deployments/{id}/log/{logId}", new { controller = "Deployment", action = "GetLogEntryDetails" }); // Deployment script routes.MapHttpRoute("get-deployment-script", "api/deploymentscript", new { controller = "Deployment", action = "GetDeploymentScript" }, new { verb = new HttpMethodConstraint("GET") }); // SSHKey routes.MapHttpRouteDual("get-sshkey", "sshkey", new { controller = "SSHKey", action = "GetPublicKey" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("put-sshkey", "sshkey", new { controller = "SSHKey", action = "SetPrivateKey" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRouteDual("delete-sshkey", "sshkey", new { controller = "SSHKey", action = "DeleteKeyPair" }, new { verb = new HttpMethodConstraint("DELETE") }); // Environment routes.MapHttpRouteDual("get-env", "environment", new { controller = "Environment", action = "Get" }, new { verb = new HttpMethodConstraint("GET") }); // Settings routes.MapHttpRouteDual("set-setting", "settings", new { controller = "Settings", action = "Set" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpRouteDual("get-all-settings", "settings", new { controller = "Settings", action = "GetAll" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("get-setting", "settings/{key}", new { controller = "Settings", action = "Get" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("delete-setting", "settings/{key}", new { controller = "Settings", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") }); // Diagnostics routes.MapHttpRouteDual("diagnostics", "dump", new { controller = "Diagnostics", action = "GetLog" }); routes.MapHttpRouteDual("diagnostics-set-setting", "diagnostics/settings", new { controller = "Diagnostics", action = "Set" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpRouteDual("diagnostics-get-all-settings", "diagnostics/settings", new { controller = "Diagnostics", action = "GetAll" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("diagnostics-get-setting", "diagnostics/settings/{key}", new { controller = "Diagnostics", action = "Get" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("diagnostics-delete-setting", "diagnostics/settings/{key}", new { controller = "Diagnostics", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") }); // Logs routes.MapHandlerDual <LogStreamHandler>(kernel, "logstream", "logstream/{*path}"); routes.MapHttpRoute("recent-logs", "api/logs/recent", new { controller = "Diagnostics", action = "GetRecentLogs" }, new { verb = new HttpMethodConstraint("GET") }); // Processes routes.MapHttpProcessesRoute("all-processes", "", new { controller = "Process", action = "GetAllProcesses" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("one-process-get", "/{id}", new { controller = "Process", action = "GetProcess" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("one-process-delete", "/{id}", new { controller = "Process", action = "KillProcess" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpProcessesRoute("one-process-dump", "/{id}/dump", new { controller = "Process", action = "MiniDump" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("start-process-profile", "/{id}/profile/start", new { controller = "Process", action = "StartProfileAsync" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpProcessesRoute("stop-process-profile", "/{id}/profile/stop", new { controller = "Process", action = "StopProfileAsync" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("all-threads", "/{id}/threads", new { controller = "Process", action = "GetAllThreads" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("one-process-thread", "/{processId}/threads/{threadId}", new { controller = "Process", action = "GetThread" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("all-modules", "/{id}/modules", new { controller = "Process", action = "GetAllModules" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpProcessesRoute("one-process-module", "/{id}/modules/{baseAddress}", new { controller = "Process", action = "GetModule" }, new { verb = new HttpMethodConstraint("GET") }); // Runtime routes.MapHttpRouteDual("runtime", "diagnostics/runtime", new { controller = "Runtime", action = "GetRuntimeVersions" }, new { verb = new HttpMethodConstraint("GET") }); // Hooks routes.MapHttpRouteDual("unsubscribe-hook", "hooks/{id}", new { controller = "WebHooks", action = "Unsubscribe" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpRouteDual("get-hook", "hooks/{id}", new { controller = "WebHooks", action = "GetWebHook" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("publish-hooks", "hooks/publish/{hookEventType}", new { controller = "WebHooks", action = "PublishEvent" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpRouteDual("get-hooks", "hooks", new { controller = "WebHooks", action = "GetWebHooks" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRouteDual("subscribe-hook", "hooks", new { controller = "WebHooks", action = "Subscribe" }, new { verb = new HttpMethodConstraint("POST") }); // Jobs routes.MapHttpWebJobsRoute("list-all-jobs", "", "", new { controller = "Jobs", action = "ListAllJobs" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("list-triggered-jobs", "triggered", "", new { controller = "Jobs", action = "ListTriggeredJobs" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("get-triggered-job", "triggered", "/{jobName}", new { controller = "Jobs", action = "GetTriggeredJob" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("invoke-triggered-job", "triggered", "/{jobName}/run", new { controller = "Jobs", action = "InvokeTriggeredJob" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpWebJobsRoute("get-triggered-job-history", "triggered", "/{jobName}/history", new { controller = "Jobs", action = "GetTriggeredJobHistory" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("get-triggered-job-run", "triggered", "/{jobName}/history/{runId}", new { controller = "Jobs", action = "GetTriggeredJobRun" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("create-triggered-job", "triggered", "/{jobName}", new { controller = "Jobs", action = "CreateTriggeredJob" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpWebJobsRoute("remove-triggered-job", "triggered", "/{jobName}", new { controller = "Jobs", action = "RemoveTriggeredJob" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpWebJobsRoute("get-triggered-job-settings", "triggered", "/{jobName}/settings", new { controller = "Jobs", action = "GetTriggeredJobSettings" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("set-triggered-job-settings", "triggered", "/{jobName}/settings", new { controller = "Jobs", action = "SetTriggeredJobSettings" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpWebJobsRoute("list-continuous-jobs", "continuous", "", new { controller = "Jobs", action = "ListContinuousJobs" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("get-continuous-job", "continuous", "/{jobName}", new { controller = "Jobs", action = "GetContinuousJob" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("disable-continuous-job", "continuous", "/{jobName}/stop", new { controller = "Jobs", action = "DisableContinuousJob" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpWebJobsRoute("enable-continuous-job", "continuous", "/{jobName}/start", new { controller = "Jobs", action = "EnableContinuousJob" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpWebJobsRoute("create-continuous-job", "continuous", "/{jobName}", new { controller = "Jobs", action = "CreateContinuousJob" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpWebJobsRoute("remove-continuous-job", "continuous", "/{jobName}", new { controller = "Jobs", action = "RemoveContinuousJob" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpWebJobsRoute("get-continuous-job-settings", "continuous", "/{jobName}/settings", new { controller = "Jobs", action = "GetContinuousJobSettings" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpWebJobsRoute("set-continuous-job-settings", "continuous", "/{jobName}/settings", new { controller = "Jobs", action = "SetContinuousJobSettings" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpWebJobsRoute("request-passthrough-continuous-job", "continuous", "/{jobName}/passthrough/{*path}", new { controller = "Jobs", action = "RequestPassthrough" }, new { verb = new HttpMethodConstraint("GET", "HEAD", "PUT", "POST", "DELETE", "PATCH") }); // Web Jobs as microservice routes.MapHttpRoute("list-triggered-jobs-swagger", "api/triggeredwebjobsswagger", new { controller = "Jobs", action = "ListTriggeredJobsInSwaggerFormat" }, new { verb = new HttpMethodConstraint("GET") }); // SiteExtensions routes.MapHttpRoute("api-get-remote-extensions", "api/extensionfeed", new { controller = "SiteExtension", action = "GetRemoteExtensions" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("api-get-remote-extension", "api/extensionfeed/{id}", new { controller = "SiteExtension", action = "GetRemoteExtension" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("api-get-local-extensions", "api/siteextensions", new { controller = "SiteExtension", action = "GetLocalExtensions" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("api-get-local-extension", "api/siteextensions/{id}", new { controller = "SiteExtension", action = "GetLocalExtension" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("api-uninstall-extension", "api/siteextensions/{id}", new { controller = "SiteExtension", action = "UninstallExtension" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpRoute("api-install-update-extension", "api/siteextensions/{id}", new { controller = "SiteExtension", action = "InstallExtension" }, new { verb = new HttpMethodConstraint("PUT") }); // Functions routes.MapHttpRoute("get-functions-host-settings", "api/functions/config", new { controller = "Function", action = "GetHostSettings" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("put-functions-host-settings", "api/functions/config", new { controller = "Function", action = "PutHostSettings" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRoute("api-sync-functions", "api/functions/synctriggers", new { controller = "Function", action = "SyncTriggers" }, new { verb = new HttpMethodConstraint("POST") }); // This route only needed for temporary workaround. Will yank when /syncfunctionapptriggers is supported in ARM routes.MapHttpRoute("api-sync-functions-tmphack", "functions/listsynctriggers", new { controller = "Function", action = "SyncTriggers" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpRoute("put-function", "api/functions/{name}", new { controller = "Function", action = "CreateOrUpdate" }, new { verb = new HttpMethodConstraint("PUT") }); routes.MapHttpRoute("list-functions", "api/functions", new { controller = "Function", action = "List" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("get-function", "api/functions/{name}", new { controller = "Function", action = "Get" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("list-secrets", "api/functions/{name}/listsecrets", new { controller = "Function", action = "GetSecrets" }, new { verb = new HttpMethodConstraint("POST") }); routes.MapHttpRoute("get-masterkey", "api/functions/admin/masterkey", new { controller = "Function", action = "GetMasterKey" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("get-admintoken", "api/functions/admin/token", new { controller = "Function", action = "GetAdminToken" }, new { verb = new HttpMethodConstraint("GET") }); routes.MapHttpRoute("delete-function", "api/functions/{name}", new { controller = "Function", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") }); routes.MapHttpRoute("download-functions", "api/functions/admin/download", new { controller = "Function", action = "DownloadFunctions" }, new { verb = new HttpMethodConstraint("GET") }); // Docker Hook Endpoint if (!OSDetector.IsOnWindows()) { routes.MapHttpRoute("docker", "docker/hook", new { controller = "Docker", action = "ReceiveHook" }, new { verb = new HttpMethodConstraint("POST") }); } // catch all unregistered url to properly handle not found // this is to work arounf the issue in TraceModule where we see double OnBeginRequest call // for the same request (404 and then 200 statusCode). routes.MapHttpRoute("error-404", "{*path}", new { controller = "Error404", action = "Handle" }); }
/// <summary> /// Used to initialize service dependencies. This method is called before OnInitialize(), /// and should include common behaviour for a family of services. /// When overriden on the family services base, it is recommended to mark it as sealed, /// to prevent concrete services from overriding the common behaviour. /// </summary> /// <param name="kernel"></param> protected virtual void PreInitialize(IKernel kernel) { var metricsInitializer = kernel.Get <IMetricsInitializer>(); metricsInitializer.Init(); }
private static void RegisterServices(IKernel kernel) { var serverConfiguration = new ServerConfiguration(); // Make sure %HOME% is correctly set EnsureHomeEnvironmentVariable(); EnsureSiteBitnessEnvironmentVariable(); IEnvironment environment = GetEnvironment(); EnsureDotNetCoreEnvironmentVariable(environment); // Add various folders that never change to the process path. All child processes will inherit PrependFoldersToPath(environment); // Per request environment kernel.Bind <IEnvironment>().ToMethod(context => GetEnvironment(context.Kernel.Get <IDeploymentSettingsManager>(), HttpContext.Current)) .InRequestScope(); // General kernel.Bind <IServerConfiguration>().ToConstant(serverConfiguration); kernel.Bind <IBuildPropertyProvider>().ToConstant(new BuildPropertyProvider()); System.Func <ITracer> createTracerThunk = () => GetTracer(kernel); System.Func <ILogger> createLoggerThunk = () => GetLogger(environment, kernel); // First try to use the current request profiler if any, otherwise create a new one var traceFactory = new TracerFactory(() => TraceServices.CurrentRequestTracer ?? createTracerThunk()); kernel.Bind <ITracer>().ToMethod(context => TraceServices.CurrentRequestTracer ?? NullTracer.Instance); kernel.Bind <ITraceFactory>().ToConstant(traceFactory); TraceServices.SetTraceFactory(createTracerThunk, createLoggerThunk); // Setup the deployment lock string lockPath = Path.Combine(environment.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); string sshKeyLockPath = Path.Combine(lockPath, Constants.SSHKeyLockFile); string hooksLockPath = Path.Combine(lockPath, Constants.HooksLockFile); _deploymentLock = new DeploymentLockFile(deploymentLockPath, kernel.Get <ITraceFactory>()); _deploymentLock.InitializeAsyncLocks(); var statusLock = new LockFile(statusLockPath, kernel.Get <ITraceFactory>()); var sshKeyLock = new LockFile(sshKeyLockPath, kernel.Get <ITraceFactory>()); var hooksLock = new LockFile(hooksLockPath, kernel.Get <ITraceFactory>()); kernel.Bind <IOperationLock>().ToConstant(sshKeyLock).WhenInjectedInto <SSHKeyController>(); kernel.Bind <IOperationLock>().ToConstant(statusLock).WhenInjectedInto <DeploymentStatusManager>(); kernel.Bind <IOperationLock>().ToConstant(hooksLock).WhenInjectedInto <WebHooksManager>(); kernel.Bind <IOperationLock>().ToConstant(_deploymentLock); var shutdownDetector = new ShutdownDetector(); shutdownDetector.Initialize(); IDeploymentSettingsManager noContextDeploymentsSettingsManager = new DeploymentSettingsManager(new XmlSettings.Settings(GetSettingsPath(environment))); TraceServices.TraceLevel = noContextDeploymentsSettingsManager.GetTraceLevel(); var noContextTraceFactory = new TracerFactory(() => GetTracerWithoutContext(environment, noContextDeploymentsSettingsManager)); var etwTraceFactory = new TracerFactory(() => new ETWTracer(string.Empty, string.Empty)); kernel.Bind <IAnalytics>().ToMethod(context => new Analytics(context.Kernel.Get <IDeploymentSettingsManager>(), context.Kernel.Get <IServerConfiguration>(), noContextTraceFactory)); // Trace unhandled (crash) exceptions. AppDomain.CurrentDomain.UnhandledException += (sender, args) => { var ex = args.ExceptionObject as Exception; if (ex != null) { kernel.Get <IAnalytics>().UnexpectedException(ex); } }; // Trace shutdown event // Cannot use shutdownDetector.Token.Register because of race condition // with NinjectServices.Stop via WebActivator.ApplicationShutdownMethodAttribute Shutdown += () => TraceShutdown(environment, noContextDeploymentsSettingsManager); // LogStream service // The hooks and log stream start endpoint are low traffic end-points. Re-using it to avoid creating another lock var logStreamManagerLock = hooksLock; kernel.Bind <LogStreamManager>().ToMethod(context => new LogStreamManager(Path.Combine(environment.RootPath, Constants.LogFilesPath), context.Kernel.Get <IEnvironment>(), context.Kernel.Get <IDeploymentSettingsManager>(), context.Kernel.Get <ITracer>(), shutdownDetector, logStreamManagerLock)); kernel.Bind <InfoRefsController>().ToMethod(context => new InfoRefsController(t => context.Kernel.Get(t))) .InRequestScope(); kernel.Bind <CustomGitRepositoryHandler>().ToMethod(context => new CustomGitRepositoryHandler(t => context.Kernel.Get(t))) .InRequestScope(); // Deployment Service kernel.Bind <ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment))) .InRequestScope(); kernel.Bind <IDeploymentSettingsManager>().To <DeploymentSettingsManager>() .InRequestScope(); kernel.Bind <IDeploymentStatusManager>().To <DeploymentStatusManager>() .InRequestScope(); kernel.Bind <ISiteBuilderFactory>().To <SiteBuilderFactory>() .InRequestScope(); kernel.Bind <IWebHooksManager>().To <WebHooksManager>() .InRequestScope(); ITriggeredJobsManager triggeredJobsManager = new TriggeredJobsManager( etwTraceFactory, kernel.Get <IEnvironment>(), kernel.Get <IDeploymentSettingsManager>(), kernel.Get <IAnalytics>(), kernel.Get <IWebHooksManager>()); kernel.Bind <ITriggeredJobsManager>().ToConstant(triggeredJobsManager) .InTransientScope(); TriggeredJobsScheduler triggeredJobsScheduler = new TriggeredJobsScheduler( triggeredJobsManager, etwTraceFactory, environment, kernel.Get <IAnalytics>()); kernel.Bind <TriggeredJobsScheduler>().ToConstant(triggeredJobsScheduler) .InTransientScope(); IContinuousJobsManager continuousJobManager = new ContinuousJobsManager( etwTraceFactory, kernel.Get <IEnvironment>(), kernel.Get <IDeploymentSettingsManager>(), kernel.Get <IAnalytics>()); OperationManager.SafeExecute(triggeredJobsManager.CleanupDeletedJobs); OperationManager.SafeExecute(continuousJobManager.CleanupDeletedJobs); kernel.Bind <IContinuousJobsManager>().ToConstant(continuousJobManager) .InTransientScope(); kernel.Bind <ILogger>().ToMethod(context => GetLogger(environment, context.Kernel)) .InRequestScope(); kernel.Bind <IDeploymentManager>().To <DeploymentManager>() .InRequestScope(); kernel.Bind <ISSHKeyManager>().To <SSHKeyManager>() .InRequestScope(); kernel.Bind <IRepositoryFactory>().ToMethod(context => _deploymentLock.RepositoryFactory = new RepositoryFactory(context.Kernel.Get <IEnvironment>(), context.Kernel.Get <IDeploymentSettingsManager>(), context.Kernel.Get <ITraceFactory>())) .InRequestScope(); kernel.Bind <IApplicationLogsReader>().To <ApplicationLogsReader>() .InSingletonScope(); // Git server kernel.Bind <IDeploymentEnvironment>().To <DeploymentEnvrionment>(); kernel.Bind <IGitServer>().ToMethod(context => new GitExeServer(context.Kernel.Get <IEnvironment>(), _deploymentLock, GetRequestTraceFile(context.Kernel), context.Kernel.Get <IRepositoryFactory>(), context.Kernel.Get <IDeploymentEnvironment>(), context.Kernel.Get <IDeploymentSettingsManager>(), context.Kernel.Get <ITraceFactory>())) .InRequestScope(); // Git Servicehook parsers kernel.Bind <IServiceHookHandler>().To <GenericHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <GitHubHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <BitbucketHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <BitbucketHandlerV2>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <DropboxHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <CodePlexHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <CodebaseHqHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <GitlabHqHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <GitHubCompatHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <KilnHgHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <VSOHandler>().InRequestScope(); kernel.Bind <IServiceHookHandler>().To <OneDriveHandler>().InRequestScope(); // SiteExtensions kernel.Bind <ISiteExtensionManager>().To <SiteExtensionManager>().InRequestScope(); // Functions kernel.Bind <IFunctionManager>().To <FunctionManager>().InRequestScope(); // Command executor kernel.Bind <ICommandExecutor>().To <CommandExecutor>().InRequestScope(); MigrateSite(environment, noContextDeploymentsSettingsManager); RemoveOldTracePath(environment); RemoveTempFileFromUserDrive(environment); // Temporary fix for https://github.com/npm/npm/issues/5905 EnsureNpmGlobalDirectory(); EnsureUserProfileDirectory(); // Skip SSL Certificate Validate if (System.Environment.GetEnvironmentVariable(SettingsKeys.SkipSslValidation) == "1") { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; } // Make sure webpages:Enabled is true. Even though we set it in web.config, it could be overwritten by // an Azure AppSetting that's supposed to be for the site only but incidently affects Kudu as well. ConfigurationManager.AppSettings["webpages:Enabled"] = "true"; // Kudu does not rely owin:appStartup. This is to avoid Azure AppSetting if set. if (ConfigurationManager.AppSettings["owin:appStartup"] != null) { // Set the appSetting to null since we cannot use AppSettings.Remove(key) (ReadOnly exception!) ConfigurationManager.AppSettings["owin:appStartup"] = null; } RegisterRoutes(kernel, RouteTable.Routes); // Register the default hubs route: ~/signalr GlobalHost.DependencyResolver = new SignalRNinjectDependencyResolver(kernel); GlobalConfiguration.Configuration.Filters.Add( new TraceDeprecatedActionAttribute( kernel.Get <IAnalytics>(), kernel.Get <ITraceFactory>())); GlobalConfiguration.Configuration.Filters.Add(new EnsureRequestIdHandlerAttribute()); }
public T Get <T>() { return(kernel.Get <T>()); }
public IHub Create(HubDescriptor descriptor) { return((IHub)_kernel.Get(descriptor.HubType)); }
public static T getValue <T>() { return(ikernel.Get <T>()); }
public TestsController() { _kernel = new StandardKernel(new NinjectServiceModule()); _testsService = _kernel.Get <TestsService>(); }
void ReloadContext() { bankDb.Dispose(); bankDb = kernel.Get <IBankDb>(); }
public void Dispatch <TParameter>(TParameter command) where TParameter : ICommand { var handler = _kernel.Get <ICommandHandler <TParameter> >(); handler.Execute(command); }
private void OnButtonCancelClick() { _kernel.Get <PurcpManagerPresenter>().Run(); _view.Close(); }
public T GetInstance <T>() { return(_ninjectKernel.Get <T>()); }
protected override object DoGetInstance(Type serviceType, string key) { return(_kernel.Get(serviceType)); }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { return(controllerType == null ? null : (IController)ninjectKernel.Get(controllerType)); }