public OneWayRequestSuite() : base(40, 20) { IoC.Container = new Agatha.Unity.Container(); serviceLayerConfiguration = new ServiceLayerConfiguration(Assembly.GetExecutingAssembly(), Assembly.GetExecutingAssembly(), IoC.Container) { BusinessExceptionType = typeof(BusinessException), SecurityExceptionType = typeof(SecurityException), CacheManagerImplementation = typeof(CacheManagerSpy) }; serviceLayerConfiguration.Initialize(); // i want to take advantage of the automatic initialization, so i'm just resolving the requestprocessor instead of creating it requestProcessor = IoC.Container.Resolve <IRequestProcessor>(); // the cache manager is a singleton so i can just resolve it and it'll be the same one the request processor uses cacheManager = (CacheManagerSpy)IoC.Container.Resolve <ICacheManager>(); firstOneWayRequestHandler = MockRepository.GenerateMock <IOneWayRequestHandler <FirstOneWayRequest> >(); secondOneWayRequestHandler = MockRepository.GenerateMock <IOneWayRequestHandler <SecondOneWayRequest> >(); thirdOneWayRequestHandler = MockRepository.GenerateMock <IOneWayRequestHandler <ThirdOneWayRequest> >(); IoC.Container.RegisterInstance(firstOneWayRequestHandler); IoC.Container.RegisterInstance(secondOneWayRequestHandler); IoC.Container.RegisterInstance(thirdOneWayRequestHandler); }
public static void Register() { var configuration = new ServiceLayerConfiguration(typeof(GetConsultantsHandler).Assembly, typeof(GetConsultantsRequest).Assembly, typeof(Agatha.Ninject.Container)); configuration.Initialize(); }
/// <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 RunnyHostService() { var configuration = new ServiceLayerConfiguration ( requestHandlersAssembly: typeof(EchoHandler).Assembly, requestsAndResponsesAssembly: typeof(EchoRequest).Assembly, containerImplementation: typeof(Container) ); configuration.Initialize(); _host = new ServiceHost(typeof(WcfRequestProcessor)); }
public static void Register() { var container = new Ninject.Container(Container.Kernel); var config = new ServiceLayerConfiguration( Assembly.GetExecutingAssembly(), typeof(HelloWorldRequest).Assembly, container) { CacheManagerImplementation = typeof(InvalidatingCacheManager) }; config.Initialize(); }
static ServiceLayerComponentResolving() { IoC.Container = null; KnownTypeProvider.ClearAllKnownTypes(); requestHandlerAssemblies = new List <Assembly> { Assembly.GetExecutingAssembly(), typeof(RequestHandlerB).Assembly }; requestResponseAssemblies = new List <Assembly> { Assembly.GetExecutingAssembly(), typeof(RequestB).Assembly }; configuration = new ServiceLayerConfiguration(requestHandlerAssemblies[0], requestResponseAssemblies[0], Activator.CreateInstance <TContainer>()); configuration.AddRequestHandlerAssembly(requestHandlerAssemblies[1]); configuration.AddRequestAndResponseAssembly(requestResponseAssemblies[1]); configuration.Use <RequestHandlerBasedConventions>(); configuration.Initialize(); }
/// <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(); }