Пример #1
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);
        }
Пример #2
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 serviceLayerConfiguration = new ServiceLayerConfiguration(structureMapContainer);

            // register request and response assemblies
            var             messageRegex      = new Regex("^Asam.Ppc.Service.Messages$");
            List <Assembly> messageAssebllies = AppDomain.CurrentDomain.GetAssembliesFromApplicationBaseDirectory()
                                                .Where(x => messageRegex.IsMatch(x.GetName().Name))
                                                .ToList();

            messageAssebllies.ForEach(
                x =>
            {
                List <Type> types =
                    x.GetTypes().     //Where(
                    //type => !type.IsSubclassOf(typeof (Request)) && !type.IsSubclassOf(typeof (Response))).
                    ToList();
                //types.ForEach(KnownTypeProvider.Register);

                serviceLayerConfiguration.AddRequestAndResponseAssembly(x);
            });

            // register request handler assemblies
            var             serviceRegex      = new Regex("^Asam.Ppc.Service.Handlers$");
            List <Assembly> serviceAssemblies = AppDomain.CurrentDomain.GetAssembliesFromApplicationBaseDirectory()
                                                .Where(x => serviceRegex.IsMatch(x.GetName().Name))
                                                .ToList();

            serviceAssemblies.ForEach(
                x => serviceLayerConfiguration.AddRequestHandlerAssembly(x));

            // register agatha conventions
            serviceLayerConfiguration.Use <RequestHandlerBasedConventions>();

            serviceLayerConfiguration.RequestProcessorImplementation = typeof(NHibernateTransactionRequestProcessor);

            // register business exception type
            //serviceLayerConfiguration.BusinessExceptionType = typeof(BusinessRuleException);

            serviceLayerConfiguration.Initialize();
        }
Пример #3
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 serviceLayerAndClientConfiguration =
                new ServiceLayerAndClientConfiguration(typeof(GetLookupsByCategoryRequestHandler).Assembly,
                                                       typeof(GetLookupsByCategoryRequest).Assembly,
                                                       structureMapContainer);

            // register agatha conventions
            serviceLayerAndClientConfiguration.Use <RequestHandlerBasedConventions> ();

            serviceLayerAndClientConfiguration.RequestDispatcherImplementation = typeof(AsyncRequestDispatcher);

            serviceLayerAndClientConfiguration.RequestProcessorImplementation =
                typeof(NHibernateTransactionRequestProcessor);

            serviceLayerAndClientConfiguration.Initialize();
            //KnownTypeProvider.ClearAllKnownTypes();
            //KnownTypesHelper.RegisterRequestsAndResponses(typeof(SaveDtoRequest<>).Assembly);
        }
Пример #4
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 );
        }