private bool ParametersMatch(Type type)
        {
            if (type.IsArray)
            {
                return(ParametersMatch(type.GetElementType()));
            }
            else if (type.IsEnum)
            {
                if (!Enum.IsDefined(type, DeserializedValue))
                {
                    return(false);
                }
            }
            else
            {
                Type deserializedType = DeserializedValue.GetType();

                if (deserializedType.IsArray)
                {
                    if (!type.IsAssignableFrom(deserializedType.GetElementType()))
                    {
                        return(false);
                    }
                }
                else if (!type.IsAssignableFrom(DeserializedValue.GetType()))
                {
                    return(false);
                }
            }

            return(true);
        }
        private bool ValueIsReference(MemberInfo member, object target)
        {
            if (DeserializedValue.GetType().IsArray)
            {
                Array array = (Array)DeserializedValue;

                if (array.Length > 0 && array != null)
                {
                    Type elementType = array.GetType().GetElementType();

                    if (elementType == typeof(Reference))
                    {
                        ArrayDeserializationHandler.Create(array, obj =>
                        {
                            DeserializedValue = obj;
                            Deserialize(target);
                        });

                        return(true);
                    }
                }
            }
            else if (DeserializedValue is Reference reference)
            {
                Deserializer.GetDeserializedObject(reference.ID, GetType(member), obj =>
                {
                    DeserializedValue = obj;
                    Deserialize(target);
                });

                return(true);
            }

            return(false);
        }
        private void AssignAsField(FieldInfo info, object target)
        {
            Type fieldType = info.FieldType;
            Type valueType = DeserializedValue.GetType();

            if (fieldType.IsEnum)
            {
                if (!Enum.IsDefined(fieldType, DeserializedValue))
                {
                    throw new ArgumentException("Type mismatch for field " + info + " - " + this);
                }
            }
            else if (!info.FieldType.IsAssignableFrom(valueType))
            {
                throw new ArgumentException("Type mismatch for field " + info + " - " + this);
            }

            info.SetValue(target, DeserializedValue);
        }
        private void AssignAsProperty(PropertyInfo info, object target)
        {
            MethodInfo setter = info.GetSetMethod();

            if (setter == null)
            {
                throw new ArgumentException("No setter for property " + info + " - " + this);
            }

            if (!ParamatersMatch(setter))
            {
                throw new ArgumentException("Parameters don't match for " + info + " - Value: " + DeserializedValue + "(" + DeserializedValue.GetType() + ")");
            }

            info.SetValue(target, DeserializedValue, null);
        }