/// <summary>
        /// Executes the task. Returns continuation of the next task(s) in the chain.
        /// </summary>
        /// <returns></returns>
        public override TaskContinuation Execute()
        {
            Func <Type, bool> filter = type => KnownTypes.ControllerType.IsAssignableFrom(type) &&
                                       type.Assembly != KnownAssembly.AspNetMvcAssembly &&
                                       !type.Assembly.GetName().Name.Equals(KnownAssembly.AspNetMvcFutureAssemblyName, StringComparison.OrdinalIgnoreCase) &&
                                       !IgnoredTypes.Any(ignoredType => ignoredType == type);

            Container.GetService <IBuildManager>()
            .ConcreteTypes
            .Where(filter)
            .Each(type => {
                var controllerName = type.Name;
                if (controllerName.EndsWith("Controller"))
                {
                    controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
                }

                var areaName = type.Assembly.GetName().Name;

                var serviceKey = (areaName + "/" + controllerName).ToLowerInvariant();
                Container.RegisterType(serviceKey, KnownTypes.ControllerType, type, LifetimeType.Transient);
            });

            return(TaskContinuation.Continue);
        }
        /// <summary>
        /// Executes the task. Returns continuation of the next task(s) in the chain.
        /// </summary>
        /// <returns></returns>
        public override TaskContinuation Execute()
        {
            Func <Type, bool> filter = type => KnownTypes.ValueProviderFactoryType.IsAssignableFrom(type) &&
                                       type.Assembly != KnownAssembly.AspNetMvcAssembly &&
                                       !IgnoredTypes.Any(ignoredType => ignoredType == type);

            Container.GetService <IBuildManager>()
            .ConcreteTypes
            .Where(filter)
            .Each(type => Container.RegisterAsTransient(KnownTypes.ValueProviderFactoryType, type));

            return(TaskContinuation.Continue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the task.
        /// </summary><returns></returns>
        public override TaskContinuation Execute()
        {
            Func <Type, bool> filter = type => KnownTypes.ViewType.IsAssignableFrom(type) &&
                                       type.Assembly != KnownAssembly.AspNetMvcAssembly &&
                                       !type.Assembly.GetName().Name.Equals(KnownAssembly.AspNetMvcFutureAssemblyName, StringComparison.OrdinalIgnoreCase) &&
                                       !IgnoredTypes.Any(ignoredType => ignoredType == type);

            Container.GetService <IBuildManager>()
            .ConcreteTypes
            .Where(filter)
            .Each(type => Container.RegisterAsTransient(type));

            return(TaskContinuation.Continue);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Determines if the specified property should be included in the list of a given type's properties.
        /// <para>
        /// The default behavior is to check the property name against the <see cref="IgnoredNames"/> list
        /// and check the property type against the <see cref="IgnoredTypes"/> list. The type is
        /// checked for equality and via <see cref="Type.IsAssignableFrom(Type)"/>. If both the property
        /// type and the currently tested type are generic (<see cref="Type.IsGenericType"/>), the equality and assignable tests are repeated
        /// with the generic definitions obtained by calling <see cref="Type.GetGenericTypeDefinition"/>. Additionally,
        /// read-only properties are ignored.
        /// </para>
        /// </summary>
        /// <param name="property">The property</param>
        /// <returns>True if the property should be included, or false.</returns>
        protected virtual bool IncludeProperty(PropertyInfo property)
        {
            if (IgnoredNames.Contains(property.Name, StringComparer.OrdinalIgnoreCase))
            {
                return(false);
            }

            var type = property.PropertyType;

            if (IgnoredTypes.Any(a => {
                if (a.Equals(type))
                {
                    return(true);
                }
                if (a.IsAssignableFrom(type))
                {
                    return(true);
                }

                if (type.IsGenericType && a.IsGenericType)
                {
                    var genericA = a.GetGenericTypeDefinition();
                    var genericType = type.GetGenericTypeDefinition();
                    if (genericA.Equals(genericType))
                    {
                        return(true);
                    }
                    if (genericA.IsAssignableFrom(genericType))
                    {
                        return(true);
                    }
                }

                return(false);
            }))
            {
                return(false);
            }

            // If we have a read-only property, we don't want to map
            // it to anything.
            if (!property.CanWrite)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Executes the task. Returns continuation of the next task(s) in the chain.
        /// </summary>
        /// <returns></returns>
        public override TaskContinuation Execute()
        {
            Func <Type, bool> filter = type => KnownTypes.ActionInvokerType.IsAssignableFrom(type) && !IgnoredTypes.Any(ignoredType => ignoredType == type);

            Container.GetService <IBuildManager>()
            .ConcreteTypes
            .Where(filter)
            .Each(type => Container.RegisterAsTransient(type));

            return(TaskContinuation.Continue);
        }