public object Mapping(XElement element, Type type)
        {
            var typeArgs         = type.GetGenericArguments();
            var keyValueType     = typeof(KeyValueBuild <,>).MakeGenericType(typeArgs);
            var keyValueInstance = MappingerSelector.Get(keyValueType, ConvertCaseStrategy).Mapping(element, keyValueType);
            var property         = keyValueType.GetProperty("KeyValue");

            return(property.GetValue(keyValueInstance));
        }
        public object Mapping(XElement element, Type type)
        {
            var listType  = typeof(List <>);
            var arrayType = type.GetElementType();

            listType = listType.MakeGenericType(arrayType);

            IMappinger mappinger = MappingerSelector.Get(listType, ConvertCaseStrategy);

            var list = mappinger.Mapping(element, listType);


            return((Array)listType.GetMethod("ToArray").Invoke(list, null));
        }
        public object Mapping(XElement element, Type type)
        {
            //  创建List的实例
            var listTypeInstance = (IList)Activator.CreateInstance(type);

            var genericArg = type.GetGenericArguments().Single();
            var mappinger  = MappingerSelector.Get(genericArg, ConvertCaseStrategy);

            // 获取所有的element子项
            foreach (var item in element.Elements())
            {
                var itemMappinger = mappinger.Mapping(item, genericArg);
                listTypeInstance.Add(itemMappinger);
            }

            return(listTypeInstance);
        }
        public object Mapping(XElement element, Type type)
        {
            // Dictionary
            var listTypeInstance = (IDictionary)Activator.CreateInstance(type);

            var genericArg = type.GetGenericArguments();

            var keyType   = genericArg.First();
            var valueType = genericArg.Last();

            var mappingerKey   = MappingerSelector.Get(keyType, ConvertCaseStrategy);
            var mappingerValue = MappingerSelector.Get(valueType, ConvertCaseStrategy);

            var convertCaseKeyName   = ConvertCaseStrategy.ConvertCase(keyName);
            var convertCaseValueName = ConvertCaseStrategy.ConvertCase(valueName);

            // 获取所有的element子项
            foreach (var item in element.Elements())
            {
                var key   = GetValue(item, mappingerKey, keyType, convertCaseKeyName);
                var value = GetValue(item, mappingerValue, valueType, convertCaseValueName);

                if (key != null && value != null)
                {
                    object keyValue   = Convert.ChangeType(key, keyType);
                    object valueValue = Convert.ChangeType(value, valueType);

                    if (listTypeInstance.Contains(keyValue))
                    {
                        throw new SuperConfigException("Dictionary key 重复!");
                    }
                    listTypeInstance.Add(keyValue, valueValue);
                }
            }

            return(listTypeInstance);
        }