Esempio n. 1
0
        private void ConnectToSubscriptionService()
        {
            _subscriptionServiceEndpoint = _container.GetInstance <IEndpointFactory>()
                                           .GetEndpoint(_container.GetInstance <IConfiguration>().SubscriptionServiceUri);

            _subscriptionServiceEndpoint.Send(new AddSubscriptionClient(_clientId, _bus.Endpoint.Uri, _bus.Endpoint.Uri));
        }
Esempio n. 2
0
        protected override void OnStop()
        {
            // Kill the bus which will kill any subscriptions
            _container.GetInstance <IBus>().Advanced.Dispose();

            // Give it 5 seconds to finish processing any in flight subscriptions.
            Thread.Sleep(TimeSpan.FromSeconds(5));
        }
Esempio n. 3
0
        public override void OnStop()
        {
            // Stop consumers
            _container.GetInstance <ApplicationStatusSummaryPageConsumerAsync>().Stop();
            _container.GetInstance <ApplicationStatusSummaryConsumerAsync>().Stop();

            // Kill the bus which will kill any subscriptions
            _container.GetInstance <IBus>().Advanced.Dispose();

            // Give it 5 seconds to finish processing any in flight subscriptions.
            Thread.Sleep(TimeSpan.FromSeconds(5));

            base.OnStop();
        }
Esempio n. 4
0
        private void RegisterIRequestHandlerOfGetRequestDtoByKey(IContainer container)
        {
            var assemblyLocator = container.GetInstance <IAssemblyLocator>();
            var assemblies      = assemblyLocator.LocateWebServiceAssemblies();

            foreach (var assembly in assemblies)
            {
                Logger.Debug("Registering IRequestHandler<GetDtoRequestByKey<TDto>> instance in DI container: {0}.", assembly);

                var dtoTypes = from dtoType in assembly.GetTypes()
                               where dtoType.IsSubclassOf(typeof(KeyedDataTransferObject)) && !dtoType.IsAbstract
                               select dtoType;
                foreach (var dtoType in dtoTypes)
                {
                    var openGetDtoRequestType   = typeof(GetDtoRequest <>);
                    var closedGetDtoRequestType = openGetDtoRequestType.MakeGenericType(dtoType);

                    var openGetDtoByKeyRequestHandlerType   = typeof(GetDtoByKeyRequestHandler <>);
                    var closedGetDtoByKeyRequestHandlerType =
                        openGetDtoByKeyRequestHandlerType.MakeGenericType(dtoType);

                    var openRequestHandlerInterfaceType = typeof(IRequestHandler <>);
                    var closedGetDtoByKeyRequestHandlerInterfaceType =
                        openRequestHandlerInterfaceType.MakeGenericType(closedGetDtoRequestType);

                    if (!container.Model.HasDefaultImplementationFor(closedGetDtoByKeyRequestHandlerInterfaceType))
                    {
                        container.Configure(
                            c =>
                            c.For(closedGetDtoByKeyRequestHandlerInterfaceType).Use(
                                p => PillarIoC.CurrentContainer.Resolve(closedGetDtoByKeyRequestHandlerType)));
                    }
                }
            }
        }
Esempio n. 5
0
        private void InitializeIoC()
        {
            var  config          = new ConfigurationManager();
            var  useCacheSetting = config.TryGetAppSetting("UseCaching");
            bool useCache;

            bool.TryParse(useCacheSetting, out useCache);

            _container = new Container(x =>
            {
                x.AddRegistry <CommonRegistry>();
                x.AddRegistry <LoggingRegistry>();
                x.AddRegistry <AzureCommonRegistry>();
                x.AddRegistry <VacancyIndexerRegistry>();
                x.AddRegistry <RabbitMqRegistry>();
                x.AddRegistry <AzureCacheRegistry>();
                x.AddRegistry <MemoryCacheRegistry>();
                x.AddRegistry(new LegacyWebServicesRegistry(useCache));
                x.AddRegistry <GatewayVacancyEtlRegistry>();
                x.AddRegistry <ElasticsearchCommonRegistry>();
                x.AddRegistry <ApplicationRepositoryRegistry>();
                x.AddRegistry <CommunicationRepositoryRegistry>();
            });

            _logger = _container.GetInstance <ILogService>();
        }
Esempio n. 6
0
        /// <summary>
        /// Configures the security.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureSecurity(IContainer appContainer)
        {
            appContainer.Configure(c => c.For <ICurrentUserPermissionService>().Use <CurrentUserPermissionService>());
            var accessCtrlMgr         = appContainer.GetInstance <IAccessControlManager> ();
            var permissionDescriptors = appContainer.GetAllInstances <IPermissionDescriptor> ();

            accessCtrlMgr.RegisterPermissionDescriptor(permissionDescriptors.ToArray());
        }
        object Common.IContainer.Build(Type typeToBuild)
        {
            if (container.Model.PluginTypes.Any(t => t.PluginType == typeToBuild))
            {
                return(container.GetInstance(typeToBuild));
            }

            throw new ArgumentException(typeToBuild + " is not registered in the container");
        }
Esempio n. 8
0
        /// <summary>
        ///     Configures the security.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureSecurity(IContainer appContainer)
        {
            appContainer.Configure(c => c.For <ICurrentUserPermissionService>().Use <CurrentUserPermissionService>());
            appContainer.Configure(c => c.For <ICurrentClaimsPrincipalService>().Use <CurrentClaimsPrincipleService>());
            appContainer.Configure(c => c.For <IAccessControlManager>().Singleton().Use <ProCenterAccessControlManager>());
            appContainer.Configure(c => c.For <IProvidePermissions>().Use(conf => conf.GetInstance <IAccessControlManager>() as IProvidePermissions));
            var accessCtrlMgr         = appContainer.GetInstance <IAccessControlManager>();
            var permissionDescriptors = appContainer.GetAllInstances <IPermissionDescriptor>();

            accessCtrlMgr.RegisterPermissionDescriptor(permissionDescriptors.ToArray());
        }
Esempio n. 9
0
        /// <summary>
        /// Configures the agatha.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureAgatha(IContainer appContainer)
        {
            var structureMapContainer = new Agatha.StructureMap.Container(appContainer);

            IoC.Container = structureMapContainer;

            var assemblyLocator          = appContainer.GetInstance <IAssemblyLocator> ();
            var infrastructureAssemblies = assemblyLocator.LocateInfrastructureAssemblies();

            var genericsToApply = new Dictionary <Type, Type> ();

            foreach (var infrastructureAssembly in infrastructureAssemblies)
            {
                var genericsToApplyInAssebmly = KnownTypeHelper.GetGenerics(infrastructureAssembly);

                foreach (KeyValuePair <Type, Type> keyValuePair in genericsToApplyInAssebmly)
                {
                    genericsToApply.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            var serviceLayerConfiguration = new ServiceLayerConfiguration(structureMapContainer);

            var serviceAssemblies = assemblyLocator.LocateWebServiceAssemblies();

            foreach (var assembly in serviceAssemblies)
            {
                var assemblyRef = assembly;
                Logger.Debug("Registering Requests, Responses, Handlers, and Dtos for Assembly: {0}", assemblyRef);

                KnownTypeHelper.RegisterNonGenericRequestsAndResponses(assembly);
                serviceLayerConfiguration.AddRequestHandlerAssembly(assembly);

                KnownTypeProvider.RegisterDerivedTypesOf <AbstractDataTransferObject> (assembly.GetTypes().Where(t => !t.IsGenericType));

                KnownTypeHelper.RegisterGenerics(genericsToApply, assembly);
            }

            KnownTypeProvider.Register <TerminologyConcept> ();
            KnownTypeProvider.Register <TerminologyProperty> ();
            KnownTypeProvider.Register <TerminologyPropertyType> ();
            KnownTypeProvider.Register <TerminologyVocabulary> ();

            // register the agatha interceptors
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor <SecurityInterceptor>();
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor <RuleViolationEventInterceptor> ();

            serviceLayerConfiguration.RequestProcessorImplementation = typeof(Service.PerformanceLoggingRequestProcessor);
            serviceLayerConfiguration.Initialize();

            RegisterIRequestHandlerOfGetRequestDtoByKey(appContainer);
            CallKnownTypeProviders(appContainer);
        }
 public object Resolve(Type type)
 {
     try
     {
         return(container.GetInstance(type));
     }
     catch (StructureMapException ex)
     {
         string message = ex.Message + "\n" + container.WhatDoIHave();
         throw new Exception(message);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Initializes the Nhibernate.
        /// </summary>
        /// <param name="container">The container.</param>
        protected virtual void InitializeNHibernate(IContainer container)
        {
            var configurationProvider = container.GetInstance <IConfigurationProvider>();
            var configuration         = configurationProvider.Configure().GetEnumerator().Current;

            configuration.SetListener(ListenerType.Flush, new PostFlushFixEventListener());
            configuration.SetListener(ListenerType.Autoflush, new AutoFlushFixEventListener());
            configuration.SetListener(ListenerType.PostUpdate, new PatientAccessAuditablePostUpdateListener());
            configuration.SetListener(ListenerType.PostInsert, new PatientAccessAuditablePostInsertListener());
            configuration.SetListener(ListenerType.PostDelete, new PatientAccessAuditablePostDeleteListener());

            ConfigureNHibernateSession(configurationProvider, container);
        }
Esempio n. 12
0
        private static void InitializeAndRegisterPersistenceStuff(IContainer container)
        {
            var configurationProvider = container.GetInstance <IConfigurationProvider> ();
            var configuration         = configurationProvider.Configure().GetEnumerator().Current;

            configuration.SetProperty(
                Environment.CurrentSessionContextClass,
                "uNhAddIns.SessionEasier.Contexts.ThreadLocalSessionContext, uNhAddIns");
            var sessionFactoryProvider = new SessionFactoryProvider(configurationProvider);

            sessionFactoryProvider.Initialize();

            container.Configure(x => x.For <ISessionFactoryProvider> ().Singleton().Use(sessionFactoryProvider));
            container.Configure(x => x.For <ISessionProvider> ().Use <SessionProvider> ());
        }
Esempio n. 13
0
 public object GetService(Type serviceType)
 {
     if (serviceType == null)
     {
         return(null);
     }
     try
     {
         return(serviceType.IsAbstract || serviceType.IsInterface
                  ? _container.TryGetInstance(serviceType)
                  : _container.GetInstance(serviceType));
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 14
0
 public object GetService(Type serviceType)
 {
     if (serviceType == null)
     {
         return(null);
     }
     try
     {
         return(serviceType.IsAbstract || serviceType.IsInterface
                  ? _container.TryGetInstance(serviceType)
                  : _container.GetInstance(serviceType));
     }
     catch (Exception ex)
     {
         //System.Diagnostics.EventLog.WriteEntry("Web Distribution System", ex.ToString());
         return(null);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Configures agatha.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureAgatha(IContainer appContainer)
        {
            var structureMapContainer = new Agatha.StructureMap.Container(appContainer);

            Agatha.Common.InversionOfControl.IoC.Container = structureMapContainer;

            var assemblyLocator          = appContainer.GetInstance <IAssemblyLocator> ();
            var infrastructureAssemblies = assemblyLocator.LocateInfrastructureAssemblies();

            var genericsToApply = new Dictionary <Type, Type> ();

            foreach (var infrastructureAssembly in infrastructureAssemblies)
            {
                var genericsToApplyInAssebmly = KnownTypeHelper.GetGenerics(infrastructureAssembly);

                foreach (var keyValuePair in genericsToApplyInAssebmly)
                {
                    genericsToApply.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            var serviceAssemblies = assemblyLocator.LocateWebServiceAssemblies();

            foreach (var assembly in serviceAssemblies)
            {
                KnownTypeHelper.RegisterNonGenericRequestsAndResponses(assembly);

                KnownTypeProvider.RegisterDerivedTypesOf <AbstractDataTransferObject> (assembly.GetTypes().Where(t => !t.IsGenericType));

                KnownTypeHelper.RegisterGenerics(genericsToApply, assembly);
            }

            var clientConfiguration = new ClientConfiguration(structureMapContainer)
            {
                AsyncRequestDispatcherImplementation = typeof(AsyncRequestDispatcher)
            };

            clientConfiguration.AddRequestAndResponseAssembly(typeof(GetLookupValuesRequest).Assembly);

            clientConfiguration.RequestProcessorImplementation = typeof(CustomSyncRequestProcessorProxy);

            clientConfiguration.Initialize();
        }
Esempio n. 16
0
        /// <summary>
        /// Configures the raven db.
        /// </summary>
        /// <param name="container">The container.</param>
        protected virtual void ConfigureRavenDb(IContainer container)
        {
            ForceLoadingRavenDbAssemblies();
            var appsettingsProvider = container.GetInstance <IConfigurationPropertiesProvider> ();
            var ravenDbUrl          = appsettingsProvider.GetProperty("RavenDBUrl");
            var runInMemory         = appsettingsProvider.GetProperty("RavenDBRunInMemory");

            IDocumentStore store = runInMemory.ToLower() == "true" ?
                                   new EmbeddableDocumentStore {
                RunInMemory = true
            } : new DocumentStore {
                Url = ravenDbUrl
            };

            store.Initialize();
            container.Configure(c => c.For <IDocumentStore> ().Singleton().Use(store));

            RegisterDocumentSessionProvider(container);
            container.Configure(c => c.For <IDocumentSessionProvider> ().HttpContextScoped().Use <DocumentSessionProvider> ());
        }
Esempio n. 17
0
 public object GetInstance(Type type, params Dependency[] dependencies)
 {
     return(dependencies != null && dependencies.Any()
         ? _container.GetInstance(type, dependencies.ToExplicitArgs())
         : _container.GetInstance(type));
 }
Esempio n. 18
0
        /// <summary>
        /// Initializes the Nhibernate.
        /// </summary>
        /// <param name="container">The container.</param>
        protected virtual void InitializeNHibernate(IContainer container)
        {
            var configurationProvider = container.GetInstance<IConfigurationProvider>();
            var configuration = configurationProvider.Configure().GetEnumerator().Current;

            configuration.SetListener(ListenerType.Flush, new PostFlushFixEventListener());
            configuration.SetListener(ListenerType.Autoflush, new AutoFlushFixEventListener());
            configuration.SetListener(ListenerType.PostUpdate, new PatientAccessAuditablePostUpdateListener());
            configuration.SetListener(ListenerType.PostInsert, new PatientAccessAuditablePostInsertListener());
            configuration.SetListener(ListenerType.PostDelete, new PatientAccessAuditablePostDeleteListener());

            ConfigureNHibernateSession(configurationProvider, container);
        }
Esempio n. 19
0
 public T Get <T>()
 {
     return(_container.GetInstance <T>());
 }
Esempio n. 20
0
        /// <summary>
        /// Configures the agatha.
        /// </summary>
        /// <param name="appContainer">The app container.</param>
        protected virtual void ConfigureAgatha(IContainer appContainer)
        {
            var structureMapContainer = new Agatha.StructureMap.Container ( appContainer );
            IoC.Container = structureMapContainer;

            var assemblyLocator = appContainer.GetInstance<IAssemblyLocator> ();
            var infrastructureAssemblies = assemblyLocator.LocateInfrastructureAssemblies();

            var genericsToApply = new Dictionary<Type, Type> ();
            foreach (var infrastructureAssembly in infrastructureAssemblies)
            {
                var genericsToApplyInAssebmly = KnownTypeHelper.GetGenerics ( infrastructureAssembly );

                foreach ( KeyValuePair<Type, Type> keyValuePair in genericsToApplyInAssebmly )
                {
                    genericsToApply.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            var serviceLayerConfiguration = new ServiceLayerConfiguration ( structureMapContainer );

            var serviceAssemblies = assemblyLocator.LocateWebServiceAssemblies();

            foreach ( var assembly in serviceAssemblies )
            {
                var assemblyRef = assembly;
                Logger.Debug ( "Registering Requests, Responses, Handlers, and Dtos for Assembly: {0}", assemblyRef );

                KnownTypeHelper.RegisterNonGenericRequestsAndResponses ( assembly );
                serviceLayerConfiguration.AddRequestHandlerAssembly ( assembly );

                KnownTypeProvider.RegisterDerivedTypesOf<AbstractDataTransferObject> ( assembly.GetTypes ().Where ( t => !t.IsGenericType ) );

                KnownTypeHelper.RegisterGenerics ( genericsToApply, assembly );
            }

            KnownTypeProvider.Register<TerminologyConcept> ();
            KnownTypeProvider.Register<TerminologyProperty> ();
            KnownTypeProvider.Register<TerminologyPropertyType> ();
            KnownTypeProvider.Register<TerminologyVocabulary> ();

            // register the agatha interceptors
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor<SecurityInterceptor>();
            serviceLayerConfiguration.RegisterRequestHandlerInterceptor<RuleViolationEventInterceptor> ();

            serviceLayerConfiguration.RequestProcessorImplementation = typeof ( Service.PerformanceLoggingRequestProcessor );
            serviceLayerConfiguration.Initialize ();

            RegisterIRequestHandlerOfGetRequestDtoByKey ( appContainer );
            CallKnownTypeProviders ( appContainer );
        }
Esempio n. 21
0
        private void RegisterIRequestHandlerOfGetRequestDtoByKey(IContainer container)
        {
            var assemblyLocator = container.GetInstance<IAssemblyLocator>();
            var assemblies = assemblyLocator.LocateWebServiceAssemblies();

            foreach (var assembly in assemblies)
            {
                Logger.Debug("Registering IRequestHandler<GetDtoRequestByKey<TDto>> instance in DI container: {0}.", assembly);

                var dtoTypes = from dtoType in assembly.GetTypes()
                               where dtoType.IsSubclassOf(typeof(KeyedDataTransferObject)) && !dtoType.IsAbstract
                               select dtoType;
                foreach (var dtoType in dtoTypes)
                {
                    var openGetDtoRequestType = typeof(GetDtoRequest<>);
                    var closedGetDtoRequestType = openGetDtoRequestType.MakeGenericType(dtoType);

                    var openGetDtoByKeyRequestHandlerType = typeof(GetDtoByKeyRequestHandler<>);
                    var closedGetDtoByKeyRequestHandlerType =
                        openGetDtoByKeyRequestHandlerType.MakeGenericType(dtoType);

                    var openRequestHandlerInterfaceType = typeof(IRequestHandler<>);
                    var closedGetDtoByKeyRequestHandlerInterfaceType =
                        openRequestHandlerInterfaceType.MakeGenericType(closedGetDtoRequestType);

                    if (!container.Model.HasDefaultImplementationFor(closedGetDtoByKeyRequestHandlerInterfaceType))
                    {
                        container.Configure(
                            c =>
                            c.For(closedGetDtoByKeyRequestHandlerInterfaceType).Use(
                                p => PillarIoC.CurrentContainer.Resolve(closedGetDtoByKeyRequestHandlerType)));
                    }
                }
            }
        }
Esempio n. 22
0
 public TComponent Resolve <TComponent>()
 {
     return(structureMapContainer.GetInstance <TComponent>());
 }
Esempio n. 23
0
 public int ShowHelp(GitTfsCommand command)
 {
     return(_container.GetInstance <Help>().Run(command));
 }
Esempio n. 24
0
 /// <summary>
 /// Configures the security.
 /// </summary>
 /// <param name="appContainer">The app container.</param>
 protected virtual void ConfigureSecurity( IContainer appContainer )
 {
     appContainer.Configure ( c => c.For<ICurrentUserPermissionService>().Use<CurrentUserPermissionService>() );
     var accessCtrlMgr = appContainer.GetInstance<IAccessControlManager> ();
     var permissionDescriptors = appContainer.GetAllInstances<IPermissionDescriptor> ();
     accessCtrlMgr.RegisterPermissionDescriptor ( permissionDescriptors.ToArray () );
 }
Esempio n. 25
0
 public TService Resolve <TService>() where TService : class
 {
     return(structureMapContainer.GetInstance <TService>());
 }
Esempio n. 26
0
        private static void InitializeAndRegisterPersistenceStuff( IContainer container )
        {
            var configurationProvider = container.GetInstance<IConfigurationProvider> ();
            var configuration = configurationProvider.Configure ().GetEnumerator ().Current;
            configuration.SetProperty (
                Environment.CurrentSessionContextClass,
                "uNhAddIns.SessionEasier.Contexts.ThreadLocalSessionContext, uNhAddIns" );
            var sessionFactoryProvider = new SessionFactoryProvider ( configurationProvider );
            sessionFactoryProvider.Initialize ();

            container.Configure ( x => x.For<ISessionFactoryProvider> ().Singleton ().Use ( sessionFactoryProvider ) );
            container.Configure ( x => x.For<ISessionProvider> ().Use<SessionProvider> () );
        }
Esempio n. 27
0
 public object Resolve(Type type)
 {
     return(_container.GetInstance(type));
 }
Esempio n. 28
0
        /// <summary>
        /// Configures the raven db.
        /// </summary>
        /// <param name="container">The container.</param>
        protected virtual void ConfigureRavenDb(IContainer container)
        {
            ForceLoadingRavenDbAssemblies ();
            var appsettingsProvider = container.GetInstance<IConfigurationPropertiesProvider> ();
            var ravenDbUrl = appsettingsProvider.GetProperty ( "RavenDBUrl" );
            var runInMemory = appsettingsProvider.GetProperty ( "RavenDBRunInMemory" );

            IDocumentStore store = runInMemory.ToLower () == "true" ?
                                                                        new EmbeddableDocumentStore { RunInMemory = true } : new DocumentStore { Url = ravenDbUrl };

            store.Initialize ();
            container.Configure ( c => c.For<IDocumentStore> ().Singleton ().Use ( store ) );

            RegisterDocumentSessionProvider ( container );
            container.Configure ( c => c.For<IDocumentSessionProvider> ().HttpContextScoped ().Use<DocumentSessionProvider> () );
        }