private void VisitMethods(MethodInfo method, RegisterElement element)
        {
            var attribute = method.GetDependencyInjectionOnMethod();

            if (attribute == null)
            {
                return;
            }

            var methodElement = new MethodElement()
            {
                name = method.Name
            };

            var param = this.VisitParam(method.GetParameters());

            methodElement.param = new List <ParamElement>();
            methodElement.param.AddRange(param);

            if (element.method == null)
            {
                element.method = new List <MethodElement>();
            }
            element.method.Add(methodElement);

            return;
        }
        private void VisitType(Type type, IList <RegisterElement> registers)
        {
            var attributes = type.GetDependencyContractsOfType();

            if (attributes == null)
            {
                attributes = new[] { new DependencyContractAttribute(type, LifetimeFlag.Default) }
            }
            ;

            foreach (var attribute in attributes)
            {
                var e = new RegisterElement();
                e.contract     = attribute.TypeOfContract != null ? attribute.TypeOfContract.AssemblyQualifiedName : type.AssemblyQualifiedName;
                e.key          = attribute.Key != null ? attribute.Key : null;
                e.dependencyTo = type.AssemblyQualifiedName;
                if (attribute.LifetimeFlag == LifetimeFlag.Default)
                {
                }
                else
                {
                    var lifetimeType = (LifetimeFlagType)Enum.Parse(typeof(LifetimeFlagType), attribute.LifetimeFlag.ToString());
                    e.lifetime = new LifetimeElement()
                    {
                        type = lifetimeType
                    };
                }



                type.GetConstructors(binding).ToList().ForEach(o => this.VisitConstructor(o, e));
                type.GetProperties(binding).ToList().ForEach(o => this.VisitProperty(o, e));
                type.GetMethods(binding).ToList().ForEach(o => this.VisitMethods(o, e));



                registers.Add(e);
            }

            var nestedTypes = type.GetNestedTypes(binding);

            if (nestedTypes.Count() > 0)
            {
                foreach (var nestedType in nestedTypes)
                {
                    this.VisitType(nestedType, registers);
                }
            }
        }
    }
        private void VisitProperty(PropertyInfo property, RegisterElement element)
        {
            if (element.property == null)
            {
                element.property = new List <PropertyElement>();
            }

            var attribute             = property.GetDependencyInjectionOnProperty();
            var defaultValueAttribute = property.GetDefaultValueOnProperty();

            var e = new PropertyElement();

            e.name = property.Name;

            if (attribute != null && attribute.DefaultValue != null)
            {
                e.Item = new ValueElement()
                {
                    value                       = attribute.DefaultValue != null?attribute.DefaultValue.ToString() : null,
                                           type = attribute.DefaultValue.GetType().ToString()
                };
                element.property.Add(e);
            }
            else if (attribute != null)
            {
                e.name = property.Name;

                e.Item = new DependencyElement()
                {
                    typeOfContract = property.PropertyType.AssemblyQualifiedName,
                    key            = attribute.Key != null?attribute.Key.ToString() : null
                };
                element.property.Add(e);
            }
            else if (defaultValueAttribute != null && defaultValueAttribute.Value != null)
            {
                e.Item = new ValueElement()
                {
                    value                       = defaultValueAttribute.Value != null?defaultValueAttribute.Value.ToString() : null,
                                           type = defaultValueAttribute.Value.GetType().ToString()
                };
                element.property.Add(e);
            }
        }
        private void VisitConstructor(ConstructorInfo constructor, RegisterElement element)
        {
            var attributes = constructor.GetDependencyInjectionOnConstructor();

            if (attributes == null || attributes.Count() > 1)
            {
                throw new FrameworkDependencyException();
            }

            var param = this.VisitParam(constructor.GetParameters());

            if (param.Count == 0)
            {
                return;
            }

            element.constructor = new List <ParamElement>();
            element.constructor.AddRange(param);
        }
 internal void Add(RegisterElement element)
 {
     this.InvalidRegisterElement.Add(element);
 }
 internal void Add(RegisterElement element)
 {
     this.InvalidRegisterElement.Add(element);
 }
        private void VisitConstructor(ConstructorInfo constructor, RegisterElement element)
        {
            var attributes = constructor.GetDependencyInjectionOnConstructor();
            if( attributes == null || attributes.Count() > 1 )
                throw new FrameworkDependencyException();

            var param = this.VisitParam(constructor.GetParameters());

            if( param.Count == 0 ) return;

            element.constructor = new List<ParamElement>();
            element.constructor.AddRange(param);
        }
        private void VisitType(Type type, IList<RegisterElement> registers)
        {
            var attributes = type.GetDependencyContractsOfType();
            if (attributes == null) attributes = new[] {new DependencyContractAttribute(type, LifetimeFlag.Default)};

            foreach (var attribute in attributes)
            {
                var e = new RegisterElement();
                e.contract        = attribute.TypeOfContract != null ? attribute.TypeOfContract.AssemblyQualifiedName : type.AssemblyQualifiedName;
                e.key             = attribute.Key != null ? attribute.Key : null;
                e.dependencyTo    = type.AssemblyQualifiedName;
                if (attribute.LifetimeFlag == LifetimeFlag.Default)
                {

                }
                else
                {
                    var lifetimeType = (LifetimeFlagType)Enum.Parse(typeof(LifetimeFlagType), attribute.LifetimeFlag.ToString());
                    e.lifetime = new LifetimeElement()
                    {
                        type = lifetimeType
                    };
                }

                type.GetConstructors(binding).ToList().ForEach(o => this.VisitConstructor(o, e));
                type.GetProperties(binding).ToList().ForEach(o => this.VisitProperty(o, e));
                type.GetMethods(binding).ToList().ForEach(o => this.VisitMethods(o, e));

                registers.Add(e);
            }

            var nestedTypes = type.GetNestedTypes(binding);
            if (nestedTypes.Count() > 0)
            {
                foreach (var nestedType in nestedTypes)
                {
                    this.VisitType(nestedType, registers);
                }
            }
        }
        private void VisitProperty(PropertyInfo property, RegisterElement element)
        {
            if (element.property == null)
                element.property = new List<PropertyElement>();

            var attribute = property.GetDependencyInjectionOnProperty();
            var defaultValueAttribute = property.GetDefaultValueOnProperty();

            var e = new PropertyElement();
            e.name            = property.Name;

            if (attribute != null && attribute.DefaultValue != null)
            {
                e.Item = new ValueElement() {
                    value = attribute.DefaultValue != null ? attribute.DefaultValue.ToString() : null,
                    type = attribute.DefaultValue.GetType().ToString()
                };
                element.property.Add(e);
            }
            else if( attribute != null )
            {
                e.name = property.Name;

                e.Item = new DependencyElement()
                {
                    typeOfContract = property.PropertyType.AssemblyQualifiedName,
                    key = attribute.Key != null ? attribute.Key.ToString() : null
                };
                element.property.Add(e);
            }
            else if (defaultValueAttribute != null && defaultValueAttribute.Value != null )
            {
                e.Item = new ValueElement() {
                    value = defaultValueAttribute.Value != null ? defaultValueAttribute.Value.ToString() : null,
                    type = defaultValueAttribute.Value.GetType().ToString()
                };
                element.property.Add(e);
            }
        }
        private void VisitMethods(MethodInfo method, RegisterElement element)
        {
            var attribute = method.GetDependencyInjectionOnMethod();
            if( attribute == null ) return;

            var methodElement = new MethodElement()
            {
                name = method.Name
            };

            var param = this.VisitParam(method.GetParameters());

            methodElement.param = new List<ParamElement>();
            methodElement.param.AddRange(param);

            if( element.method == null ) element.method = new List<MethodElement>();
            element.method.Add(methodElement);

            return;
        }