public static TinyIoCContainer Initialize(InputOptions inputOptions, ILogger overrideLogger = null) { if (inputOptions == null) throw new ArgumentNullException("inputOptions"); var ioc = new TinyIoCContainer(); ILogger logger = overrideLogger ?? GetLogger(inputOptions.IsRequestingDebug); ioc.Register(logger); ioc.Resolve<SettingsOverrideApplicator>() .ApplySettingsFrom(inputOptions.SettingsOverride, Properties.Settings.Default); inputOptions.DumpValuesForDebug(logger); ioc.Register(ioc); ioc.Register(inputOptions); ioc.Register<WebServerLocation>().AsSingleton(); ioc.Register<IStatLightRunnerFactory, StatLightRunnerFactory>(); var eventAggregator = ioc.Resolve<EventAggregatorFactory>().Create(); ioc.Register(eventAggregator); ioc.Register<IEventPublisher>(eventAggregator); ioc.Register<IEventSubscriptionManager>(eventAggregator); ioc.Register<ResponseFactory>().AsSingleton(); ioc.Register<IPostHandler, PostHandler>().AsSingleton(); ioc.Register<ICurrentStatLightConfiguration, CurrentStatLightConfiguration>(); return ioc; }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { pipelines.BeforeRequest += (ctx) => { Log.Request(ctx.Request); var applicationService = container.Resolve<IApplicationService>(); var applicationId = context.Request.GetParam("applicationid"); if (!applicationService.IsRegistered(applicationId)) { Log.Write("Warning: Unauthorized Access Attempt. ApplicationId = " + applicationId); return HttpStatusCode.Unauthorized; } return null; }; pipelines.OnError += (ctx, ex) => { Log.Error("Unhandled error on request: " + context.Request.Url, ex); return null; }; pipelines.AfterRequest += (ctx) => { if (ctx.Response.StatusCode == HttpStatusCode.OK) container.Resolve<IRavenSessionProvider>().SaveChangesAfterRequest(); Log.Response(ctx.Response); }; base.RequestStartup(container, pipelines, context); }
public ViewModelLocator() { _container = TinyIoCContainer.Current; _container.Register<ClockViewModel>().AsSingleton(); _container.Register<AirportsViewModel>().AsSingleton(); _container.Register<IGetAirports, AirportNamesService>().AsSingleton(); _container.Register<IDispatchOnUIThread, DispatchAdapter>().AsSingleton(); _container.Register<IStoreObjects, ObjectStore>().AsSingleton(); #if DEBUG _container.Register<IGeolocation>(new PresetLocationService(63.433281, 10.419294, _container.Resolve<IDispatchOnUIThread>())); #else _container.Register<IGeolocation, MonoMobile.Extensions.Geolocation>(); #endif _container.Register(new NearestAirportService(_container.Resolve<IGeolocation>(), _container.Resolve<ITinyMessengerHub>())); if (DesignerProperties.IsInDesignTool) { //_container.Register<IStoreObjects, DesignTimeObjectStore>().AsSingleton(); _container.Register<IGetFlights, DesignTimeFlightsService>().AsSingleton(); _container.Register<IFlightsViewModel, FlightsDesignTimeViewModel>().AsSingleton(); } else { _container.Register<IGetFlights, FlightsService>().AsSingleton(); _container.Register<IFlightsViewModel, FlightsViewModel>().AsSingleton(); } }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); Persistence.Config.Init(); Domain.Config.Init(container.Resolve<IEventBus>(), container.Resolve<IViewRepository>()); }
public static void ConfigureContainer(TinyIoCContainer container) { var opts = container.Resolve<Options>(); container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.Register<InMemorySessionManager>().AsSingleton(); var sessionManager = container.Resolve<InMemorySessionManager>(); container.Register<ISessionHandler, InMemorySessionManager>(sessionManager); container.RegisterMultiple<IMessageLifecycleCallbackHandler>(new List<Type>() { typeof (SessionMessageLifecycleCallback), typeof (SpamManager) }).AsSingleton(); IPAddress ipAddress; if (IPAddress.TryParse(opts.IPAddress, out ipAddress) == false) { throw new ArgumentException("Failed to parse IP Address: " + opts.IPAddress); } container.Register(typeof(TorqueMasterServer), new TorqueMasterServer(container, new IPEndPoint(ipAddress, opts.Port))); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); var configuration = new BasicAuthenticationConfiguration(container.Resolve<IUserValidator>(), "test-realm"); BasicAuthentication.Enable(pipelines,configuration); var stateless = new StatelessAuthenticationConfiguration(c => { const string key = "X-Auth-Token"; string token = null; if (c.Request.Headers.Authorization == null || !c.Request.Headers.Authorization.Any()) { _log.ErrorFormat("No request headers are present in the request {0}", c); return null; } if (c.Request.Headers.FirstOrDefault(f => f.Key == key).Value == null || string.IsNullOrEmpty(c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First())) { _log.ErrorFormat("No Key present in the request headers"); return null; } token = c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First(); _log.InfoFormat("Token used {0}", token); var user = container.Resolve<IUserApiMapper>(); return user.GetUserFromToken(token); }); StatelessAuthentication.Enable(pipelines, stateless); }
protected void Register(TinyIoCContainer container) { Configure(container); container.Register<IMappingProvider>(new DefaultMappingProvider(container.ResolveAll<IMap>())); container.Register<IConnectionStringProvider>(new DefaultConnectionStringProvider("ApplicationConnectionString")); container.Register<IDatabaseFactory>(new DatabaseFactory(container.Resolve<IConnectionStringProvider>(), container.Resolve<IMappingProvider>())); container.Register<IDatabase>(container.Resolve<IDatabaseFactory>().GetDatabase()); }
private static void InitializeContext(TinyIoCContainer container) { container.Register<FeatureContext>().AsSingleton(); container.Register<ScenarioContext>().AsSingleton(); container.Register<StepContext>().AsSingleton(); container.Register<IContextHandler, ContextHandler>().AsSingleton(); var r = new RunContext(container.Resolve<IContextHandler>(), container.Resolve<HooksHandler>()); container.Register<IRunContext>(r); container.Register<IRunContextEvents>(r); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { _logger.Info("Starting NzbDrone API"); RegisterPipelines(pipelines); container.Resolve<DatabaseTarget>().Register(); container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent()); ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve<NzbDroneErrorPipeline>().HandleException); }
protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context) { base.RequestStartup(container, pipelines, context); var formsAuthenticationConfiguration = new FormsAuthenticationConfiguration { RedirectUrl = Route.Login, UserMapper = container.Resolve<IUserMapper>(), }; FormsAuthentication.Enable( pipelines, formsAuthenticationConfiguration ); LayoutViewBagInitializer.Enable( pipelines, container.Resolve<IDatabase>() ); }
private static TinyIoCContainer CreateHelperLogBuilderContainer(TinyIoCContainer container) { var logContainer = new TinyIoCContainer(); logContainer.Register<IClientMessenger>((c, p) => container.Resolve<IClientMessenger>()); logContainer.Register<IMemoryLog>((c, p) => container.Resolve<IMemoryLog>()); logContainer.Register<FileLogFileNameProvider>(); logContainer.Register<FileLog>(); logContainer.Register<ILog>((c,p) => new CompositeLog(new List<ILog>() { c.Resolve<IMemoryLog>(), c.Resolve<FileLog>() })); return logContainer; }
public void Install(TinyIoCContainer container) { serviceProvider = container.Resolve<IServiceProvider>(); menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (menuCommandService == null) return; pluginConfiguration = container.Resolve<IPluginConfiguration>(); pluginConfiguration.PropertyChanged += SetButtonState; solutionEvents = container.Resolve<ISolutionEventsListener>(); solutionEvents.AfterSolutionLoaded += SolutionLoaded; solutionEvents.BeforeSolutionClosed += SolutionClosed; var vs = container.Resolve<IVisualStudioService>(); InstallMenuCommands(vs.IsSolutionOpen); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); container.Register<ISearchService<BlogPost>, SearchService>(); if (!Directory.Exists(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["IndexPath"]))) { var searchService = container.Resolve<ISearchService<BlogPost>>(); var blogService = container.Resolve<IBlogService>(); new Task(() => searchService.Index(blogService.LoadAll())).Start(); } DiagnosticsHook.Disable(pipelines); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { Logger.Info("Starting NzbDrone API"); if (RuntimeInfoBase.IsProduction) { DiagnosticsHook.Disable(pipelines); } RegisterPipelines(pipelines); container.Resolve<DatabaseTarget>().Register(); container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent()); }
public StatLightRunnerFactory(ILogger logger, TinyIoCContainer ioc) { if (logger == null) throw new ArgumentNullException("logger"); if (ioc == null) throw new ArgumentNullException("ioc"); _ioc = ioc; _logger = logger; _eventSubscriptionManager = ioc.Resolve<IEventSubscriptionManager>(); _eventPublisher = ioc.Resolve<IEventPublisher>(); _ioc.ResolveAndAddToEventAggregator<ConsoleDebugListener>(); _ioc.Resolve<ExtensionResolver>().AddExtensionsToEventAggregator(); }
private static void SetUpSilverlightResultsHandler(TinyIoCContainer ioc, IEnumerable<ClassTask> testClasses, IEnumerable<MethodTask> testMethods) { var silverlightResultsHandler = new SilverlightResultsHandler(testClasses, testMethods); var eventSubscriptionManager = ioc.Resolve<IEventSubscriptionManager>(); eventSubscriptionManager.AddListener(silverlightResultsHandler); }
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { base.ConfigureRequestContainer(container, context); var store = container.Resolve<IDocumentStore>(); container.Register<IDocumentSession>(store.OpenSession()); }
protected override void ApplicationStartup( TinyIoCContainer container, IPipelines pipelines) { CookieBasedSessions.Enable(pipelines); var rootPathProvider = container.Resolve<IRootPathProvider>(); if (rootPathProvider == null) throw new InvalidOperationException("Could not resolve root path provider in bootstrapper."); fn.SetRootPath(rootPathProvider.GetRootPath()); fn.SetConfiguration(new Configuration(new ConfigurationReader(prefix: "RpgRooms"))); fn.SetKeyGenerator(new PassphraseKeyGenerator(fn.GetConfiguration().Passphrase, new byte[8])); fn.SetEncryptionProvider(new RijndaelEncryptionProvider(fn.GetKeyGenerator())); fn.SetSignatureProvider(new DefaultHmacProvider(fn.GetKeyGenerator())); fn.SetMailSenderConfiguration(fn.MakeMailSenderConfiguration(fn.GetConfiguration(), fn.GetRootPath())); fn.SetDocumentStore(fn.MakeDocumentStore(fn.GetConfiguration())); fn.InitializeDocumentStore(fn.GetDocumentStore()); fn.SetPostHandlers(new List<Func<IDocumentSession, IMember, IRoom, string, PostHandlerOutput[]>> { PostHandlers.RollCommand, PostHandlers.InviteCommand, PostHandlers.InvitationsCommand, PostHandlers.OOCMessage, PostHandlers.NPCDialogue, PostHandlers.GMNarration, PostHandlers.PCDialogue, PostHandlers.PCNarration }); pipelines.BeforeRequest.AddItemToEndOfPipeline(PipelineFunctions.RestoreIdentity); pipelines.BeforeRequest.AddItemToEndOfPipeline(PipelineFunctions.EnsureSignedUp); pipelines.AfterRequest.AddItemToEndOfPipeline(PipelineFunctions.AddAlert); pipelines.AfterRequest.AddItemToEndOfPipeline(PipelineFunctions.AddTwitterAuthCookie); }
//protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container) //{ // // We don't call "base" here to prevent auto-discovery of // // types/dependencies //} //protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) //{ // base.ConfigureRequestContainer(container, context); // // Here we register our user mapper as a per-request singleton. // // As this is now per-request we could inject a request scoped // // database "context" or other request scoped services. // container.Register<IUserMapper, UserDatabase>(); //} protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context) { // At request startup we modify the request pipelines to // include forms authentication - passing in our now request // scoped user name mapper. // // The pipelines passed in here are specific to this request, // so we can add/remove/update items in them as we please. var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = requestContainer.Resolve<IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); pipelines.AfterRequest.AddItemToEndOfPipeline(x => { if (x.CurrentUser != null) x.ViewBag.CurrentUserName = x.CurrentUser.UserName; else x.ViewBag.CurrentUserName = null; }); }
public AdminNonsecureModule(TinyIoCContainer container) { Get["/Login"] = parameters => { return View["Views/Login.cshtml"]; }; Post["/Login"] = parameters => { using (var repository = container.Resolve<IRepository>()) { var userGuid = UserMapper.ValidateUser(repository, (string)this.Request.Form.Username, (string)this.Request.Form.Password); if (userGuid == null) { return null; } else { return this.LoginAndRedirect(userGuid.Value); } } }; Get["/Logout"] = parameters => { return this.Logout("~/Login"); }; }
public static void ApplicationConfiguration(TinyIoCContainer container, IPipelines pipelines) { var cryptographyConfiguration = new CryptographyConfiguration( new RijndaelEncryptionProvider(new PassphraseKeyGenerator("SuperSecretPass", new byte[] {1, 2, 3, 4, 5, 6, 7, 8})), new DefaultHmacProvider(new PassphraseKeyGenerator("UberSuperSecure", new byte[] {1, 2, 3, 4, 5, 6, 7, 8}))); pipelines.AfterRequest.AddItemToEndOfPipeline(x => { x.Response.Headers.Add("Access-Control-Allow-Origin", "*"); x.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS"); }); var formsAuthentication = new FormsAuthenticationConfiguration() { CryptographyConfiguration = cryptographyConfiguration, RedirectUrl = "~/weblogin", UserMapper = container.Resolve<IUserMapper>(), }; Nancy.Json.JsonSettings.MaxJsonLength = int.MaxValue; FormsAuthentication.Enable(pipelines, formsAuthentication); GlobalHost.DependencyResolver = new TinyIoCDependencyResolver(container); container.Register(typeof (StartableManager), new StartableManager(container)); }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { var formsAuthConfig = new FormsAuthenticationConfiguration { RedirectUrl = "~/login", UserMapper = container.Resolve<IUserMapper>() }; FormsAuthentication.Enable(pipelines, formsAuthConfig); pipelines.AfterRequest += ctx => { var dbContext = container.Resolve<SmartFlowContext>(); dbContext.SaveChanges(); }; pipelines.OnError += (ctx, ex) => { var logger = container.Resolve<TextFileLogger>(); logger.Write("Error", Enums.LogLevel.ApplicationError, ex); return ErrorResponse.FromException(ex); }; base.RequestStartup(container, pipelines, context); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); //var configuration = new StatelessAuthenticationConfiguration(context => //{ // var token = context.AuthorizationHeaderToken(); // var authenticator = container.Resolve<IAuthenticateUser>(); // return string.IsNullOrWhiteSpace(token) ? null : authenticator != null ? authenticator.GetUserIdentity(token) : null; //}); //StatelessAuthentication.Enable(pipelines, configuration); pipelines.EnableStatelessAuthentication(container.Resolve<IAuthenticateUser>()); pipelines.EnableCors(); // cross origin resource sharing pipelines.EnableMonitoring(); //Make every request SSL based //pipelines.BeforeRequest += ctx => //{ // return (!ctx.Request.Url.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) ? // (Response)HttpStatusCode.Unauthorized : // null; //}; }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = container.Resolve<IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); CookieBasedSessions.Enable(pipelines); pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => { if (Helper.Settings.Instance.Client.CanConnect) return null; else { if (String.Compare(ctx.Request.Path, "/notavailable", true) == 0) { return null; } return new RedirectResponse("/notavailable"); } }); base.RequestStartup(container, pipelines, context); }
// The bootstrapper enables you to reconfigure the composition of the framework, // by overriding the various methods and properties. // For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { container.Register<IStorage, Storage>().AsSingleton(); container.Register<CredentialsStorage>().AsSingleton(); var serverScheduler = new ServerScheduler(container.Resolve<IStorage>()); serverScheduler.Start(); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); var mixFeeds = container.Resolve<MixFeeds>(); mixFeeds.ForMyNeeds(); }
protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context) { base.RequestStartup(container, pipelines, context); pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => { var documentStore = container.Resolve<IDocumentStore>(); var documentSession = container.Resolve<IDocumentSession>(); if (ctx.Response.StatusCode != HttpStatusCode.InternalServerError) { documentSession.SaveChanges(); } documentSession.Dispose(); documentStore.Dispose(); }); }
protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { base.ApplicationStartup(container, pipelines); CookieBasedSessions.Enable(pipelines); Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("views/", viewName)); Conventions.StaticContentsConventions.Add( StaticContentConventionBuilder.AddDirectory("assets", @"assets") ); container.Register<IFlexUserStore, FlexMembershipUserStore<User, Role>>(); container.Register(typeof(IDocumentStore), InitDocStore()); container.Register(typeof(IDocumentSession), (c, overloads) => c.Resolve<IDocumentStore>().OpenSession()); var cryptographyConfiguration = new CryptographyConfiguration( new RijndaelEncryptionProvider(new PassphraseKeyGenerator(Configuration.EncryptionKey, new byte[] { 8, 2, 10, 4, 68, 120, 7, 14 })), new DefaultHmacProvider(new PassphraseKeyGenerator(Configuration.HmacKey, new byte[] { 1, 20, 73, 49, 25, 106, 78, 86 }))); var authenticationConfiguration = new FormsAuthenticationConfiguration() { CryptographyConfiguration = cryptographyConfiguration, RedirectUrl = "/login", UserMapper = container.Resolve<IUserMapper>(), }; FormsAuthentication.Enable(pipelines, authenticationConfiguration); FlexMembershipProvider.RegisterClient( new GoogleOpenIdClient(), "Google", new Dictionary<string, object>()); }
protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context) { base.RequestStartup(requestContainer, pipelines, context); // At request startup we modify the request pipelines to // include forms authentication - passing in our now request // scoped user name mapper. // // The pipelines passed in here are specific to this request, // so we can add/remove/update items in them as we please. var loginService = requestContainer.Resolve<LoginService>(); var authConfiguration = new StatelessAuthenticationConfiguration(c => { var apiKeyFromRequest = ((DynamicDictionaryValue)c.Request.Query.ApiKey).Value as ApiKey ?? ((DynamicDictionaryValue)c.Request.Form.ApiKey).Value as ApiKey; if (apiKeyFromRequest == null) return null; if (loginService.IsApiKeyValid(apiKeyFromRequest)) { return new UserIdentity(apiKeyFromRequest.Username, new List<string>()); } return null; }); StatelessAuthentication.Enable(pipelines, authConfiguration); }
public HoganPipeline_Tests() { var container = new TinyIoCContainer(); container.Register<IUrlModifier>(new VirtualDirectoryPrepender("/")); container.Register<IUrlGenerator>((c, n) => new UrlGenerator(c.Resolve<IUrlModifier>(), "")); pipeline = container.Resolve<HoganPipeline>(); }
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { base.ConfigureRequestContainer(container, context); // Need a new CloudTableClient per request, it's not thread safe var tableClient = container.Resolve <CloudStorageAccount>().CreateCloudTableClient(); tableClient.RetryPolicy = new NoRetry(); container.Register <ITableStorageProvider>((c, p) => new TableStorageProvider(tableClient)); }
protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context) { var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = requestContainer.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); }
public App() { InitializeComponent(); Container = new TinyIoCContainer(); Container.RegisterClient(); using (UserDialogs.Instance.Loading("Loading data...")) { MainPage = new NavigationPage(Container.Resolve <LoginPage>()); } }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); var configuration = new BasicAuthenticationConfiguration( container.Resolve <IUserValidator>(), "MessageVault" ); pipelines.EnableBasicAuthentication(configuration); }
private static void RegisterEDWAdminRoleSyncService(TinyIoCContainer container) { if (container.Resolve <DefaultPropertySettings>().DualStoreEDWAdminPermissions) { container.Register <IEDWAdminRoleSyncService, EDWAdminRoleSyncService>(); } else { container.Register <IEDWAdminRoleSyncService, DisableEDWAdminRoleSyncService>(); } }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { var configuration = new StatelessAuthenticationConfiguration(ctx => { var jwtToken = ctx.Request.Headers.Authorization; if (string.IsNullOrEmpty(jwtToken)) { jwtToken = ctx.Request.Query.Authorization; } if (string.IsNullOrEmpty(jwtToken)) { jwtToken = ctx.Request.Form.Authorization; } try { var ssa = container.Resolve <SuperSimpleAuth>(); var user = ssa.Validate(jwtToken); //claims if using later versions of nancy //var claims = new List<Claim>(); //foreach(var role in user.Roles) //{ // foreach(var permission in role.Permissions) // { // claims.Add(new Claim(role.Name, permission)); // } //} //var identity = new ClaimsIdentity( // new GenericIdentity(user.UserName), // claims, // "Jwt", // "SSA", // "SSA"); var identity = new NancyUserIdentity(user); //return new ClaimsPrincipal(identity); return(identity); } catch (Exception exc) { return(null); } }); StatelessAuthentication.Enable(pipelines, configuration); }
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { base.ConfigureRequestContainer(container, context); container.Register <IUserMapper, UserMapper>(); var docStore = container.Resolve <DocumentStore>("DocStore"); var documentSession = docStore.OpenSession(); container.Register <IDocumentSession>(documentSession); }
private static void OutputSettings(TinyIoCContainer container) { var settings = container.Resolve <IGlobalSettings>(); foreach (var propertyInfo in settings.GetType().GetProperties()) { var getter = propertyInfo.GetGetMethod(); Console.WriteLine($" {propertyInfo.Name} = {getter.Invoke(settings, new object[] {})}"); } Console.WriteLine(); }
public IRunner CreateContinuousTestRunner(IEnumerable <StatLightConfiguration> statLightConfigurations) { if (statLightConfigurations == null) { throw new ArgumentNullException("statLightConfigurations"); } var webServer = _ioc.Resolve <InMemoryWebServer>(); IEnumerable <IWebBrowser> webBrowsers = GetWebBrowsers().ToList(); IDialogMonitorRunner dialogMonitorRunner = SetupDialogMonitorRunner(_logger, webBrowsers); StartupBrowserCommunicationTimeoutMonitor(); CreateAndAddConsoleResultHandlerToEventAggregator(); return(new ContinuousConsoleRunner(_logger, _eventSubscriptionManager, _eventPublisher, webServer, webBrowsers, dialogMonitorRunner, _ioc.Resolve <ICurrentStatLightConfiguration>())); }
private static void RegisterLoggerTypes(TinyIoCContainer container) { container.Register <IClientMessenger, ClientMessenger>().AsSingleton(); container.Register <IMemoryLog, MemoryLog>().AsSingleton(); TinyIoCContainer logContainer = CreateHelperLogBuilderContainer(container); var threadSafeLog = new ThreadSafeLog(logContainer.Resolve <ILog>()); container.Register <ILog, ThreadSafeLog>(threadSafeLog); container.Register <ILogger>( (c, p) => new Logger(new Context("Chooie.Startup"), c.Resolve <ILog>())); }
public object GetService(Type serviceType) { try { return(_container.Resolve(serviceType)); } catch (Exception) { return(null); } }
public MiniParseConfigPanel(TinyIoCContainer container, MiniParseOverlay overlay) { InitializeComponent(); this.keyboardHook = container.Resolve <KeyboardHook>(); this.overlay = overlay; this.config = overlay.Config; SetupControlProperties(); SetupConfigEventHandlers(); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); // CookieBasedSessions.Enable(pipelines); //redis setting container.Register <IRedisClientsManager>( new PooledRedisClientManager("127.0.0.1:6379")); container.Register(container.Resolve <IRedisClientsManager>().GetClient()); // container.Register<IRedisClient>(new RedisClient()); RedisBasedSessions.Enable(pipelines); }
public static void Initialize(TinyIoCContainer container, NBehaveConfiguration configuration) { container.Register <ActionCatalog>().AsSingleton(); container.Register <HooksCatalog>().AsSingleton(); container.Register <HooksHandler>().AsSingleton(); container.Register(configuration); container.Register <IStringStepRunner, StringStepRunner>().AsMultiInstance(); InitializeContext(container); InitializeHooks(configuration, container.Resolve <HooksCatalog>()); }
public ActorControl143(TinyIoCContainer container, Assembly assembly_) { var netHelper = container.Resolve <NetworkParser>(); packetType = assembly_.GetType("Machina.FFXIV.Headers.Server_ActorControlSelf"); size = Marshal.SizeOf(packetType); categoryOffset = netHelper.GetOffset(packetType, "category"); param1Offset = netHelper.GetOffset(packetType, "param1"); param2Offset = netHelper.GetOffset(packetType, "param2"); opCode = netHelper.GetOpcode("ActorControlSelf"); }
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { base.ConfigureRequestContainer(container, context); IAppSettings settings = container.Resolve <IAppSettings>(); // register database context per request IDbContextFactory dbContextFactory = container.Resolve <IDbContextFactory>(); container.Register <IDbContext>(dbContextFactory.GetDbContext()); // validators container.Register <IUserValidator, UserValidator>(); // repositories container.Register <ILogFileRepository, LogFileRepository>(); container.Register <IProjectRepository, ProjectRepository>(); container.Register <IRequestRepository, RequestRepository>(); container.Register <IProjectRequestAggregateRepository, ProjectRequestAggregateRepository>(); container.Register <IUserRepository, UserRepository>(); // commands container.Register <ICreateLogFileCommand, CreateLogFileCommand>(); container.Register <ICreateProjectCommand, CreateProjectCommand>(); container.Register <ICreateProjectRequestAggregateCommand, CreateProjectRequestAggregateCommand>(); container.Register <ICreateRequestBatchCommand, CreateRequestBatchCommand>(); container.Register <ICreateUserCommand, CreateUserCommand>(); container.Register <IDeleteLogFileCommand, DeleteLogFileCommand>(); container.Register <IDeleteProjectCommand, DeleteProjectCommand>(); container.Register <IDeleteProjectRequestAggregateCommand, DeleteProjectRequestAggregateCommand>(); container.Register <IDeleteUserCommand, DeleteUserCommand>(); container.Register <IProcessLogFileCommand, ProcessLogFileCommand>(); container.Register <ISetLogFileUnprocessedCommand, SetLogFileUnprocessedCommand>(); container.Register <IUpdateUserPasswordCommand, UpdateUserPasswordCommand>(); // services container.Register <IJobRegistrationService, JobRegistrationService>(); container.Register <IUserService, UserService>(); container.Register <IUserMapper, UserMapper>(); }
public void ShouldFindGivenActionStepInAssembly() { TinyIoCContainer tinyIoCContainer = TinyIoCContainer.Current; var runner = CreateRunnerWithBasicConfiguration(); runner.Run(); var actionCatalog = tinyIoCContainer.Resolve <ActionCatalog>(); Assert.That(actionCatalog.ActionExists("Given my name is Morgan".AsStringStep("")), Is.True); }
private void RegisterRepository(TinyIoCContainer container) { var v = TypeScanner .GetTypesOf <IRepository>(); v.ForEach(type => { var interfaceType = type .GetInterfaces() .First(x => x != typeof(IRepository)); var isRadioSong = typeof(ISongRepository) == interfaceType || typeof(IRadioSongRepository) == interfaceType; var instance = Activator .CreateInstance(type, container.Resolve <IProvider>(isRadioSong ? "song" : "domain"), container.Resolve <IDbParameter>()); container.Register(interfaceType, instance); }); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { this.Pipelines = pipelines; this.EnableCors(pipelines); this.EnableCSRF(pipelines); this.SetupLogger(pipelines, container); this.AddRequestKey(pipelines, container); this.SetupMapper(container); Api.ApiBasicConfiguration.Pipelines?.Invoke(pipelines, container); SwaggerConfiguration.Register(container.Resolve <JsonSerializerSettings>()); Api.ApiBasicConfiguration.ApplicationStartup?.Invoke(pipelines, container); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { _componentManager = container.Resolve <IComponentManager>(); SetupPipelineHandlers(pipelines); base.ApplicationStartup(container, pipelines); foreach (var extender in _componentManager.GetBootstrapperExtenders()) { extender.Initialize(this, container); } }
/// <summary> /// reinitialize the bootstrapper - can be used for adding pre-/post- hooks and /// any other initialization tasks that aren't specifically container setup /// related /// </summary> /// <param name="container">Container instance for resolving types if required.</param> /// <param name="pipelines">The pipelines used in this application.</param> protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { Logger.Info("Bootstrapping Application"); Logger.Info("Setting up Pipelines"); base.ApplicationStartup(container, pipelines); Logger.Info("Setting up Serialization Resolver"); // register model resolvers SeedResolverRegistry.Register(); // register serializer container.Register <ISerializer, JsonApiSerializer>().AsSingleton(); var serializer = container.Resolve <ISerializer>() as JsonApiSerializer; if (serializer != null) { serializer.DeserializationMap = EntityResolverMap.DeserializationMap; } try { Logger.Info("Initializing database connection..."); DatabaseSession.Instance.CreateConnector("localhost", 5432, "redshiftseed", "redshiftseed", "redshift", ConnectorType.Postgresql); Logger.Info("Database connected..."); } catch (Exception ex) { Logger.Info("Failed to establish database connected..."); throw new HttpRequestException(string.Format("The connection to database could not be made: {0}", ex.Message)); } #if DEBUG Logger.Info("DEBUG Detected. Reseting database."); // dev mode only! wipe the db to remigrate and reseed, should always delete this once the first few migrations are finalized. MigrationEngine.DropAllTables("public"); Logger.Info("Reseting database complete..."); #endif Logger.Info("Initializing migration engine..."); MigrationEngine.Migrate(); Logger.Info("Migrations done..."); Logger.Info("Application Finished Bootstrapping"); }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { base.RequestStartup(container, pipelines, context); var formsAuthConfiguration = new FormsAuthenticationConfiguration { RedirectUrl = "~/account/login", UserMapper = container.Resolve <IUserMapper>() }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); }
public HtmlTemplatePipeline(TinyIoCContainer container) : base(container) { AddRange(new IBundleProcessor <HtmlTemplateBundle>[] { new AssignHtmlTemplateRenderer(new InlineHtmlTemplateBundleRenderer()), new ParseHtmlTemplateReferences(), container.Resolve <WrapHtmlTemplatesInScriptElements>(), new AssignHash(), new ConcatenateAssets() }); }
public StylesheetsContainerConfiguration_Tests() { container = new TinyIoCContainer(); container.Register <IStylesheetMinifier, MicrosoftStylesheetMinifier>(); container.Register(typeof(IUrlModifier), Mock.Of <IUrlModifier>()); container.Register <IUrlGenerator>((c, x) => new UrlGenerator(c.Resolve <IUrlModifier>(), "cassette.axd/")); configuration = new StylesheetsContainerConfiguration(type => new Type[0]); configuration.Configure(container); fileSearch = (FileSearch)container.Resolve <IFileSearch>(HostBase.FileSearchComponentName(typeof(StylesheetBundle))); }
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { base.RequestStartup(container, pipelines, context); //form authentication var formsAuthConfiguration = new FormsAuthenticationConfiguration { RedirectUrl = ConfigHelper.GetAppSettingByKey("logonUrl"), UserMapper = container.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); }
public void StartEventSource <T>(T source) where T : class, IEventSource { _container.BuildUp(source); _eventSources.Add(source); _container.Register(source); source.LoadConfig(_container.Resolve <IPluginConfig>()); source.Start(); EventSourceRegistered?.Invoke(null, new EventSourceRegisteredEventArgs(source)); }
public StatLightRunnerFactory(ILogger logger, TinyIoCContainer ioc) { if (logger == null) { throw new ArgumentNullException("logger"); } if (ioc == null) { throw new ArgumentNullException("ioc"); } _ioc = ioc; _logger = logger; _eventSubscriptionManager = ioc.Resolve <IEventSubscriptionManager>(); _eventPublisher = ioc.Resolve <IEventPublisher>(); _ioc.ResolveAndAddToEventAggregator <ConsoleDebugListener>(); _ioc.Resolve <ExtensionResolver>().AddExtensionsToEventAggregator(); }
public GeneralConfigTab(TinyIoCContainer container) { InitializeComponent(); Dock = DockStyle.Fill; this.container = container; pluginDirectory = container.Resolve <PluginMain>().PluginDirectory; config = container.Resolve <PluginConfig>(); logger = container.Resolve <ILogger>(); cbErrorReports.Checked = config.ErrorReports; cbUpdateCheck.Checked = config.UpdateCheck; cbHideOverlaysWhenNotActive.Checked = config.HideOverlaysWhenNotActive; cbHideOverlaysDuringCutscene.Checked = config.HideOverlayDuringCutscene; // Attach the event handlers only *after* loading the configuration because we'd otherwise trigger them ourselves. cbErrorReports.CheckedChanged += CbErrorReports_CheckedChanged; cbUpdateCheck.CheckedChanged += CbUpdateCheck_CheckedChanged; cbHideOverlaysWhenNotActive.CheckedChanged += cbHideOverlaysWhenNotActive_CheckedChanged; cbHideOverlaysDuringCutscene.CheckedChanged += cbHideOverlaysDuringCutscene_CheckedChanged; }
private bool IEnumerableDependency(TinyIoCContainer container, ILogger logger) { logger.WriteLine("IEnumerableDependency"); container.Register <ITestInterface, TestClassWithInterface>(); container.Register <ITestInterface, TestClassWithInterface>("Named1"); container.Register <ITestInterface, TestClassWithInterface>("Named2"); container.Register <TestClassEnumerableDependency>(); var result = container.Resolve <TestClassEnumerableDependency>(); return(result.EnumerableCount == 2); }
public Task <TResult> DispatchAsync <TQuery, TResult>(TQuery query) where TQuery : IQueryProvider { var type = typeof(IQueryHandler <,>).MakeGenericType(typeof(TQuery), typeof(TResult)); var handler = _container.Resolve(type) as IQueryHandler <TQuery, TResult>; if (handler == null) { throw new NoteMeNotRegisteredComponentException(type); } return(handler.HandleAsync(query)); }