private static void SetupAuth(IAppBuilder app, KernelBase 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 void Load_BindsIAuthorizationProviderToConstant() { IAuthorizationProvider expected = kernel.Get <IAuthorizationProvider>(); IAuthorizationProvider actual = kernel.Get <IAuthorizationProvider>(); Assert.AreSame(expected, actual); }
protected override void OnStart() { IProjectLogger logger = dependencyContainer.Get <IProjectLogger>(); logger.Open(); base.OnStart(); }
public TInterface Resolve <TInterface>() { try { return(kernel.Get <TInterface>()); } catch (ActivationException) { throw new NoRegisteredImplementationException(); } }
public static IMediator Setup(KernelBase dependencyContainer) { dependencyContainer.Components.Add <IBindingResolver, ContravariantBindingResolver>(); dependencyContainer.Bind(x => x.FromAssemblyContaining <IMediator>().SelectAllClasses().BindDefaultInterface()); dependencyContainer.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequest>().SelectAllClasses().InheritedFrom(typeof(IRequestHandler <,>)).BindAllInterfaces()); dependencyContainer.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequestValidator>().SelectAllClasses().InheritedFrom(typeof(AbstractValidator <>)).BindDefaultInterfaces()); dependencyContainer.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestPerformanceBehavior <,>)); dependencyContainer.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestValidationBehavior <,>)); dependencyContainer.Bind <ServiceFactory>().ToMethod(x => t => x.Kernel.TryGet(t)); return(dependencyContainer.Get <IMediator>()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += (sender, args) => { var result = DialogResult.Cancel; MessageBox.Show(args.Exception.Message, "Opps", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop); if (result == DialogResult.Abort) { Application.Exit(); } }; _kernel = NinjectConfiguration.GetKernel(); var mainForm = _kernel.Get <MainForm>(); Application.Run(mainForm); }
protected override object GetInstance(Type service, string key) { //return string.IsNullOrEmpty(key) ? _kernel.Get(service, key) : _kernel.Get(service); return(_kernel.Get(service)); }
public T Resolve <T>() where T : class { return(_kernel.Get <T>()); }
private void InitCommandEngine(KernelBase kernel) { if (logger.IsTraceEnabled) { logger.Trace("Настройка командного процессора..."); } commandEngine = kernel.Get <ICommandEngine>(); commandEngine.RegisterDefaultCommand(kernel.Get <WrongInputCommand>()); commandEngine.RegisterCommand("help", kernel.Get <HelpCommand>()); commandEngine.RegisterCommand("exit", kernel.Get <ExitCommand>()); commandEngine.RegisterCommand("pull", kernel.Get <PullCommand>()); commandEngine.RegisterCommand("list", kernel.Get <ListCommand>()); commandEngine.RegisterCommand("remove", kernel.Get <RemoveCommand>()); commandEngine.RegisterCommand("subs", kernel.Get <SubsCommand>()); commandEngine.RegisterCommand("addsub", kernel.Get <AddSubCommand>()); commandEngine.RegisterCommand("remsub", kernel.Get <RemoveSubCommand>()); commandEngine.RegisterCommand("path", kernel.Get <AppPathCommand>()); if (logger.IsTraceEnabled) { logger.Trace("Настройка командного процессора завершена."); } }
public static T GetFromFactory <T>(this KernelBase kernel, params object[] pars) { return(kernel.Get <IBindingFactory <T> >().CreateWithParams(pars)); }