예제 #1
0
        public override void ScanTypes(TypeSet types, Registry registry)
        {
            var interfaces = types.FindTypes(TypeClassification.Interfaces);
            var concretes = types.FindTypes(TypeClassification.Concretes).Where(x => x.HasConstructors()).ToArray();

            interfaces.Each(@interface =>
            {
                var implementors = concretes.Where(x => x.CanBeCastTo(@interface)).ToArray();
                if (implementors.Count() == 1)
                {
                    registry.AddType(@interface, implementors.Single());
                    ConfigureFamily(registry.For(@interface));
                }
            });
        }
예제 #2
0
        public void ScanTypes(TypeSet types, Registry registry)
        {
            types.FindTypes(TypeClassification.Closed | TypeClassification.Concretes)
                .Where(Registry.IsPublicRegistry)
                .Each(type => registry.Configure(x => x.ImportRegistry(type)));

        }
예제 #3
0
 public void ScanTypes(TypeSet types, Registry registry)
 {
     types.FindTypes(TypeClassification.Concretes).Where(Matches).Each(type =>
     {
         var name = _getName(type);
         registry.AddType(GetLeastSpecificButValidType(_pluginType, type), type, name);
     });
 }
예제 #4
0
        public void ScanTypes(TypeSet types, Registry registry)
        {
            // Only work on concrete types
            types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ForEach(type =>
            {

                if (type.Name.EndsWith("Job"))
                    registry.For(type).Singleton();
            });
        }
 public void ScanTypes(TypeSet types, Registry registry)
 {
     // Only work on concrete types
     types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).Each(type =>
     {
         // Register against all the interfaces implemented
         // by this concrete class
         type.GetInterfaces().Each(@interface => registry.For(@interface).Use(type));
     });
 }
예제 #6
0
        public void ScanTypes(TypeSet types, Registry registry)
        {
            var matches = types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed)
                .Where(type => type.CanBeCastTo<ITeam>());

            foreach (var type in matches)
            {
                registry.For(typeof (ITeam)).Add(type);
            }
        }
 public void ScanTypes(TypeSet types, Registry registry)
 {
     types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ForEach(type =>
     {
         if (type.CanBeCastTo<ControllerBase>())
         {
             registry.For(type).LifecycleIs(new UniquePerRequestLifecycle()).Use(type);
         }
     });
 }
예제 #8
0
		public void ScanTypes(TypeSet types, Registry registry)
		{
			var controllerTypes =
				types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed)
					.Where(t => t.CanBeCastTo<Controller>());
			foreach (var type in controllerTypes)
			{
				registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());

			}
		}
 public override void ScanTypes(TypeSet types, Registry registry)
 {
     types.FindTypes(TypeClassification.Concretes).Where(type => type.HasConstructors()).Each(type =>
     {
         var pluginType = FindPluginType(type);
         if (pluginType != null)
         {
             registry.AddType(pluginType, type);
             ConfigureFamily(registry.For(pluginType));
         }
     });
 }
예제 #10
0
        public override void ScanTypes(TypeSet types, Registry registry)
        {
            types.FindTypes(TypeClassification.Concretes).Where(x => x.HasConstructors()).Each(type =>
            {
                var interfaceType = type.AllInterfaces().FirstOrDefault();
                if (interfaceType != null)
                {
                    registry.AddType(interfaceType, type);
                    ConfigureFamily(registry.For(interfaceType));
                }
            });

        }
예제 #11
0
        public void ScanTypes(TypeSet types, Registry registry)
        {
            // Only work on concrete types
            types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ForEach(type =>
            {

                type.GetInterfaces()
                    .Where(@interface => @interface.Name == $"I{type.Name}")
                    .ForEach(@interface => registry.For(@interface).Use(type).Singleton());

                if (type.Name.EndsWith("Job"))
                    registry.For(type).Singleton();
            });
        }
예제 #12
0
 public void ScanTypes(TypeSet types, Registry registry)
 {
     foreach(var type in types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed))
     {
         if (type.CanBeCastTo<Controller>() && !type.IsAbstract)
         {
             registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
         }
         else if (type.CanBeCastTo<ApiController>() && !type.IsAbstract)
         {
             registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
         }
     }
 }
예제 #13
0
        /// <summary>
        /// Registers found Rebus handler types in the container
        /// </summary>
        public void ScanTypes(TypeSet types, global::StructureMap.Registry registry)
        {
            var messageHandlers = types.FindTypes(TypeClassification.Concretes)
                .Where(t => t.CanBeCastTo(typeof(IHandleMessages)));

            foreach (var handlerType in messageHandlers)
            {
                var handlerInterfaces = handlerType.GetInterfaces().Where(IsHandler).ToList();

                foreach (var handlerInterface in handlerInterfaces)
                {
                    registry
                        .For(handlerInterface)
                        .Use(handlerType)
                        .LifecycleIs<UniquePerRequestLifecycle>();
                }
            }
        }
예제 #14
0
        public void ScanTypes(TypeSet types, Registry registry)
        {

            // Only work on concrete types
            types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ForEach(type =>
            {

                // Only work on concrete types
             //   if (!type.IsConcrete() || type.IsGenericType) return;

                // Add against all the interfaces implemented
                // by this concrete class
                type.GetInterfaces()
                    .Where(@interface => @interface.Name == $"I{type.Name}")
                    .ForEach(@interface => registry.For(@interface).Use(type).Singleton());

                if (type.Name.EndsWith("Job"))
                    registry.For(type).Singleton();
            });

        }
 public void ScanTypes(TypeSet types, Registry registry)
 {
     types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ToList()
         .ForEach(service => RegisterInterfaces(registry, service));
 }