Exemple #1
0
        public void ProcessType(IContainerConfiguration container, TypeInfo type)
        {
            foreach (var serviceType in type.ImplementedInterfaces)
            {
                if (serviceType.IsConstructedGenericType)
                {
                    var typeDefinition = serviceType.GetGenericTypeDefinition();
                    if (typeDefinition == ServiceLoaderTypeDefinition)
                    {
                        container.
                        Register(serviceType).
                        AsTransient().
                        UsingConcreteType(type.AsType());

                        var dataType = serviceType.GenericTypeArguments[0];
                        var dataTypeConfiguration = new ServiceLoaderActivatorConfiguration(dataType);

                        container.Register(dataTypeConfiguration);
                    }
                }
            }
        }
Exemple #2
0
        public void ProcessType(IContainerConfiguration container, TypeInfo type)
        {
            if (type.IsAbstract || type.IsInterface || type.IsNested)
            {
                return;
            }

            if (ApiControllerType.IsAssignableFrom(type))
            {
                container.
                Register(type).
                AsTransient();
            }
        }
        private static void ProcessType(IContainerConfiguration container, TypeInfo concreteType, Type serviceType)
        {
            var typeDefinition = serviceType.GetGenericTypeDefinition();

            if (HandlerTypeDefinitions.Any(h => h == typeDefinition))
            {
                var serviceScope =
                    concreteType.GetServiceScope() ??
                    ServiceScope.Default;

                container.
                    Register(serviceType).
                    InScope(serviceScope).
                    UsingConcreteType(concreteType.AsType());
            }
        }
Exemple #4
0
        private void ConfigureContainer(IUnityContainer unityContainer,
                                        IQuartzConfig quartzConfig,
                                        ActorSystem actorSystem)
        {
            unityContainer.Register(new GridNodeContainerConfiguration(actorSystem,
                                                                       _transportMode,
                                                                       quartzConfig));

            _configuration.Register(unityContainer);

            var persistentScheduler = System.ActorOf(System.DI().Props <SchedulingActor>(), nameof(SchedulingActor));

            unityContainer.RegisterInstance(new TypedMessageActor <ScheduleMessage>(persistentScheduler));
            unityContainer.RegisterInstance(new TypedMessageActor <ScheduleCommand>(persistentScheduler));
            unityContainer.RegisterInstance(new TypedMessageActor <Unschedule>(persistentScheduler));
            unityContainer.RegisterInstance(_messageRouting);
        }
        public void ProcessType(IContainerConfiguration container, TypeInfo type)
        {
            var settingsAttribute = type.GetCustomAttribute<SettingsAttribute>();
            if (settingsAttribute != null)
            {
                var settingsType = type.AsType();
                var settingsScope = settingsAttribute.Scope;
                var activatorConfiguration = new SettingsActivatorConfiguration(settingsScope, settingsType);

                container.Register(activatorConfiguration);
            }

            foreach (var serviceType in type.ImplementedInterfaces)
            {
                ProcessServiceType(container, type, serviceType);
            }
        }
Exemple #6
0
        private void ProcessConcreteType(IContainerConfiguration container, TypeInfo concreteType)
        {
            var identities = GetIdentities(concreteType);

            foreach (var identity in identities)
            {
                var serviceType = identity.ServiceType.GetTypeInfo();
                var scope       =
                    concreteType.GetServiceScope() ??
                    serviceType.GetServiceScope() ??
                    ServiceScope.Default;

                container.
                Register(identity).
                InScope(scope).
                UsingConcreteType(concreteType.AsType());
            }
        }
        private static void ProcessServiceType(IContainerConfiguration container, TypeInfo concreteType, Type serviceType)
        {
            if (serviceType.IsConstructedGenericType)
            {
                var typeDefinition = serviceType.GetGenericTypeDefinition();
                if (typeDefinition == SettingsHandlerTypeDefinition)
                {
                    var serviceScope =
                        concreteType.GetServiceScope() ??
                        ServiceScope.Default;

                    container.
                        Register(serviceType).
                        InScope(serviceScope).
                        UsingConcreteType(concreteType.AsType());
                }
            }
        }
 public static void Register(this ContainerBuilder container, IContainerConfiguration configuration)
 {
     configuration.Register(container);
 }
 public static void Register(this IUnityContainer container, IContainerConfiguration configuration)
 {
     configuration.Register(container);
 }