Beispiel #1
0
        protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            container.Register<IDemoRepository, DemoRepository>();
            container.Register<IContributorRepository, ContributorRepository>();
        }
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register(typeof(IRoomService), (c, o) => new RoomService());
            container.Register(typeof(IUserService), (c, o) => new UserService());
        }
Beispiel #3
0
		protected override void ConfigureApplicationContainer(TinyIoCContainer container) {
			base.ConfigureApplicationContainer(container);

			container.Register(typeof(IProvideHalTypeConfiguration), HypermediaConfiguration());

			container.Register<Repositories.IRepositoryProjection<DataModels.Album>, Repositories.SqliteRepositories.AlbumRepository>();
		}
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(_config);
     container.Register((ctx, npo) => Container.Resolve<IWebServiceReceiverStrategy>());
     container.Register((ctx, npo) => Container.Resolve<ActivityTracker>());
 }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     
     container.Register<IServiceResolver>((tinyIoCContainer, _) => new DelegateServiceResolver(tinyIoCContainer.Resolve));
     container.Register<IService<HelloRequest, HelloResponse>, HelloService>();
 }
 private void RegisterDependenciesWithNancyContainer(TinyIoCContainer container)
 {
     container.Register(typeof(IProviderServiceRequestMapper), typeof(ProviderServiceRequestMapper));
     container.Register(typeof(INancyResponseMapper), typeof(NancyResponseMapper));
     container.Register(typeof (IMockContextService), _mockContextService);
     container.Register(typeof (IMockProviderNancyRequestHandler), typeof (MockProviderNancyRequestHandler));
 }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(_solution);
     container.Register(_fileSystem);
     container.RegisterMultiple<IReferenceProcessor>(new []{typeof(AddProjectReferenceProcessor), typeof(AddFileReferenceProcessor), typeof(AddGacReferenceProcessor)});
 }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     var dir = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data"));
     var store = new JsonStore<EventDescriptor>(dir, "store", "events");
     container.Register<IDataStore<EventDescriptor>, JsonStore<EventDescriptor>>(store);
     container.Register<IStore>(new Store(store, new JsonSerializer()));
 }
 // 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();
 }
Beispiel #10
0
        protected override void RegisterInstances(TinyIoCContainer container, IEnumerable<InstanceRegistration> instanceRegistrations)
        {
            base.RegisterInstances(container, instanceRegistrations);

            container.Register(mServiceManager.GetType(), mServiceManager);
            container.Register(mDeviceManager.GetType(), mDeviceManager);
        }
        protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            container.Register<IUserMapper, FakeRepository>();
            container.Register<IRepository, FakeRepository>();
        }
Beispiel #12
0
        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>());
        }
        private void RegisterProjections(TinyIoCContainer container)
        {
            var itemDetailRepository = new InMemoryItemDetailRepository();
            container.Register<IItemDetailRepository>(itemDetailRepository);
            var itemDetailViewWriter = new InMemoryViewWriter<Guid, ItemDetailViewModel>(itemDetailRepository);
            var itemDetails = new ItemDetailResultProjection(
                itemDetailViewWriter);

            var itemDetailSubscription = new GetEventStoreEventDispatcher(
                EventStoreConnection, serializerSettings, itemDetailViewWriter, bus);
            itemDetailSubscription.Subscribe<ItemTracked>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemPicked>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemLiquidated>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemReceived>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemQuantityAdjusted>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<CycleCountStarted>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<CycleCountCompleted>(itemDetails.Handle);

            itemDetailSubscription.StartDispatching();

            container.Register<IItemSearchRepository>(
                (c, n) => new RavenItemSearchRepository(c.Resolve<IDocumentSession>()));
            var itemSearchSessionObserver = new CatchUpDocumentSessionObserver<ItemSearchResultViewModel>(DocumentStore);
            bus.Register(itemSearchSessionObserver);
            var itemSearch = new ItemSearchResultProjection(
                new RavenDbViewWriter<Guid, ItemSearchResultViewModel>(
                    itemSearchSessionObserver));

            var itemSearchSubscription = new GetEventStoreEventDispatcher(
                EventStoreConnection, serializerSettings, itemSearchSessionObserver, bus);
            itemSearchSubscription.Subscribe<ItemTracked>(itemSearch.Handle);

            itemSearchSubscription.StartDispatching();
        }
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register<IArticleReader, ArticleReader>();
            container.Register<IArticleStorage, ArticleStorage>();
        }
 protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
 {
     base.ConfigureRequestContainer(container, context);
     var ctx = new SmartFlowContext();
     container.Register(ctx);
     container.Register<IUserMapper, SmartFlowAuthService>();
 }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(sessionFactory);
     container.Register(typeMapper);
     container.Register<IPomonaDataSource, TestPomonaDataSource>();
 }
 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>();
 }
Beispiel #18
0
 // Overriding this just to show how it works, not actually necessary as autoregister
 // takes care of it all.
 protected override void ConfigureApplicationContainer(TinyIoCContainer existingContainer)
 {
     // We don't call base because we don't want autoregister
     // we just register our one known dependency as an application level singleton
     existingContainer.Register<IApplicationDependency, ApplicationDependencyClass>().AsSingleton();
     existingContainer.Register<IRazorConfiguration, MyRazorConfiguration>().AsSingleton();
 }
        protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            var parser = ConnectionStringParser<RavenConnectionStringOptions>.FromConnectionStringName("RavenDB");
            parser.Parse();

            var documentStore = new DocumentStore
            {
                ApiKey = parser.ConnectionStringOptions.ApiKey,
                Url = parser.ConnectionStringOptions.Url
            };

            documentStore.Initialize();

            IndexCreation.CreateIndexes(typeof(DataCreatedDateIndex).Assembly, documentStore);

            container.Register<IDocumentStore>(documentStore);
            container.Register<IDocumentSession>(documentStore.OpenSession());

            var apiKey = WebConfigurationManager.AppSettings["dropboxApiKey"].ToString();
            var apiSecret = WebConfigurationManager.AppSettings["dropboxApiSecret"].ToString();
            var userToken = WebConfigurationManager.AppSettings["dropboxApiUserToken"].ToString();
            var userSecret = WebConfigurationManager.AppSettings["dropboxApiUserSecret"].ToString();

            var dropboxCredentials = new DropboxCredentials(apiKey, apiSecret, userToken, userSecret);

            container.Register<DropboxCredentials>(dropboxCredentials);
        }
        protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            container.Register<IProvideNancyContext>((c, o) => new NancyContextProvider(context));
            container.Register<IBuildRouteUrls, NancyRouteUrlBuilder>();
        }
Beispiel #21
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);
            var logger = LogProvider.GetLogger(this.GetType().Namespace);
            container.Register(logger);

            var subscriberRegistry = new SubscriberRegistry();
            subscriberRegistry.Register<AddTaskCommand, AddTaskCommandHandler>();
            subscriberRegistry.Register<CompleteTaskCommand, CompleteTaskCommandHandler>();

            container.Register<IHandleRequests<AddTaskCommand>, AddTaskCommandHandler>().AsMultiInstance();
            container.Register<IHandleRequests<CompleteTaskCommand>, CompleteTaskCommandHandler>().AsMultiInstance();
            var handlerFactory = new TinyIoCHandlerFactory(container);

            var retryPolicy = Policy.Handle<Exception>().WaitAndRetry(new[] { TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(150) });
            var circuitBreakerPolicy = Policy.Handle<Exception>().CircuitBreaker(1, TimeSpan.FromMilliseconds(500));
            var policyRegistry = new PolicyRegistry() { { CommandProcessor.RETRYPOLICY, retryPolicy }, { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy } };

            var sqlMessageStore = new MsSqlMessageStore(new MsSqlMessageStoreConfiguration("Server=.;Database=brighterMessageStore;Trusted_Connection=True", "messages", MsSqlMessageStoreConfiguration.DatabaseType.MsSqlServer), logger);
            var gateway = new AzureServiceBusMessageProducer(logger);

            container.Register<IAmAMessageMapper<TaskReminderCommand>, TaskReminderCommandMessageMapper>().AsMultiInstance();
            var messageMapperFactory = new TinyIoCMessageMapperFactory(container);
            var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory);
            messageMapperRegistry.Add(typeof(TaskReminderCommand), typeof(TaskReminderCommandMessageMapper));

            var commandProcessor = CommandProcessorBuilder
                .With()
                .Handlers(new HandlerConfiguration(subscriberRegistry, handlerFactory))
                    .Policies(policyRegistry)
                    .TaskQueues(new MessagingConfiguration(sqlMessageStore, gateway, messageMapperRegistry))
                    .RequestContextFactory(new InMemoryRequestContextFactory())
                    .Build();
            container.Register<IAmACommandProcessor>(commandProcessor);
        }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     AutoMapperConfiguration.Init();
     container.Register<IAuthenticateUser>(new TestAuthenticator(_username));
     container.Register<IEntryPoint>(new FakeEntryPoint());
     container.Register<IConnectToBilling>(new FakeConnectToBilling());
 }
Beispiel #23
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register(_predictionFactory);
            container.Register(_predictionRepository);
        }
Beispiel #24
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(this.repository);
     container.Register<CritterDataSource>();
     container.Register(this.typeMapper);
 }
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            // The CLR (not mono) does lazy loading of external assemblies and
            // will retrieve them on demand when you use their types. the
            // downside of this is that the razor template can't compile
            // because the assembly hasn't been loaded yet, so we use a type
            // from the assembly to force it to be loaded.
#if !__MonoCS__
            var a = new TradeStats.PowerStats("a", 1, 1, 1, 1, 1, 1);
#endif

            string exe = Assembly.GetEntryAssembly().Location;
            string exeDir = Path.GetDirectoryName(exe);
            string tmplFile = Path.Combine(exeDir, "template.html");
            Templater tmpl = new Templater(tmplFile);
            container.Register<ITemplate>(tmpl);

            string gamedir = Path.Combine(exeDir, "..", "games");
            if (!Directory.Exists(gamedir))
                Directory.CreateDirectory(gamedir); 

            var gen = new IncrementIdGenerator(gamedir);
            container.Register<IIdGenerator>(gen);

            var module = new SavegameStorage(gamedir);
            container.Register<SavegameStorage>(module);
        }
Beispiel #26
0
        public static TinyIoCContainer RegisterDependencies()
        {
            var container = new TinyIoCContainer();

            //Configuration
            container.Register<IConfigurationManager, ConfigurationManagerProxy>();

            //MVC Framework
            container.Register<System.Web.Http.Dependencies.IDependencyResolver, TinyIocDependencyResolver>();
            container.Register<IControllerFactory, TinyIocControllerFactory>();

            //Domain
            container.Register<IConfigurationRepository, ConfigurationRepository>();
            container.Register<IRepositoryManager, RepositoryManager>();
            container.Register<IFrontMatterRepository, FrontMatterRepository>();
            container.Register<IMarkupProcessorFactory, MarkupProcessorFactory>();

            //WebApi Controllers
            container.Register<PostsController>().AsMultiInstance();

            //Mvc Controllers
            container.Register<IController, UrlController>("Url").AsMultiInstance();
            container.Register<IController, HomeController>("Home").AsMultiInstance();

            return container;
        }
        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)));
        }
Beispiel #28
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            _container = container;

            var configuration = new HostConfiguration() { UrlReservations = { CreateAutomatically = true } };
            container.Register(configuration);

            //register dependencies

            IRepository<User> userRepository = new UserRepository(_mongoEndpoint);
            IRepository<Meeting> meetingRepository = new MeetingRepository(_mongoEndpoint);

            IUserService userService = new UserService(userRepository);
            IMeetingService meetingService = new MeetingService(meetingRepository,userService);

            container.Register(userService);
            container.Register(meetingService);

            pipelines.AfterRequest += (ctx) =>
            {
                ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                ctx.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS");
                ctx.Response.Headers.Add("Access-Control-Allow-Headers", "Accept, Origin, Content-type,Authorization");
            };

            base.ApplicationStartup(container, pipelines);
        }
		/// <summary>
		/// Registers JavaScript engines that may be able to run in the current environment
		/// </summary>
		/// <param name="container"></param>
		private void RegisterSupportedEngines(TinyIoCContainer container)
		{
			if (JavaScriptEngineUtils.EnvironmentSupportsClearScript())
			{
				container.Register(new JavaScriptEngineFactory.Registration
				{
					Factory = () => new V8JsEngine(),
					Priority = 10
				}, "ClearScriptV8");
			}
			if (JavaScriptEngineUtils.EnvironmentSupportsVroomJs())
			{
				container.Register(new JavaScriptEngineFactory.Registration
				{
					Factory = () => new VroomJsEngine(),
					Priority = 10
				}, "VroomJs");
			}

			container.Register(new JavaScriptEngineFactory.Registration
			{
				Factory = () => new MsieJsEngine(new MsieConfiguration { EngineMode = JsEngineMode.ChakraEdgeJsRt }),
				Priority = 20
			}, "MsieChakraEdgeRT");
			container.Register(new JavaScriptEngineFactory.Registration
			{
				Factory = () => new MsieJsEngine(new MsieConfiguration { EngineMode = JsEngineMode.ChakraIeJsRt }),
				Priority = 30
			}, "MsieChakraIeRT");
			container.Register(new JavaScriptEngineFactory.Registration
			{
				Factory = () => new MsieJsEngine(new MsieConfiguration { EngineMode = JsEngineMode.ChakraActiveScript }),
				Priority = 40
			}, "MsieChakraActiveScript");
		}
Beispiel #30
0
        public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .CreateLogger();

            var container = new TinyIoCContainer();

            var handlerFactory       = new TinyIocHandlerFactory(container);
            var messageMapperFactory = new TinyIoCMessageMapperFactory(container);

            container.Register <IHandleRequests <GreetingEvent>, GreetingEventHandler>();

            var subscriberRegistry = new SubscriberRegistry();

            subscriberRegistry.Register <GreetingEvent, GreetingEventHandler>();

            //create policies
            var retryPolicy = Policy
                              .Handle <Exception>()
                              .WaitAndRetry(new[]
            {
                TimeSpan.FromMilliseconds(50),
                TimeSpan.FromMilliseconds(100),
                TimeSpan.FromMilliseconds(150)
            });

            var circuitBreakerPolicy = Policy
                                       .Handle <Exception>()
                                       .CircuitBreaker(1, TimeSpan.FromMilliseconds(500));

            var policyRegistry = new PolicyRegistry()
            {
                { CommandProcessor.RETRYPOLICY, retryPolicy },
                { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy }
            };

            //create message mappers
            var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory)
            {
                { typeof(GreetingEvent), typeof(GreetingEventMessageMapper) }
            };

            //create the gateway
            var rmqConnnection = new RmqMessagingGatewayConnection
            {
                AmpqUri  = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")),
                Exchange = new Exchange("paramore.brighter.exchange"),
            };

            var rmqMessageConsumerFactory = new RmqMessageConsumerFactory(rmqConnnection);
            var rmqMessageProducerFactory = new RmqMessageProducerFactory(rmqConnnection);

            // Service Activator connections
            var connections = new List <Connection>
            {
                new Connection(
                    new ConnectionName("paramore.example.greeting"),
                    new InputChannelFactory(rmqMessageConsumerFactory, rmqMessageProducerFactory),
                    typeof(GreetingEvent),
                    new ChannelName("greeting.event"),
                    "greeting.event",
                    timeoutInMilliseconds: 200)
            };

            var builder = DispatchBuilder
                          .With()
                          .CommandProcessor(CommandProcessorBuilder.With()
                                            .Handlers(new HandlerConfiguration(subscriberRegistry, handlerFactory))
                                            .Policies(policyRegistry)
                                            .NoTaskQueues()
                                            .RequestContextFactory(new InMemoryRequestContextFactory())
                                            .Build()
                                            )
                          .MessageMappers(messageMapperRegistry)
                          .ChannelFactory(new InputChannelFactory(rmqMessageConsumerFactory, rmqMessageProducerFactory))
                          .Connections(connections);

            var dispatcher = builder.Build();


            dispatcher.Receive();

            Console.WriteLine("Press Enter to stop ...");
            Console.ReadLine();

            dispatcher.End().Wait();
        }
Beispiel #31
0
        protected static void RegisterServices(TinyIoCContainer container)
        {
            container.Register <MainWindow>().AsSingleton();

            container.Register <IRepositoryInformationAggregator, DefaultRepositoryInformationAggregator>().AsSingleton();

            container.Register <IRepositoryMonitor, DefaultRepositoryMonitor>().AsSingleton();
            container.Register <WindowsExplorerHandler>().AsSingleton();
            container.Register <IRepositoryDetectorFactory, DefaultRepositoryDetectorFactory>().AsSingleton();
            container.Register <IRepositoryObserverFactory, DefaultRepositoryObserverFactory>().AsSingleton();
            container.Register <IPathCrawlerFactory, DefaultPathCrawlerFactory>().AsSingleton();

            container.Register <IAppDataPathProvider, DefaultAppDataPathProvider>();
            container.Register <IErrorHandler, UIErrorHandler>();
            container.Register <IRepositoryActionProvider, WindowsRepositoryActionProvider>();
            container.Register <IRepositoryReader, DefaultRepositoryReader>();
            container.Register <IRepositoryWriter, DefaultRepositoryWriter>();
            container.Register <IRepositoryStore, DefaultRepositoryStore>();
            container.Register <IPathProvider, DefaultDriveEnumerator>();
            container.Register <IPathCrawler, GravellPathCrawler>();
            container.Register <IPathSkipper, WindowsPathSkipper>();
            container.Register <IThreadDispatcher, WpfThreadDispatcher>().AsSingleton();
            container.Register <IGitCommander, ProcessExecutingGitCommander>();
            container.Register <IAppSettingsService, FileAppSettingsService>();
            container.Register <IAutoFetchHandler, DefaultAutoFetchHandler>().AsSingleton();
            container.Register <IRepositoryIgnoreStore, DefaultRepositoryIgnoreStore>().AsSingleton();
            container.Register <ITranslationService, ResourceDictionaryTranslationService>();
        }
        static ViewModelLocator()
        {
            _container = new TinyIoCContainer();

            // View models - by default, TinyIoC will register concrete classes as multi-instance.
            _container.Register <AboutViewModel>();
            _container.Register <AddEditPropertyViewModel>();
            _container.Register <MenuViewModel>();
            _container.Register <MainViewModel>();
            _container.Register <PropertyDetailViewModel>();
            _container.Register <PropertyListViewModel>();

            // Services - by default, TinyIoC will register interface registrations as singletons.
            _container.Register <INavigationService, NavigationService>();
            _container.Register <IRepository, MockRepository>();
            _container.Register <ISettingsService, SettingsService>();
            _container.Register <IDialogService, DialogService>();
            _container.Register <ILogger, DebugLogger>();
            _container.Register <ILoginService, MockLoginService>();
            _container.Register <IUpdateService, UpdateService>();
            _container.Register <ICompassSensor, CompassSensorImplementation>();
        }
Beispiel #33
0
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     container.Register(this.log);
 }
Beispiel #34
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register <IDocumentStore>(InitializeStore());
        }
Beispiel #35
0
 protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
 {
     container.Register(new MyDependency(context));
 }
Beispiel #36
0
 public void Register <T>() where T : class
 {
     _container.Register <T>();
 }
Beispiel #37
0
 protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
 {
     container.Register <IService, Service>();
 }
Beispiel #38
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register <ILog>(LogManager.GetLogger(Setting.LogInstance));
 }
Beispiel #39
0
        protected override void ConfigureRequestContainer(TinyIoCContainer existingContainer, NancyContext context)
        {
            base.ConfigureRequestContainer(existingContainer, context);

            existingContainer.Register <IRequestDependency, RequestDependencyClass>().AsSingleton();
        }
Beispiel #40
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register <JsonSerializer, CustomJsonSerializer>();
 }
Beispiel #41
0
 public static void RegisterTypes(TinyIoCContainer container)
 {
     container.Register <IImportController, ImportController> ().AsMultiInstance();
 }
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(SQLiteService);
 }
 public void RegisterDependencies(TinyIoCContainer container)
 {
     container.Register <PackageListRetriver>();
     container.Register <PackageInstaller>();
     container.Register <PackageUninstaller>();
 }
Beispiel #44
0
        private static void ConfigureContainer(TinyIoCContainer container, IHaveMainPage mainApp)
        {
            var appInsights = new TelemetryClient(new TelemetryConfiguration("97e6fd64-c506-4830-9530-fbe9a7274326"));

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.NSLog()
                         .WriteTo.ApplicationInsights(
                appInsights,
                TelemetryConverter.Traces,
                restrictedToMinimumLevel: LogEventLevel.Information)
                         .WriteTo.Debug(restrictedToMinimumLevel: LogEventLevel.Information)
                         .CreateLogger();

            AppDomain.CurrentDomain.UnhandledException += (s, e) => LogUnhandled(e.ExceptionObject as Exception);
            TaskScheduler.UnobservedTaskException      += (s, e) => LogUnhandled(e.Exception);

            container.Register(Log.Logger);
            container.Register <IAuthorizer, Authorizer>();
            container.Register <IActionPresenter, ActionPresenter>();
            container.Register <IShare, HealthNerd.Services.Share>();
            container.Register <IClock>(SystemClock.Instance);
            container.Register <IFileManager, FileManager>(
                new FileManager(container.Resolve <IClock>(), FileSystem.CacheDirectory));
            container.Register <ISettingsStore, SettingsStore>();
            container.Register <IAnalytics>(new MultiAnalytics(
                                                new FirebaseAnalytics(),
                                                new AppInsightsAnalytics(appInsights)));
            container.Register <AuthorizeHealthCommand>();
            container.Register <ExportSpreadsheetCommand>();
            container.Register <IHealthStore>(new HealthStore(new HKHealthStore()));

            var navigator = new NavigationService(mainApp, new ViewLocator(), container);

            container.Register <MainPageViewModel>();
            container.Register <SettingsViewModel>();
            container.Register <ExportSettingsViewModel>();
            container.Register <OnboardingPageViewModel>();
            container.Register <OnboardingWelcomeViewModel>();
            container.Register <OnboardingWhatViewModel>();
            container.Register <OnboardingAuthViewModel>();
            container.Register <OnboardingSettingsViewModel>();
            container.Register <OnboardingFinishViewModel>();

            container.Register <INavigationService>(navigator);

            void LogUnhandled(Exception ex)
            {
                Log.Logger.Error(ex, "Unhandled exception");
                appInsights.TrackException(ex);
                appInsights.Flush();
            }
        }
Beispiel #45
0
 public void Register(TinyIoCContainer container)
 {
     container.Register <IMongoService, MongoService>();
 }
Beispiel #46
0
        //private readonly Config config = Config.GetInstance();

        // override initial startup and add TTSProducerConsumer as a singleton
        // this makes the TTSProducerConsumer available in each request
        // (NancyModule lifetime is per request, not for the life of the application)
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            container.Register <TTSProducer>().AsSingleton();
        }
Beispiel #47
0
 private static void RegisterViewModels()
 {
     _container.Register <StartCenterViewModel>();
     _container.Register <WorkOutListViewModel>();
     _container.Register <RegisterWorkOutViewModel>();
 }
Beispiel #48
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register <IConfiguration>(Config.Instance);
 }
        private void InitaliseServices()
        {
            _container.Register <ITinyMessengerHub, TinyMessengerHub>();


            _container.Register <IAccountServiceClient>((c, p) =>
                                                        new AccountServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), null, null, c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()),
                                                        "NotAuthenticated");

            _container.Register <IAccountServiceClient>((c, p) =>
                                                        new AccountServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), null, c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()),
                                                        "Authenticate");

            _container.Register <IAccountServiceClient>((c, p) => new AccountServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), null, c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()));

            _container.Register((c, p) => new ReferenceDataServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), c.Resolve <IPackageInfo>(), c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()));

            _container.Register((c, p) => new OrderServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), c.Resolve <IPackageInfo>(), c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()));

            _container.Register <IAuthServiceClient>((c, p) => new AuthServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), c.Resolve <IPackageInfo>(), c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()));

            _container.Register((c, p) => new ApplicationInfoServiceClient(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), c.Resolve <IPackageInfo>(), c.Resolve <IConnectivityService>(), c.Resolve <ILogger>()));

            _container.Register((c, p) => new ConfigurationClientService(c.Resolve <IAppSettings>().GetServiceUrl(), GetSessionId(), c.Resolve <IPackageInfo>(), c.Resolve <IConnectivityService>(), c.Resolve <ILogger>(), c.Resolve <ICryptographyService>()));

            _container.Register <IAccountService>((c, p) => new AccountService(c.Resolve <IAppSettings>(), null, null, c.Resolve <ILocalization>(), c.Resolve <IConnectivityService>(), null, null));

            _container.Register <IBookingService>((c, p) => new BookingService(
                                                      c.Resolve <IAccountService>(),
                                                      c.Resolve <ILocalization>(),
                                                      c.Resolve <IAppSettings>(),
                                                      null,
                                                      c.Resolve <IMessageService>(),
                                                      c.Resolve <IIPAddressManager>()));

            _container.Register <IApplicationInfoService, ApplicationInfoService>();

            ServicePointManager.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
        }
Beispiel #50
0
 private static void RegisterSystemTrayApplicationTypes(TinyIoCContainer container)
 {
     container.Register <SystemTrayApplicationStarter>();
 }
Beispiel #51
0
 private static void RegisterSignalRTypes(TinyIoCContainer container)
 {
     container.Register <SignalRStarter>();
     container.Register <SignalRUriProvider>();
 }
Beispiel #52
0
 private static void RegisterDatabaseTypes(TinyIoCContainer container)
 {
     container.Register <DatabaseFileNameProvider>();
     container.Register <IDatabaseAccessor, DatabaseAccessor>();
     container.Register <DatabaseStarter>();
 }
Beispiel #53
0
 private static void RegisterApplicationStarterTypes(TinyIoCContainer container)
 {
     container.Register <ApplicationStarterProvider>((c, p) => new ApplicationStarterProvider(c));
     container.Register <ApplicationStarter>();
 }
Beispiel #54
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            container.Register <IAccountContextProvider, AccountContextProvider>();
            container.Register <IAccountRepo, AccountRepo>();
            container.Register <ICacheLocalProvider, CacheLocalProvider>();
            container.Register <ICharacterNameDict, CharacterNameDict>();
            container.Register <ICorporationRepo, CorporationRepo>();
            container.Register <IEveApi, EveApi>();
            container.Register <IJobRepo, JobRepo>();
            container.Register <IJobService, JobsService>();
            container.Register <IKeyInfoRepo, KeyInfoRepo>();
            container.Register <INotificationRepo, NotificationRepo>();
            container.Register <IPilotRepo, PilotRepo>();
            container.Register <IEvePilotDataService, EvePilotDataService>();
            container.Register <IRefTypeDict, RefTypeDict>();
            container.Register <ISkillRepo, SkillRepo>();
            container.Register <ISkillInQueueRepo, SkillInQueueRepo>();
            container.Register <ITypeNameDict, TypeNameDict>();
            container.Register <IAccountService, ts.services.AccountService>();
            container.Register <IKeyInfoService, ts.services.KeyInfoService>();
            container.Register <IEveLibCache, EveSqlServerCache>();
            container.Register <IBackgroundUpdate, ts.services.BackgroundUpdate>();

            var config = new LoggerConfiguration();

#if DEBUG
            config.MinimumLevel.Debug().WriteTo.Trace();
#else
            config.MinimumLevel.Debug();
#endif
            var log = config.CreateLogger();
            container.Register <ILogger>(log);
        }
Beispiel #55
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     container.Register <IDataManagerService>(new DataManagerService());
     container.Register <ICheckIPService>(new VirusTotalService());
 }
Beispiel #56
0
        public DocumentService()
        {
            log4net.Config.XmlConfigurator.Configure();

            var container = new TinyIoCContainer();

            var handlerFactory       = new TinyIocHandlerFactory(container);
            var messageMapperFactory = new TinyIoCMessageMapperFactory(container);

            container.Register <IHandleRequests <DocumentCreatedEvent>, DocumentCreatedEventHandler>();
            container.Register <IHandleRequests <DocumentUpdatedEvent>, DocumentUpdatedEventHandler>();
            container.Register <IHandleRequests <FolderCreatedEvent>, FolderCreatedEventHandler>();

            var subscriberRegistry = new SubscriberRegistry();

            subscriberRegistry.Register <DocumentCreatedEvent, DocumentCreatedEventHandler>();
            subscriberRegistry.Register <DocumentUpdatedEvent, DocumentUpdatedEventHandler>();
            subscriberRegistry.Register <FolderCreatedEvent, FolderCreatedEventHandler>();

            //create policies
            var retryPolicy = Policy
                              .Handle <Exception>()
                              .WaitAndRetry(new[]
            {
                TimeSpan.FromMilliseconds(5000),
                TimeSpan.FromMilliseconds(10000),
                TimeSpan.FromMilliseconds(10000)
            });

            var circuitBreakerPolicy = Policy
                                       .Handle <Exception>()
                                       .CircuitBreaker(1, TimeSpan.FromMilliseconds(500));

            var policyRegistry = new PolicyRegistry
            {
                { CommandProcessor.RETRYPOLICY, retryPolicy },
                { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy }
            };

            //create message mappers
            var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory)
            {
                { typeof(FolderCreatedEvent), typeof(FolderCreatedEventMessageMapper) },
                { typeof(DocumentCreatedEvent), typeof(DocumentCreatedEventMessageMapper) },
                { typeof(DocumentUpdatedEvent), typeof(DocumentUpdatedEventMessageMapper) }
            };

            var awsCredentials = new StoredProfileAWSCredentials();

            _dispatcher = DispatchBuilder.With()
                          .CommandProcessor(CommandProcessorBuilder.With()
                                            .Handlers(new HandlerConfiguration(subscriberRegistry, handlerFactory))
                                            .Policies(policyRegistry)
                                            .NoTaskQueues()
                                            .RequestContextFactory(new InMemoryRequestContextFactory())
                                            .Build())
                          .MessageMappers(messageMapperRegistry)
                          .DefaultChannelFactory(new InputChannelFactory(new SqsMessageConsumerFactory(awsCredentials)))
                          .Connections(new Connection[]
            {
                new Connection <DocumentCreatedEvent>(
                    new ConnectionName("paramore.example.documentsandfolders.documentcreatedevent"),
                    new ChannelName("https://sqs.eu-west-1.amazonaws.com/027649620536/DocumentCreatedEvent"),
                    new RoutingKey("DocumentCreatedEvent"),
                    timeoutInMilliseconds: 5000,
                    noOfPerformers: 10),
                new Connection <DocumentUpdatedEvent>(
                    new ConnectionName("paramore.example.documentsandfolders.documentupdatedevent"),
                    new ChannelName("https://sqs.eu-west-1.amazonaws.com/027649620536/DocumentUpdatedEvent"),
                    new RoutingKey("DocumentUpdatedEvent"),
                    timeoutInMilliseconds: 5000,
                    noOfPerformers: 10),
                new Connection <FolderCreatedEvent>(
                    new ConnectionName("paramore.example.documentsandfolders.foldercreateddevent"),
                    new ChannelName("https://sqs.eu-west-1.amazonaws.com/027649620536/FolderCreatedEvent"),
                    new RoutingKey("FolderCreatedEvent"),
                    timeoutInMilliseconds: 5000,
                    noOfPerformers: 10)
            }).Build();
        }
Beispiel #57
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register <IAppConfiguration>(appConfig);
        }
Beispiel #58
0
        protected static void RegisterServices(TinyIoCContainer container)
        {
            container.Register <MainWindow>().AsSingleton();

            container.Register <IRepositoryInformationAggregator, DefaultRepositoryInformationAggregator>().AsSingleton();

            container.Register <IRepositoryMonitor, DefaultRepositoryMonitor>().AsSingleton();
            container.Register <WindowsExplorerHandler>().AsSingleton();
            container.Register <IRepositoryDetectorFactory, DefaultRepositoryDetectorFactory>().AsSingleton();
            container.Register <IRepositoryObserverFactory, DefaultRepositoryObserverFactory>().AsSingleton();
            container.Register <IPathCrawlerFactory, DefaultPathCrawlerFactory>().AsSingleton();

            container.Register <IErrorHandler, UIErrorHandler>();
            container.Register <IRepositoryActionProvider, WindowsRepositoryActionProvider>();
            container.Register <IRepositoryReader, DefaultRepositoryReader>();
            container.Register <IRepositoryWriter, DefaultRepositoryWriter>();
            container.Register <IRepositoryStore, WindowsRepositoryStore>();
            container.Register <IPathProvider, DefaultDriveEnumerator>();
            container.Register <IPathCrawler, GravellPathCrawler>();
            container.Register <IPathSkipper, WindowsPathSkipper>();
            container.Register <IThreadDispatcher, WpfThreadDispatcher>().AsSingleton();
            container.Register <IGitCommander, WindowsGitCommander>();
        }
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     container.Register <MessageRepository>().AsSingleton();
     base.ApplicationStartup(container, pipelines);
 }
Beispiel #60
-1
        // 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, Nancy.Bootstrapper.IPipelines pipelines)
        {
            var projRep = new ProjectRepository(null);

            var sampleProj = Samples.SampleProject();
            ProjectIdUsedDuringDevelopment = sampleProj.Id;

            var user = Samples.SampleUser(sampleProj);
            UserIdUsedDuringDevelopment = user.Id;

            projRep.AddProject(sampleProj);
            projRep.AddProject(new Project {Id = Guid.NewGuid(), Name = "Testobjekt"});
            projRep.AddProject(new Project {Id = Guid.NewGuid(), Name = "Skräpobjekt"});

            var fileSystem = new MockFileSystem();
            fileSystem.Directory.CreateDirectory(@"c:\HeatOn\users");
            fileSystem.Directory.CreateDirectory(@"c:\HeatOn\projects");
            var userRep = new UserRepository(fileSystem);
            userRep.SaveUser(user);

            container.Register<IProjectService>(new ProjectService(projRep));
            container.Register<IUserRepository>(userRep);

            //Conventions.ViewLocationConventions.Add((viewName, model, context) =>
            //{
            //    return string.Concat("bin/views/", viewName);
            //});
        }