public SerializationInfo(object dataInstance, Type dataType, EDataType eDataType)
 {
     SingleFieldTypeAttribute.ResolveForSerialization(ref dataType, ref eDataType, ref dataInstance);
     this.dataInstance = dataInstance;
     this.dataType     = dataType;
     this.eDataType    = eDataType;
 }
        private object DeserializeNodeValue(TokenNode node, Type type, EDataType eType, object instanceToUse = null)
        {
            switch (eType)
            {
            case EDataType.TypeConvertibleClass:
            case EDataType.Enum:
            case EDataType.Primitive:
            case EDataType.String: {
                return(DeserializeSimpleValue(node, type));
            }

            case EDataType.GenericList: {
                IList list          = (IList)(instanceToUse ?? Activator.CreateInstance(type));
                Type  listValueType = type.GetGenericArguments()[0];
                DeserializeListValue(node, listValueType, EDataTypes_Extensions.GetDataType(listValueType), list);
                return(list);
            }

            case EDataType.GenericDictionary: {
                IDictionary dictionary       = (IDictionary)(instanceToUse ?? (IDictionary)Activator.CreateInstance(type));
                Type[]      genericArguments = type.GetGenericArguments();
                Type        dictKeyType      = genericArguments[0];
                Type        dictValueType    = genericArguments[1];
                DeserializeDictionary(node, dictKeyType, dictValueType, EDataTypes_Extensions.GetDataType(dictValueType), dictionary);
                return(dictionary);
            }

            case EDataType.NonGenericClass: {
                if (SingleFieldTypeAttribute.IsSingleFieldType(type))
                {
                    List <FieldInfo> resolveFieldChain = SingleFieldTypeAttribute.ResolveFieldChain(type);
                    return(DeserializeSingleFieldType(node, type, instanceToUse, resolveFieldChain));
                }
                if (node.listValues.Count == 0)
                {
                    return(null);
                }
                object objectInstance = instanceToUse ?? Activator.CreateInstance(type);
                DeserializeNonGenericObject(node, type, eType, objectInstance);
                return(objectInstance);
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(eType), eType, null);
            }
        }