Ejemplo n.º 1
0
            /// <summary>
            /// Registers the specified type.
            /// </summary>
            /// <param name="type">The specified type.</param>
            /// <param name="registry">The registry.</param>
            public void Process(Type type, Registry registry)
            {
                if (type.IsAbstract || !type.IsClass || !type.Name.EndsWith("Repository"))
                {
                    return;
                }

                Type interfaceType;

                try
                {
                    interfaceType = RepositoryInterfaces.Single(p => p.Name == "I" + type.Name);
                }
                catch (ArgumentNullException)
                {
                    interfaceType = null;
                }
                catch (InvalidOperationException)
                {
                    interfaceType = null;
                }

                if (interfaceType == null)
                {
                    // todo log
                    throw new Exception("Could not find the corresponding interface for Repository:" + type.Name);
                }

                registry.AddType(interfaceType, type);
            }
 public void Process(Type type, Registry registry)
 {
     if (type.ImplementsInterface<ILatticeGroup>() && !type.IsAbstract && type.IsPublic)
     {
         registry.AddType(typeof(ILatticeGroup), type, type.FullName);
     }
 }
Ejemplo n.º 3
0
 public void Process(Type type, Registry registry)
 {
     if (type.GetInterfaces().Contains(typeof(IModule)))
     {
         registry.AddType(typeof(IModule), type);
     }
 }
 public void RegisterTypes(Registry registry)
 {
     foreach (var batchPipelineBehaviourType in _batchPipelineBehaviourTypes)
     {
         registry.AddType(batchPipelineBehaviourType, batchPipelineBehaviourType);
     }
 }
Ejemplo n.º 5
0
 public void RegisterTypes(Registry registry)
 {
     foreach (var messagePipelineBehaviourType in _messagePipelineBehaviourTypes)
     {
         registry.AddType(messagePipelineBehaviourType, messagePipelineBehaviourType);
     }
 }
 public void Process(Type type, Registry registry)
 {
     if (PluggableAttribute.MarkedAsPluggable(type))
     {
         registry.AddType(type);
     }
 }
Ejemplo n.º 7
0
 public void Process(Type type, Registry registry)
 {
     if (PluggableAttribute.MarkedAsPluggable(type))
     {
         registry.AddType(type);
     }
 }
        public void Process(Type type, Registry registry)
        {
            var validatorTypes = type.FindInterfacesThatClose(typeof(IValidator<>));

            foreach(var validatorType in validatorTypes)
                registry.AddType(validatorType, type);
        }
 public void Process(Type type, Registry registry)
 {
     if (!type.IsAbstract && typeof(ICommandEvent).IsAssignableFrom(type))
     {
         registry.AddType(typeof(ICommand), typeof(EventCommand<>).MakeGenericType(type), type.Name);
     }
 }
 public void Process(Type type, Registry registry)
 {
     if (!type.IsAbstract && typeof(IController).IsAssignableFrom(type))
     {
        registry.AddType(type, type);
     }
 }
        public void Process(Type type, Registry registry)
        {
            var interceptorTypes = type.FindInterfacesThatClose(typeof(IInterceptor<>));

            foreach(var interceptorType in interceptorTypes)
                registry.AddType(interceptorType, type);
        }
Ejemplo n.º 12
0
 public void Process(Type type, Registry registry)
 {
     if (type.IsClosedTypeOf(openGenericInterfaceCollectionType))
     {
         registry.AddType(openGenericInterfaceCollectionType, type);
     }
 }
 public void Process(Type type, Registry registry)
 {
     if (!type.IsAbstract && typeof(IController).IsAssignableFrom(type))
     {
         registry.AddType(type, type);
     }
 }
 public void Process(Type type, Registry registry)
 {
     if (IsConcreteClass(type))
     {
         registry.AddType(type, type);
     }
 }
Ejemplo n.º 15
0
        public void Process(Type type, Registry registry)
        {
            if (type.Assembly == _thisAssembly)
            {
                return;
            }

            if (type.CanBeCastTo(typeof(IFixture)))
            {
                registry.AddType(typeof(IFixture), type, type.GetFixtureAlias());
            }

            if (type.IsConcreteAndAssignableTo(typeof(IStartupAction)))
            {
                registry.AddType(typeof(IStartupAction), type, type.Name.Replace("Action", string.Empty));
            }
        }
Ejemplo n.º 16
0
        public EventsModule()
        {
            Registry.AddType(typeof(IEventer <>), typeof(EventSink <>));

            Registry
            .AddType <IEventSystem, EventSystem>()
            .WithAlias <IPipeFactory>();
        }
        public void Process(Type type, Registry registry)
        {
            if (!type.CanBeCastTo(typeof(IStatusCodeTranslator))) return;

            var name = type.Name.Replace("StatusCodeTranslator", "");

            registry.AddType(typeof (IStatusCodeTranslator), type, name);
        }
 public void Process(Type type, Registry registry)
 {
     Type interfaceType = type.FindFirstInterfaceThatCloses(_openGenericType);
     if (interfaceType != null)
     {
         registry.AddType(interfaceType, type);
     }
 }
Ejemplo n.º 19
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);
     });
 }
Ejemplo n.º 20
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);
     });
 }
Ejemplo n.º 21
0
        public LocalModule()
        {
            Include <ComplexModule>();

            Registry.Instance(new LocalService());

            Registry.AddType <ILocalService, LocalService>();
        }
Ejemplo n.º 22
0
        public ComplexModule()
        {
            Include <SimpleModule>();

            Registry.Instance(new OtherService());

            Registry.AddType <IOtherService, OtherService>();
        }
Ejemplo n.º 23
0
 public void Process(Type type, Registry registry)
 {
     if (type.CanBeCastTo(_pluginType) && Constructor.HasConstructors(type))
     {
         string name = _getName(type);
         registry.AddType(GetLeastSpecificButValidType(_pluginType, type), type, name);
     }
 }
        public void Process(Type type, Registry registry)
        {
            if (!type.CanBeCastTo(typeof(IResponseWriter))) return;

            var name = type.Name.Replace("ResponseWriter", "");

            registry.AddType(typeof (IResponseWriter), type, name);
        }
Ejemplo n.º 25
0
 public void Process(Type type, Registry registry)
 {
     if (type.CanBeCastTo(_pluginType) && Constructor.HasConstructors(type))
     {
         string name = _getName(type);
         registry.AddType(GetLeastSpecificButValidType(_pluginType, type), type, name);
     }
 }
Ejemplo n.º 26
0
        public void Process(Type type, Registry registry)
        {
            Type interfaceType = type.FindFirstInterfaceThatCloses(_openGenericType);

            if (interfaceType != null)
            {
                registry.AddType(interfaceType, type);
            }
        }
Ejemplo n.º 27
0
		public void ProcessFacade(Type type, Registry registry, Type facadeInterface, Type genericFacadeInterface, Type concreteFacade)
		{
			if (type.ImplementsInterfaceTemplate(genericFacadeInterface))
			{
				var interfaceType = type.FindFirstInterfaceThatCloses(genericFacadeInterface);
				var commandMessageTypes = interfaceType.GetGenericArguments();

				var closesQuerryProcessor =
					concreteFacade.MakeGenericType(commandMessageTypes);

				registry.AddType(closesQuerryProcessor);
				registry.AddType(interfaceType, type);
			}
			if (facadeInterface.IsAssignableFrom(type) && !type.IsInterface)
			{
				registry.AddType(facadeInterface, type);
			}
		}
 public void Process(Type type, Registry registry)
 {
     bool hasInjectAttribute = type.GetCustomAttributes(false)
                                   .Any(attr => attr.Equals(typeof(InjectAttribute)));
     if (hasInjectAttribute)
     {
         registry.AddType(type);
     }
 }
Ejemplo n.º 29
0
        public void ProcessFacade(Type type, Registry registry, Type facadeInterface, Type genericFacadeInterface, Type concreteFacade)
        {
            if (type.ImplementsInterfaceTemplate(genericFacadeInterface))
            {
                var interfaceType = type.FindFirstInterfaceThatCloses(genericFacadeInterface);
                var commandMessageTypes = interfaceType.GetGenericArguments();

                var closesQuerryProcessor =
                    concreteFacade.MakeGenericType(commandMessageTypes);

                registry.AddType(closesQuerryProcessor);
                registry.AddType(interfaceType, type);
            }
            if (facadeInterface.IsAssignableFrom(type) && !type.IsInterface)
            {
                registry.AddType(facadeInterface, type);
            }
        }
Ejemplo n.º 30
0
        public void Process(Type type, Registry registry)
        {
            if (!type.CanBeCastTo(typeof (IController)))
                return;

            string name = GetName(type);

            registry.AddType(typeof (IController), type, name);
        }
Ejemplo n.º 31
0
        public void Process(Type type, Registry registry)
        {
            if (type.IsAbstract || !type.IsClass || !typeof(ICommand).IsAssignableFrom(type))
            {
                return;
            }

            registry.AddType(typeof(ICommand), type, type.Name);
        }
        /// <summary>
        /// Processes types from an assembly for controllers and implements controller overriding behavior
        /// </summary>
        /// <param name="type">Type to process</param>
        /// <param name="registry">Registry on which to register controllers</param>
        public void Process(Type type, Registry registry)
        {
            // ensure the type is not null, registry isn't null and the type is a valid controller
            if (registry == null || !IsValidController(type))
                return;

            var baseClass = type.BaseType;

            // type must inherit from controller with same type name to be overriden.
            // The type should be added as normal
            // NOTE: this can be extended to be resolved by attribute or something of the sort
            if (!IsValidController(baseClass) || !baseClass.Name.Equals(type.Name))
                registry.AddType(typeof(IController), type);
            else
            {
                registry.AddType(typeof(IController), baseClass);
                registry.RegisterInterceptor(new TypeReplacementInterceptor(baseClass, type));
            }
        }
Ejemplo n.º 33
0
 /// <inheritdoc />
     public void Process(Type type, Registry registry)
     {           
         Type interfaceType = type.GetInterface(typeof(IFoo).Name);
         if (interfaceType == null)
         {
             return;
         }
         registry.AddType(interfaceType, type, type.Name);
         // Do your stuff with INewFoo
     }
        /// <summary>
        /// Processes types from an assembly for controllers and implements controller overriding behavior
        /// </summary>
        /// <param name="type">Type to process</param>
        /// <param name="registry">Registry on which to register controllers</param>
        public void Process(Type type, Registry registry)
        {
            // ensure the type is not null, registry isn't null and the type is a valid controller
            if (registry == null || !IsValidController(type))
                return;

            var baseClass = type.BaseType;

            // type must inherit from controller with same type name to be overriden.
            // The type should be added as normal
            // NOTE: this can be extended to be resolved by attribute or something of the sort
            if (!IsValidController(baseClass) || !baseClass.Name.Equals(type.Name))
                registry.AddType(typeof(IController), type);
            else
            {
                registry.AddType(typeof(IController), baseClass);
                registry.RegisterInterceptor(new TypeReplacementInterceptor(baseClass, type));
            }
        }
        public void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete()) return;

            var baseType = type.BaseType;
            if (baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition() == m_mapType)
            {
                registry.AddType(baseType, type);
            }
        }
        public void Process(Type type, Registry registry)
        {
            if (type.GetInterfaces().Contains(typeof(IDeviceStrategy)))
            {
                registry.AddType(typeof(IDeviceStrategy), type);

                foreach (Attribute attr in Attribute.GetCustomAttributes(type))
                    if (attr is OsDeviceAttribute)
                        Common.DeviceStrategy.Add(((OsDeviceAttribute)attr).Name, type);
            }
        }
Ejemplo n.º 37
0
        public void Process(Type type, Registry registry)
        {
            if (type.GetTypeInfo().IsAbstract) return;
            if (type.GetTypeInfo().IsInterface) return;

            if (type.CanBeCastTo(_pluginType) && type.HasConstructors())
            {
                var name = _getName(type);
                registry.AddType(GetLeastSpecificButValidType(_pluginType, type), type, name);
            }
        }
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete()) return;

            var pluginType = FindPluginType(type);
            if (pluginType != null && type.HasConstructors())
            {
                registry.AddType(pluginType, type);
                ConfigureFamily(registry.For(pluginType));
            }
        }
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated()) return;

            Type interfaceType = type.AllInterfaces().FirstOrDefault();
            if (interfaceType != null)
            {
                registry.AddType(interfaceType, type);
                ConfigureFamily(registry.For(interfaceType));
            }
        }
        public void Process(Type type, Registry registry)
        {
            if (IsNotRegisterable(type))
            {
                return;
            }

            var interfaceType = type.GetInterface(type.Name.Replace("Implementation", string.Empty));

            registry.AddType(interfaceType, type);
        }
Ejemplo n.º 41
0
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated()) return;

            Type interfaceType = type.AllInterfaces().FirstOrDefault();
            if (interfaceType != null)
            {
                Debug.WriteLine("Plugging {0} into {1}".ToFormat(type.Name, interfaceType.Name));
                registry.AddType(interfaceType, type);
                ConfigureFamily(registry.For(interfaceType));
            }
        }
Ejemplo n.º 42
0
 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));
         }
     });
 }
Ejemplo n.º 43
0
 public void Process(Type type, Registry registry)
 {
     var m = _lastPascalWord.Match(type.Name);
     if (!type.IsAbstract && !type.IsInterface && type.IsPublic && m.Success)
     {
         var interfaceType = type.GetInterfaces().FirstOrDefault(iface => iface.Name.EndsWith(m.Value));
         if (null != interfaceType)
         {
             registry.AddType(interfaceType, type, type.Name);
         }
     }
 }
Ejemplo n.º 44
0
        public void Process(Type type, Registry registry)
        {
            if (type.Assembly == _thisAssembly)
            {
                return;
            }

            if (type.CanBeCastTo(typeof(IFixture)))
            {
                registry.AddType(typeof(IFixture), type, type.GetFixtureAlias());
            }
        }
Ejemplo n.º 45
0
 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));
         }
     });
 }
Ejemplo n.º 46
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));
         }
     });
 }
Ejemplo n.º 47
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));
                }
            });

        }
        private static void ProcessInterfaceName(Type type, Registry registry, string interfaceName)
        {
            //Trace.WriteLine(string.Format("RepositoryIntConvention: testing type: {0}, formatted: {1}"
            //        , type.Name, interfaceName));

            // Get interface and register (can use AddType overload method to create named types
            Type interfaceType = type.GetInterface(interfaceName);

            if (null != interfaceType)
            {
            Trace.WriteLine("RepositoryIntConvention: adding type: " + type.Name);
            registry.AddType(interfaceType, type);
            }
        }
        public void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete())
            {
                return;
            }

            var baseType = type.BaseType;

            if (baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition() == m_mapType)
            {
                registry.AddType(baseType, type);
            }
        }
Ejemplo n.º 50
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));
                }
            });
        }
Ejemplo n.º 51
0
        /// <summary>
        /// Processa mapeamento
        /// </summary>
        /// <param name="type">Tipo sendo mapeado</param>
        /// <param name="registry">Grafo de objetos do assembly 'scaneado'</param>
        public void Process(Type type, Registry registry)
        {
            if (type.IsAbstract)
            {
                return;
            }

            var interfaceName = this.GetInterfaceName(type);
            var interfaceType = type.GetInterface(interfaceName);

            if (interfaceType != null)
            {
                registry.AddType(interfaceType, type);
            }
        }
Ejemplo n.º 52
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));
                }
            });
        }
Ejemplo n.º 53
0
        public void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete())
            {
                return;
            }

            foreach (var @interface in type.GetInterfaces())
            {
                if (@interface.IsGenericType && @interface.GetGenericTypeDefinition() == _openIHandlesType)
                {
                    registry.AddType(@interface, type);
                }
            }
        }
Ejemplo n.º 54
0
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete())
            {
                return;
            }

            Type pluginType = FindPluginType(type);

            if (pluginType != null && Constructor.HasConstructors(type))
            {
                registry.AddType(pluginType, type);
                ConfigureFamily(registry.For(pluginType));
            }
        }
Ejemplo n.º 55
0
    public override void Process(Type type, Registry registry)
    {
        if (!TypeExtensions.IsConcrete(type))
        {
            return;
        }
        Type pluginType = this.FindPluginType(type);

        if (pluginType == null || !TypeExtensions.HasConstructors(type))
        {
            return;
        }
        registry.AddType(pluginType, type);
        this.ConfigureFamily(registry.For(pluginType, (ILifecycle)null));
    }
Ejemplo n.º 56
0
        public void Process(Type type, Registry registry)
        {
            if (!type.IsConcreteAndAssignableTo(typeof(IReportGenerator)))
            {
                return;
            }

            if (!type.Name.EndsWith("ReportGenerator"))
            {
                return;
            }

            var generatorName = type.Name.Remove(type.Name.IndexOf("ReportGenerator"));

            registry.AddType(typeof(IReportGenerator), type, generatorName);
        }
        public void ProcessHandler(Type type, Registry registry, Type typeInterface, Type handlerInterface, Type concreteHandler)
        {
            if (type.ImplementsInterfaceTemplate(typeInterface))
            {
                Type   interfaceType    = type.FindFirstInterfaceThatCloses(typeInterface);
                Type[] genericArguments = interfaceType.GetGenericArguments();

                Type closeActionProcessprInterface =
                    handlerInterface.MakeGenericType(genericArguments);

                Type closesActionProcessor =
                    concreteHandler.MakeGenericType(genericArguments);

                registry.For(closeActionProcessprInterface).Use(closesActionProcessor);
                registry.AddType(interfaceType, type);
            }
        }
Ejemplo n.º 58
0
        public void Process(Type type, Registry registry)
        {
            if (type.IsAbstract)
            {
                return;
            }
            if (type.IsInterface)
            {
                return;
            }

            if (type.CanBeCastTo(_pluginType) && type.HasConstructors())
            {
                var name = _getName(type);
                registry.AddType(GetLeastSpecificButValidType(_pluginType, type), type, name);
            }
        }
Ejemplo n.º 59
0
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated())
            {
                return;
            }


            var interfaceType = type.AllInterfaces().FirstOrDefault();

            if (interfaceType != null)
            {
                Debug.WriteLine("Plugging {0} into {1}".ToFormat(type.Name, interfaceType.Name));
                registry.AddType(interfaceType, type);
                ConfigureFamily(registry.For(interfaceType));
            }
        }
Ejemplo n.º 60
0
    public override void Process(Type type, Registry registry)
    {
        if (!type.IsConcrete())
        {
            return;
        }
        var pluginType = this.FindPluginType(type);

        if (pluginType == null || !type.HasConstructors())
        {
            return;
        }
        registry.AddType(pluginType, type);
        var policy = CreatePolicy(pluginType);

        registry.Policies.Interceptors(policy);
        ConfigureFamily(registry.For(pluginType));
    }