public void Registr(Type IType, Type DType, bool isSingleton)
        {
            if (!IType.IsAssignableFrom(DType) && !IsOpenGenericType(IType))
            {
                return;
            }
            else if (IsOpenGenericType(IType) && IsOpenGenericType(DType))
            {
                if (DType.GetInterface(IType.Name) == null)
                {
                    return;
                }
            }

            DependencyInfo DInfo = new DependencyInfo(IType, DType, isSingleton);

            if (IsOpenGenericType(IType) && IsOpenGenericType(DType))
            {
                DInfo.isOpenGeneric = true;
            }

            if (Config.ContainsKey(IType))
            {
                if (Config[IType].Where(item => item.DependencyType.Equals(DType)).Count() == 0)
                {
                    Config[IType].Add(DInfo);
                }
            }
            else
            {
                Config.Add(IType, new List <DependencyInfo>()
                {
                    DInfo
                });
            }
        }
        public object CreateDependency(Type type, DependencyInfo info)
        {
            object obj = null;

            ConstructorInfo[] constructors = type.GetConstructors();
            constructors = constructors.OrderByDescending(constructor => constructor.GetParameters().Length).
                           Append(typeof(object).GetConstructor(Type.EmptyTypes)).
                           ToArray();

            for (int i = 0; i < constructors.Length; i++)
            {
                ParameterInfo[] parameters        = constructors[i].GetParameters();
                object[]        constructorParams = new object[parameters.Length];
                for (int j = 0; j < parameters.Length; j++)
                {
                    object result;
                    if (parameters[j].ParameterType.IsGenericTypeDefinition)
                    {
                        Type d1          = parameters[j].ParameterType;
                        Type constructed = d1.MakeGenericType(new Type[] { parameters[j].ParameterType.GetGenericArguments()[0] });
                        result = Activator.CreateInstance(constructed);
                    }
                    result = Resolve(parameters[j].ParameterType);
                    constructorParams[j] = result;
                }

                try
                {
                    obj            = Activator.CreateInstance(type, constructorParams);
                    info.isCreated = true;
                    break;
                }
                catch (Exception e) { }
            }
            return(obj);
        }