示例#1
0
        //TODO
        private static ConstructorDefImpl CreateConstructorDef(ConstructorInfo constructor, bool injectable)
        {
            var parameters = constructor.GetParameters();

            IConstructorArg[] args = new ConstructorArgImpl[parameters.Length];

            for (int i = 0; i < parameters.Length; i++)
            {
                //TODO for getInterfaceTarget() call
                Type type = parameters[i].ParameterType;
                type = ReflectionUtilities.EnsureInterfaceType(type);
                //if (type.IsGenericType && type.FullName == null)
                //{
                //    type = type.GetGenericTypeDefinition();
                //}
                bool isFuture;

                if (ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(IInjectionFuture <>), type))
                {
                    type     = ReflectionUtilities.GetInterfaceTarget(typeof(IInjectionFuture <>), type);
                    isFuture = true;
                }
                else
                {
                    isFuture = false;
                }

                ParameterAttribute named = parameters[i].GetCustomAttribute <ParameterAttribute>();
                if (named != null && !injectable)
                {
                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException(constructor + " is not injectable, but it has an @Parameter annotation."), LOGGER);
                }

                if (type == null)
                {
                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Exception"), LOGGER);
                }

                string typename = ReflectionUtilities.GetAssemblyQualifiedName(type);
                if (typename == null)
                {
                    typename = type.Name;
                }
                args[i] = new ConstructorArgImpl(typename, named == null ? null : ReflectionUtilities.GetAssemblyQualifiedName(named.Value), isFuture);
            }
            return(new ConstructorDefImpl(ReflectionUtilities.GetAssemblyQualifiedName(constructor.DeclaringType), args, injectable));
        }
示例#2
0
        public override bool Equals(Object o)
        {
            ConstructorArgImpl arg = (ConstructorArgImpl)o;

            if (!type.Equals(arg.type))
            {
                return(false);
            }
            if (name == null && arg.name == null)
            {
                return(true);
            }
            if (name == null && arg.name != null)
            {
                return(false);
            }
            if (name != null && arg.name == null)
            {
                return(false);
            }
            return(name.Equals(arg.name));
        }