public void Process(Type type, Registry registry)
            {
                // Only work on concrete types
                if (!type.IsConcrete() || type.IsGenericType) return;

                // Register against all the interfaces implemented
                // by this concrete class
                type.GetInterfaces().Each(@interface => { registry.For(@interface).Use(type); });
            }
        public IBindingScope To(Type concreteType)
        {
            Assert.IsNotNull(concreteType);
            Assert.IsTrue(concreteType.IsConcrete());
            Assert.IsTrue(concreteType.Is(ContractType));

            return ToMethod(c => c.Container.Instantiator
                .Instantiate(new InjectionContext { Container = c.Container, DeclaringType = concreteType }));
        }
		public IEnumerable<Route> GetServiceRoutes(Type serviceType)
		{
			if (!serviceType.IsConcrete())
				throw new ArgumentException("Type " + serviceType + " must be a concrete type", "serviceType");

			return MethodsToRoutes(
				this.GetServiceMethodsFrom(serviceType)
					.Where(x => !x.IsShadowed(serviceType))
					.Select(x => x.IsVirtual? x.GetBaseDefinition(): x));
		}
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated())
                return;

            Type interfaceType = GetInterfaceType(type);

            if (interfaceType != null)
                registry.Register(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);
            }
        }
        public void Process(Type type, Registry registry)
        {
            // Only work on concrete types
            if (!type.IsConcrete() || type.IsGenericType) return;

            // Register against all the interfaces implemented
            // by this concrete class
            type.GetInterfaces()
                .Where(@interface => @interface.Name == string.Format("I{0}", type.Name))
                .ForEach(@interface => registry.For(@interface).Use(type).Singleton());
        }
        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 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)
            {
                Debug.WriteLine("Plugging {0} into {1}".ToFormat(type.Name, interfaceType.Name));
                registry.AddType(interfaceType, type);
                ConfigureFamily(registry.For(interfaceType));
            }
        }
Exemple #10
0
        public object Bind(Type type, IBindingContext context)
        {
            var entity = context.ValueAs(type, "Id");

            if (entity != null) return entity;

            if (type.IsConcrete())
            {
                return Activator.CreateInstance(type);
            }

            return null;
        }
        public void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete())
                return;
            
            if (!typeof(IHelpContext).IsAssignableFrom(type))
                return;

            var name = type.GetCustomAttributes(false).OfType<InstanceNameAttribute>().Select(x => x.Name).FirstOrDefault();
            if (string.IsNullOrEmpty(name))
                return;
            registry.For(typeof(IHelpContext)).Use(type).Named(name.ToLowerInvariant());
        }
        public override void Process(Type type, Registry registry)
        {
            if (!type.IsConcrete())
                return;
            
            var pluginType = FindPluginType(type);
            if (pluginType == null || !Constructor.HasConstructors(type))
                return;

            registry.For(pluginType)
                .EnrichWith(z => DynamicProxy.CreateInterfaceProxyWithTarget(pluginType, z, _aspects))
                .Use(type);
        }
        public void Process(Type type, Registry registry)
        {
            // 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 Func<string, object> ConverterFor(Type type)
        {
            if (!type.IsConcrete()) {
                return null;
            }
            var constructor = type.GetConstructor (new [] { typeof(string) });
            if (constructor == null) {
                return null;
            }

            var param = Expression.Parameter (typeof(string), "arg");
            var body = Expression.New (constructor, param);

            return Expression.Lambda<Func<string, object>> (body, param).Compile();
        }
        public override void Process(Type type, Registry registry)
        {
            var interfaceTypes = type.FindInterfacesThatClose(_openType);
            if (!interfaceTypes.Any()) return;

            if (type.IsConcrete())
            {
                _concretions.Add(type);
            }

            foreach (var interfaceType in interfaceTypes)
            {
                _interfaces.Add(interfaceType);
            }
        }
	    public void Process(Type type, Registry registry)
	    {
            // ignore interfaces and abstract classes
            if (type.IsConcrete() == false)
                return;

            Type baseType = type.BaseType;

            // IF type has basetype AND basetype is generic AND basetype is Map<> THEN
            if (baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition() == m_mapType)
            {
                var instance = Activator.CreateInstance(type);
                string instanceName = instance.GetType().GetProperty("TemplatePath").GetValue(instance, null).ToString();
                registry.AddType(typeof(IMap), type, instanceName.ToLower());
            }
	    }
        PluginFamily IFamilyPolicy.Build(Type pluginType)
        {
            if (pluginType.IsConcrete())
            {
                return null;
            }

            var family = new PluginFamily(pluginType);

            var service = _locator.Service(pluginType);

            var instance = new ObjectInstance(service);

            family.SetDefault(instance);

            return family;
        }
Exemple #18
0
        private static IEnumerable<Type> rawFindInterfacesThatCloses(Type pluggedType, Type templateType)
        {
            if (!pluggedType.IsConcrete()) yield break;

            if (templateType.IsInterface)
            {
                foreach (var interfaceType in pluggedType.GetInterfaces().Where(type => type.IsGenericType && (type.GetGenericTypeDefinition() == templateType)))
                {
                    yield return interfaceType;
                }
            }
            else if (pluggedType.BaseType.IsGenericType && (pluggedType.BaseType.GetGenericTypeDefinition() == templateType))
            {
                yield return pluggedType.BaseType;
            }

            if (pluggedType.BaseType == typeof(object)) yield break;

            foreach (var interfaceType in rawFindInterfacesThatCloses(pluggedType.BaseType, templateType))
            {
                yield return interfaceType;
            }
        }
Exemple #19
0
            public void Process(Type type, Registry registry)
            {
                if (!type.IsConcrete())
                    return;

                Type matchingInterface = type.GetInterfaces().Where(x => x.Name.EndsWith(type.Name)).FirstOrDefault();
                if (matchingInterface == null)
                    return;

                registry.For(matchingInterface).Use(type);
            }
Exemple #20
0
 private static bool IsConventionTest(Type type)
 {
     return type.IsClass && type.IsConcrete<IConventionTest>();
 }
 public void Process(Type type, Registry registry)
 {
     if (type.IsConcrete() && type.Name.EndsWith("Job"))
         registry.For(type).Singleton();
 }
Exemple #22
0
            public void Process(Type type, Registry registry)
            {
                if (!type.IsConcrete())
                    return;

                if (!type.Name.EndsWith("Impl"))
                    return;

                string interfaceName = type.Name.Substring(0, type.Name.Length - 4);

                Type match = type.GetInterfaces()
                    .Where(x => x.Name.Equals(interfaceName))
                    .Where(x => type.Namespace.StartsWith(x.Namespace))
                    .SingleOrDefault();

                if (match != null)
                {
                    registry.AddType(match, type);
                }
            }
		public bool CanCreateBindingDelegateFor(Type requestType)
		{
			return requestType.IsConcrete();
		}